Inheritance: extends Zend\EventManager\Event
Esempio n. 1
0
 /**
  * @param DoctrineResourceEvent $e
  */
 public function fetchAll(DoctrineResourceEvent $e)
 {
     /** @var QueryBuilder $queryBuilder */
     $queryBuilder = $e->getQueryBuilder();
     $user = $this->getUser($e, $this->userService);
     $this->groupService->fetchUserGroupsApi($queryBuilder, $user);
 }
Esempio n. 2
0
 public function onPreCreateEvent(DoctrineResourceEvent $e)
 {
     /**
      * @var User $entity
      */
     $entity = $e->getEntity();
     $entity->changePassword('Welcome123');
 }
 public function createPost(DoctrineResourceEvent $event)
 {
     $objectManager = $event->getObjectManager();
     $event->getEntity();
     $event->getData();
     $event->getResourceEvent();
     $event->getEntityClassName();
     $event->getEntityId();
 }
Esempio n. 4
0
 /**
  * @param DoctrineResourceEvent $e
  * @return \ZF\ApiProblem\ApiProblem
  */
 public function patch(DoctrineResourceEvent $e)
 {
     /** @var Note $note */
     $note = $e->getEntity();
     $user = $this->getUser($e, $this->userService);
     $editCheck = $this->noteService->checkNoteEditPermission($user->getId(), $note->getId());
     if ($editCheck === false) {
         return new ApiProblem(403, 'User is not allowed to edit note');
     }
 }
 /**
  * This method will give custom listeners te chance to alter entities / collections.
  * Listeners can also return an ApiProblem, which will be returned immediately.
  * It is also possible to throw Exceptions, which will result in an ApiProblem eventually.
  *
  * @param $name
  * @param $entity
  * @param $data mixed The original data supplied to the resource method, if any
  *
  * @return \Zend\EventManager\ResponseCollection
  */
 protected function triggerDoctrineEvent($name, $entity, $data = null)
 {
     $event = new DoctrineResourceEvent($name, $this);
     $event->setEntity($entity);
     $event->setData($data);
     $event->setObjectManager($this->getObjectManager());
     $event->setResourceEvent($this->getEvent());
     $eventManager = $this->getEventManager();
     $response = $eventManager->trigger($event);
     return $response;
 }
 /**
  * @param DoctrineResourceEvent $event
  *
  * @return array
  */
 public function handleCollections(DoctrineResourceEvent $event)
 {
     // Setup the dependencies
     $this->setObjectManager($event->getObjectManager());
     $this->setRootEntity($event->getEntity());
     $this->setObjectData((array) $event->getData());
     $this->setInputFilter($event->getResourceEvent()->getInputFilter());
     $this->setServiceManager($event->getTarget()->getServiceManager());
     // Start processing with the root entity, if any nested entities will be handled by the iterateEntity method
     $this->setObjectData($this->iterateEntity($this->getRootEntity(), $this->getObjectData(), $this->getInputFilter()));
     $event->setData($this->getObjectData());
     return $this->getObjectData();
 }
 /**
  * @param DoctrineResourceEvent $e
  * @param Service\User $userService
  * @return Entity\User
  */
 protected function getUser(DoctrineResourceEvent $e, Service\User $userService)
 {
     return $userService->getUserByMail($e->getResourceEvent()->getIdentity()->getName());
 }