public write ( Yosymfony\Spress\Core\DataSource\ItemInterface $item ) | ||
$item | Yosymfony\Spress\Core\DataSource\ItemInterface |
public function testWriteItem() { $item = new Item('Test content', 'my-id'); $item->setPath('index.html', Item::SNAPSHOT_PATH_RELATIVE_AFTER_CONVERT); $item->setPath('index.html', Item::SNAPSHOT_PATH_PERMALINK); $dw = new FilesystemDataWriter(new Filesystem(), $this->tmpDir); $dw->write($item); $this->assertFileExists($this->tmpDir . '/index.html'); }
/** * {@inheritdoc} */ public function write(ItemInterface $item) { parent::write($item); if ($this->isWritable($item) === false) { return; } $writtenPath = $item->getPath(ItemInterface::SNAPSHOT_PATH_PERMALINK); $writtenExtension = pathinfo($writtenPath, PATHINFO_EXTENSION); $writeGzip = strlen($writtenPath) !== 0; $writeGzip = $writeGzip && !in_array($item->getId(), $this->configuration->getExcludedFiles()); $writeGzip = $writeGzip && in_array($writtenExtension, $this->configuration->getExtensions()); if ($writeGzip) { $this->filesystem->dumpFile($this->composeOutputPath($writtenPath . '.gz'), gzencode($item->getContent(), $this->configuration->getCompressionLevel())); } }