Newscoop\Service\Template::createFile PHP Method

createFile() public method

Create file
public createFile ( string $name ) : void
$name string
return void
    public function createFile($name)
    {
        try {
            $this->storage->createFile($name);
        } catch (\InvalidArgumentException $e) {
            throw new \InvalidArgumentException(sprintf('A file or folder having the name %s already exists', $name), $e->getCode(), $e);
        }
    }

Usage Example

Example #1
0
 public function createFileAction()
 {
     $path = $this->parsePath();
     $name = $this->formatName($this->_getParam('name'));
     try {
         $this->service->createFile(ltrim("{$path}/{$name}", ' /'));
         $this->_helper->flashMessenger(getGS("New template '\$1' created.", $name));
     } catch (\InvalidArgumentException $e) {
         $this->_helper->flashMessenger(array('error', $e->getMessage()));
     }
     $this->_redirect(urldecode($this->_getParam('next')), array('prependBase' => false));
 }
All Usage Examples Of Newscoop\Service\Template::createFile