This data writer uses SNAPSHOT_PATH_PERMALINK for working
with the path of the items. In case of binary item this data writer
uses SNAPSHOT_PATH_SOURCE and SNAPSHOT_PATH_RELATIVE_AFTER_CONVERT.
public function testCleanUp() { $fs = new FileSystem(); $fs->dumpFile($this->tmpDir . '/dummy-file', 'Dummy content.'); $dw = new FilesystemDataWriter(new Filesystem(), $this->tmpDir); $dw->setUp(); $this->assertFileNotExists($this->tmpDir . '/dummy-file'); }
/** * {@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())); } }