/** * @param VersionProviderEvent $event */ public function doPublish(VersionProviderEvent $event) { $versionable = $event->getVersionable(); if (!$versionable instanceof File) { return; } if (!$this->adapter->isFileReadableByAnonymous($versionable)) { return; } foreach ($event->getVersions() as $version) { $this->publisher->publishVersion($versionable, $version); } }
/** * @test */ public function unpublishShouldUnpublishFileVersion() { $adapter = new CopyFilesystemPublisherAdapter(ROOT_TESTS . '/data/publisher/public', "600", "700", ''); $publisher = new Publisher($adapter, new UniversalSequentialLinker()); $publisher->attachTo($this->filelib); $file = $this->filelib->uploadFile(ROOT_TESTS . '/data/self-lussing-manatee.jpg'); $publisher->publishVersion($file, Version::get('original')); $path = ROOT_TESTS . '/data/publisher/public/' . $publisher->getUrl($file, Version::get('original')); $this->assertFileExists($path); $this->assertFalse(is_link($path)); $publisher->unpublishVersion($file, Version::get('original')); $this->assertFileNotExists($path); }