Inheritance: extends Doctrine\ORM\EntityRepository, implements Sulu\Bundle\MediaBundle\Entity\FileVersionMetaRepositoryInterface
Esempio n. 1
0
 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);
 }
Esempio n. 2
0
 /**
  * Removes all FileVersionMetas belonging to the collection, which just got secured.
  *
  * @param PermissionUpdateEvent $event
  */
 public function onPermissionUpdate(PermissionUpdateEvent $event)
 {
     if ($event->getType() !== Collection::class) {
         return;
     }
     foreach ($this->fileVersionMetaRepository->findByCollectionId($event->getIdentifier()) as $fileVersionMeta) {
         $this->searchManager->deindex($fileVersionMeta);
     }
 }
 public function testFindByCollectionId()
 {
     $collection = new Collection();
     $collection->setType($this->collectionType);
     $this->em->persist($collection);
     $this->createFile('Old Title 1', 'New Title 1');
     $this->createFile('Old Title 2', 'New Title 2');
     $this->createFile('Old Title 3', 'New Title 3', $collection);
     $this->em->flush();
     $titles = array_map(function (FileVersionMeta $fileVersionMeta) {
         return $fileVersionMeta->getTitle();
     }, $this->fileVersionMetaRepository->findByCollectionId($this->collection->getId()));
     $this->assertContains('New Title 1', $titles);
     $this->assertContains('New Title 2', $titles);
     $this->assertContains('Old Title 1', $titles);
     $this->assertContains('Old Title 2', $titles);
     $this->assertNotContains('New Title 3', $titles);
     $this->assertNotContains('Old Title 3', $titles);
 }