public function generate($targetDir, \DateTime $date, $title, $layout, array $tags = [], array $categories = [])
    {
        if (0 === strlen(trim($title))) {
            throw new \RuntimeException('Unable to generate the post as the title is empty.');
        }

        if (file_exists($targetDir)) {
            if (false === is_dir($targetDir)) {
                throw new \RuntimeException(sprintf('Unable to generate the post as the target directory "%s" exists but is a file.', $targetDir));
            }

            if (false === is_writable($targetDir)) {
                throw new \RuntimeException(sprintf('Unable to generate the post as the target directory "%s" is not writable.', $targetDir));
            }
        }

        $model = [
            'layout' => $layout,
            'title' => $title,
            'categories' => $categories,
            'tags' => $tags,
        ];

        $this->cleanFilesAffected();

        $this->renderFile('post/post.md.twig', $targetDir.'/'.$this->getPostFilename($date, $title), $model);

        return $this->getFilesAffected();
    }
public function generate($targetDir, \DateTime $date, $title, $layout, array $tags = [], array $categories = [])
    {
        if (0 === strlen(trim($title))) {
            throw new \RuntimeException('Unable to generate the post as the title is empty.');
        }

        if (file_exists($targetDir)) {
            if (false === is_dir($targetDir)) {
                throw new \RuntimeException(sprintf('Unable to generate the post as the target directory "%s" exists but is a file.', $targetDir));
            }

            if (false === is_writable($targetDir)) {
                throw new \RuntimeException(sprintf('Unable to generate the post as the target directory "%s" is not writable.', $targetDir));
            }
        }

        $model = [
            'layout' => $layout,
            'title' => $title,
            'categories' => $categories,
            'tags' => $tags,
        ];

        $this->cleanFilesAffected();

        $this->renderFile('post/post.md.twig', $targetDir.'/'.$this->getPostFilename($date, $title), $model);

        return $this->getFilesAffected();
    }
public function generate ( $ targetDir , \ DateTime $ date , $ title , $ layout , array $ tags = [ ] , array $ categories = [ ] ) { if ( 0 === strlen ( trim ( $ title ) ) ) { throw new \ RuntimeException ( 'Unable to generate the post as the title is empty.' ) ; } if ( file_exists ( $ targetDir ) ) { if ( false === is_dir ( $ targetDir ) ) { throw new \ RuntimeException ( sprintf ( 'Unable to generate the post as the target directory "%s" exists but is a file.' , $ targetDir ) ) ; } if ( false === is_writable ( $ targetDir ) ) { throw new \ RuntimeException ( sprintf ( 'Unable to generate the post as the target directory "%s" is not writable.' , $ targetDir ) ) ; } } $ model = [ 'layout' => $ layout , 'title' => $ title , 'categories' => $ categories , 'tags' => $ tags , ] ; $ this -> cleanFilesAffected ( ) ; $ this -> renderFile ( 'post/post.md.twig' , $ targetDir . '/' . $ this -> getPostFilename ( $ date , $ title ) , $ model ) ; return $ this -> getFilesAffected ( ) ; }
Generates a post.

@param $targetDir string
@param $tdate DateTime
@param $title string
@param $layout string
@param $categories array
@param $tags array

@return array
Generates a post .