/** * @param FileEvent $event */ public function doPermissionsCheck(FileEvent $event) { if ($this->adapter->isFileReadableByAnonymous($event->getFile())) { return; } $this->publisher->unpublishAllVersions($event->getFile()); }
public function checkFileRead(FileEvent $event) { $file = $event->getFile(); if (!$this->adapter->isFileReadable($file)) { $this->dispatchDenyEvent($file); throw $this->createAccessDeniedException($file, 'read'); } }
/** * @test */ public function eventShouldInitializeCorrectly() { $file = $this->getMockedFile(); $event = new FileEvent($file); $file2 = $event->getFile(); $this->assertSame($file, $file2); $file3 = $event->getIdentifiable(); $this->assertSame($file, $file3); }
public function beforeCreate(FileEvent $event) { $file = $event->getFile(); if (!$this->belongsToProfile($file->getProfile())) { return; } $file->getData()->set('plugin.randomize_name.original_name', $file->getName()); $pinfo = pathinfo($file->getName()); $newName = Uuid::uuid4()->toString(); if (isset($pinfo['extension']) && $pinfo['extension']) { $newName .= '.' . $pinfo['extension']; } $file->setName($newName); }
public function __construct(File $file, array $versions) { parent::__construct($file); $this->versions = array_map(function ($version) { return Version::get($version); }, $versions); }
/** * @param FileEvent $event */ public function onFileDelete(FileEvent $event) { $this->deleteProvidedVersions($event->getFile()); }
/** * @param FileEvent $event */ public function onBeforeDelete(FileEvent $event) { $file = $event->getFile(); $this->unpublishAllVersions($file); }