public function checkUserCredentials(Event $e)
 {
     if ($e->getParams()['username'] == 'test_event_true') {
         $e->stopPropagation();
         return true;
     }
     if ($e->getParams()['username'] == 'test_event_false') {
         $e->stopPropagation();
         return false;
     }
 }
예제 #2
0
 /**
  * @param Event $e
  * @throws ServiceException
  */
 public function queueMail(Event $e)
 {
     /* @var ServiceManager $sl */
     $sl = $e->getTarget()->getServiceLocator();
     $data = $e->getParams();
     /* @var $mailQueue MailQueue */
     $mailQueue = $sl->get('UthandoMailQueue');
     $hydrator = $mailQueue->getHydrator();
     $model = $mailQueue->getModel();
     $model = $hydrator->hydrate($data, $model);
     $mailQueue->save($model);
 }
예제 #3
0
 /**
  * Allow calls as this would be a function.
  *
  * @param Event $event
  */
 public function __invoke(Event $event)
 {
     try {
         $connection = $this->factory->createConnection();
         $channel = $connection->channel();
         $channel->queue_declare('notify_queue', false, true, false, false);
         $msg = new AMQPMessage(json_encode($event->getParams()), ['delivery_mode' => 2]);
         $channel->basic_publish($msg, '', 'notify_queue');
         $channel->close();
         $connection->close();
     } catch (\Exception $e) {
         $this->logger->critical("Notify Service Event says: {$e->getMessage()}", $e->getTrace());
     }
 }
예제 #4
0
 public function onSendEmail(Event $e)
 {
     /** @var QueueInterface $queue */
     $queue = $this->queues->get('user');
     $emailJob = $queue->getJobPluginManager()->get(SendEmailJob::class);
     $email = $e->getParams();
     $html = $this->renderer->render($email->getHtmlTemplate(), $email->getVars());
     $text = $this->renderer->render($email->getTextTemplate(), $email->getVars());
     $message = new MessageStruct();
     $message->html = $html;
     $message->text = $text;
     $message->to = $email->getTo();
     $emailJob->setContent($message);
     $queue->push($emailJob);
 }
예제 #5
0
 /**
  * Determines whether a page should be accepted by ACL when iterating
  *
  * - If helper has no ACL, page is accepted
  * - If page has a resource or privilege defined, page is accepted if the
  *   ACL allows access to it using the helper's role
  * - If page has no resource or privilege, page is accepted
  * - If helper has ACL and role:
  *      - Page is accepted if it has no resource or privilege.
  *      - Page is accepted if ACL allows page's resource or privilege.
  *
  * @param  Event    $event
  * @return bool
  */
 public static function accept(Event $event)
 {
     $accepted = true;
     $params = $event->getParams();
     $acl = $params['acl'];
     $page = $params['page'];
     $role = $params['role'];
     if (!$acl) {
         return $accepted;
     }
     $resource = $page->getResource();
     $privilege = $page->getPrivilege();
     if ($resource || $privilege) {
         $accepted = $acl->hasResource($resource) && $acl->isAllowed($role, $resource, $privilege);
     }
     return $accepted;
 }
예제 #6
0
 /**
  * Get all event parameters
  *
  * @return array|\ArrayAccess
  */
 public function getParams()
 {
     $params = parent::getParams();
     $params['model'] = $this->getModel();
     $params['renderer'] = $this->getRenderer();
     $params['request'] = $this->getRequest();
     $params['response'] = $this->getResponse();
     $params['result'] = $this->getResult();
     return $params;
 }
예제 #7
0
 /**
  * Set an event to use during dispatch
  *
  * By default, will re-cast to AdapterChainEvent if another event type is provided.
  *
  * @param  Event $e
  * @return AdapterChain
  */
 public function setEvent(Event $e)
 {
     if (!$e instanceof AdapterChainEvent) {
         $eventParams = $e->getParams();
         $e = new AdapterChainEvent();
         $e->setParams($eventParams);
     }
     $this->event = $e;
     return $this;
 }
예제 #8
0
 public function onAddItem(Event $e)
 {
     $this->addItemToCart($e->getCartItem());
     $this->getEventManager()->trigger(CartEvent::EVENT_ADD_ITEM_POST, $this, $e->getParams());
 }
예제 #9
0
파일: Module.php 프로젝트: ifigenija/server
 public function translationListener(Event $e)
 {
     $m = $e->getParams();
     error_log(sprintf("missingTranslation;%s;%s;", $m['message'], $m['locale']));
 }
예제 #10
0
 /**
  * Set an event to use during the queue event flow
  *
  * By default, will re-cast to QueueEvent if another event type is provided.
  *
  * @param  Event $e
  * @return Queue
  */
 public function setEvent(Event $e)
 {
     if (!$e instanceof QueueEvent) {
         $eventParams = $e->getParams();
         $e = new QueueEvent();
         $e->setParams($eventParams);
         unset($eventParams);
     }
     $this->event = $e;
     return $this;
 }
예제 #11
0
 /**
  * {@inheritdoc}
  */
 public function getParams()
 {
     $params = parent::getParams();
     $isObject = is_object($params);
     foreach ($this->specializedParams as $param) {
         if ($isObject) {
             $params->{$param} = $this->{'get' . $param}();
         } else {
             $params[$param] = $this->{'get' . $param}();
         }
     }
     return $params;
 }
예제 #12
0
파일: Module.php 프로젝트: patrova/omeka-s
 /**
  * Determine whether a navigation page is allowed.
  *
  * @param Event $event
  * @return bool
  */
 public function navigationPageIsAllowed(Event $event)
 {
     $accepted = true;
     $params = $event->getParams();
     $acl = $params['acl'];
     $page = $params['page'];
     if (!$acl) {
         return $accepted;
     }
     $resource = $page->getResource();
     $privilege = $page->getPrivilege();
     if ($resource || $privilege) {
         $accepted = $acl->hasResource($resource) && $acl->userIsAllowed($resource, $privilege);
     }
     $event->stopPropagation();
     return $accepted;
 }
예제 #13
0
 /**
  * Callback function invoking on mail sending error
  *
  * @param Event $e
  */
 public function onMailSentError(Event $e)
 {
     /* @var Message */
     $message = $e->getTarget();
     $params = $e->getParams();
     $addressList = $this->prepareAddressList($message);
     $this->logger->err(sprintf("E-mail '%s' has been not sent to following recipients: %s. Error message: %s", $message->getSubject(), implode(', ', $addressList), $params['error_message']));
 }
예제 #14
0
 /**
  * Get all event parameters
  *
  * @return array|\ArrayAccess
  */
 public function getParams()
 {
     $params = parent::getParams();
     $params['processor'] = $this->getProcessor();
     $params['message'] = $this->getMessage();
     $params['result'] = $this->getResult();
     return $params;
 }