ZF\Apigility\Doctrine\Server\Event\DoctrineResourceEvent::setEntity PHP Method

setEntity() public method

public setEntity ( mixed $entity )
$entity mixed
    public function setEntity($entity)
    {
        $this->entity = $entity;
        return $this;
    }

Usage Example

 /**
  * 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;
 }