Exemplo n.º 1
0
 /**
  * {@inheritdoc}
  *
  * @throws \Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException
  */
 protected function dispatchEvent($action, &$entity, $isNew = false, Event $event = null)
 {
     if (!$entity instanceof Role) {
         throw new MethodNotAllowedHttpException(['Role'], 'Entity must be of class Role()');
     }
     switch ($action) {
         case 'pre_save':
             $name = UserEvents::ROLE_PRE_SAVE;
             break;
         case 'post_save':
             $name = UserEvents::ROLE_POST_SAVE;
             break;
         case 'pre_delete':
             $name = UserEvents::ROLE_PRE_DELETE;
             break;
         case 'post_delete':
             $name = UserEvents::ROLE_POST_DELETE;
             break;
         default:
             return null;
     }
     if ($this->dispatcher->hasListeners($name)) {
         if (empty($event)) {
             $event = new RoleEvent($entity, $isNew);
             $event->setEntityManager($this->em);
         }
         $this->dispatcher->dispatch($name, $event);
         return $event;
     }
     return null;
 }
Exemplo n.º 2
0
 /**
  * Add a role delete entry to the audit log
  *
  * @param Events\RoleEvent $event
  */
 public function onRoleDelete(Events\RoleEvent $event)
 {
     $role = $event->getRole();
     $log = array("bundle" => "user", "object" => "role", "objectId" => $role->deletedId, "action" => "delete", "details" => array('name' => $role->getName()), "ipAddress" => $this->factory->getIpAddressFromRequest());
     $this->factory->getModel('core.auditLog')->writeToLog($log);
 }
Exemplo n.º 3
0
 /**
  * Add a role delete entry to the audit log.
  *
  * @param Events\RoleEvent $event
  */
 public function onRoleDelete(Events\RoleEvent $event)
 {
     $role = $event->getRole();
     $log = ['bundle' => 'user', 'object' => 'role', 'objectId' => $role->deletedId, 'action' => 'delete', 'details' => ['name' => $role->getName()], 'ipAddress' => $this->ipLookupHelper->getIpAddressFromRequest()];
     $this->auditLogModel->writeToLog($log);
 }