/**
  * @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');
     }
 }
Example #3
0
 /**
  * @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);
 }
Example #5
0
 public function __construct(File $file, array $versions)
 {
     parent::__construct($file);
     $this->versions = array_map(function ($version) {
         return Version::get($version);
     }, $versions);
 }
Example #6
0
 /**
  * @param FileEvent $event
  */
 public function onFileDelete(FileEvent $event)
 {
     $this->deleteProvidedVersions($event->getFile());
 }
Example #7
0
 /**
  * @param FileEvent $event
  */
 public function onBeforeDelete(FileEvent $event)
 {
     $file = $event->getFile();
     $this->unpublishAllVersions($file);
 }