Exemple #1
0
 public function testSetDestinationPaths()
 {
     $fileItem = new FileItem($this->mock, FileItem::TYPE_POST);
     $fileItem->setDestinationPaths(array('/spress_test/_site/2013/08/22/example.html'));
     $this->assertTrue(is_array($fileItem->getDestinationPaths()));
     $this->assertCount(1, $fileItem->getDestinationPaths());
 }
Exemple #2
0
 /**
  * Constructor
  * 
  * @param FileItem $fileItem
  * @param Yosymfony\Spress\Configuration $configuration
  */
 public function __construct(FileItem $fileItem, $configuration)
 {
     $this->fileItem = $fileItem;
     $this->extension = $fileItem->getExtension();
     $this->configuration = $configuration;
     $this->frontmatter = new Frontmatter($this->fileItem->getSourceContent(), $configuration);
     $this->setPreConverterContent($this->frontmatter->getContentNotFrontmatter());
 }
Exemple #3
0
 /**
  * Constructor
  * 
  * @param FileItem $fileItem
  * @param Yosymfony\Spress\Configuration $configuration
  */
 public function __construct(FileItem $fileItem, $configuration)
 {
     if ($fileItem->getType() !== FileItem::TYPE_PAGE) {
         throw new \InvalidArgumentException(sprintf('Type item "%s" is invalid in page item.', $fileItem->getType()));
     }
     parent::__construct($fileItem, $configuration);
     $this->setUpDestinationPath();
 }
Exemple #4
0
 /**
  * Constructor
  * 
  * @param FileItem $fileItem
  * @param Yosymfony\Spress\Configuration $configuration
  */
 public function __construct(FileItem $fileItem, $configuration)
 {
     if ($fileItem->getType() !== FileItem::TYPE_POST) {
         throw new \InvalidArgumentException(sprintf('Type item "%s" is invalid in post item'));
     }
     parent::__construct($fileItem, $configuration);
     $this->extractDataFromFilename();
     $this->setUpDestinationPath();
 }
Exemple #5
0
 /**
  * Save a FileItem into destiny paths
  * 
  * @param FileItem $item
  */
 public function saveItem(FileItem $item)
 {
     $fs = new Filesystem();
     $paths = $item->getDestinationPaths();
     if (0 == count($paths)) {
         throw new \LengthException('No destination paths found');
     }
     foreach ($paths as $destination) {
         $fs->dumpFile($this->getDestinationDir() . '/' . $destination, $item->getDestinationContent());
     }
 }