Sulu\Bundle\MediaBundle\Search\EventListener\PermissionListener::onPermissionUpdate PHP Method

onPermissionUpdate() public method

Removes all FileVersionMetas belonging to the collection, which just got secured.
public onPermissionUpdate ( PermissionUpdateEvent $event )
$event Sulu\Component\Security\Event\PermissionUpdateEvent
    public function onPermissionUpdate(PermissionUpdateEvent $event)
    {
        if ($event->getType() !== Collection::class) {
            return;
        }
        foreach ($this->fileVersionMetaRepository->findByCollectionId($event->getIdentifier()) as $fileVersionMeta) {
            $this->searchManager->deindex($fileVersionMeta);
        }
    }

Usage Example

 public function testOnPermissionUpdateWrongType()
 {
     $event = new PermissionUpdateEvent(\stdClass::class, '1', null);
     $this->fileVersionMetaRepository->findByCollectionId(Argument::any())->shouldNotBeCalled();
     $this->searchManager->deindex(Argument::any())->shouldNotBeCalled();
     $this->permissionListener->onPermissionUpdate($event);
 }