本文整理汇总了PHP中Zend\EventManager\Event::getParams方法的典型用法代码示例。如果您正苦于以下问题:PHP Event::getParams方法的具体用法?PHP Event::getParams怎么用?PHP Event::getParams使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\EventManager\Event
的用法示例。
在下文中一共展示了Event::getParams方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkUserCredentials
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: queueMail
/**
* @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: __invoke
/**
* 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: onSendEmail
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: accept
/**
* 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: getParams
/**
* 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: setEvent
/**
* 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: onAddItem
public function onAddItem(Event $e)
{
$this->addItemToCart($e->getCartItem());
$this->getEventManager()->trigger(CartEvent::EVENT_ADD_ITEM_POST, $this, $e->getParams());
}
示例9: translationListener
public function translationListener(Event $e)
{
$m = $e->getParams();
error_log(sprintf("missingTranslation;%s;%s;", $m['message'], $m['locale']));
}
示例10: setEvent
/**
* 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: getParams
/**
* {@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: navigationPageIsAllowed
/**
* 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: onMailSentError
/**
* 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: getParams
/**
* 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;
}