Ejemplo n.º 1
0
 /**
  * @param FileEvent $event
  */
 public function doPermissionsCheck(FileEvent $event)
 {
     if ($this->adapter->isFileReadableByAnonymous($event->getFile())) {
         return;
     }
     $this->publisher->unpublishAllVersions($event->getFile());
 }
Ejemplo n.º 2
0
 public function checkFileRead(FileEvent $event)
 {
     $file = $event->getFile();
     if (!$this->adapter->isFileReadable($file)) {
         $this->dispatchDenyEvent($file);
         throw $this->createAccessDeniedException($file, 'read');
     }
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 4
0
 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);
 }
Ejemplo n.º 5
0
 public function __construct(File $file, array $versions)
 {
     parent::__construct($file);
     $this->versions = array_map(function ($version) {
         return Version::get($version);
     }, $versions);
 }
Ejemplo n.º 6
0
 /**
  * @param FileEvent $event
  */
 public function onFileDelete(FileEvent $event)
 {
     $this->deleteProvidedVersions($event->getFile());
 }
Ejemplo n.º 7
0
 /**
  * @param FileEvent $event
  */
 public function onBeforeDelete(FileEvent $event)
 {
     $file = $event->getFile();
     $this->unpublishAllVersions($file);
 }