本文整理匯總了PHP中Symfony\Component\EventDispatcher\Event::getArgument方法的典型用法代碼示例。如果您正苦於以下問題:PHP Event::getArgument方法的具體用法?PHP Event::getArgument怎麽用?PHP Event::getArgument使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Symfony\Component\EventDispatcher\Event
的用法示例。
在下文中一共展示了Event::getArgument方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: onRulesEvent
/**
* Reacts on the given event and invokes configured reaction rules.
*
* @param \Symfony\Component\EventDispatcher\Event $event
* The event object containing context for the event.
* @param string $event_name
* The event name.
*/
public function onRulesEvent(Event $event, $event_name)
{
// Load reaction rule config entities by $event_name.
$storage = $this->entityManager->getStorage('rules_reaction_rule');
// @todo Only load active reaction rules here.
$configs = $storage->loadByProperties(['event' => $event_name]);
// Loop over all rules and execute them.
foreach ($configs as $rules_config) {
$reaction_rule = $rules_config->getExpression();
$context_names = array_keys($reaction_rule->getContextDefinitions());
foreach ($context_names as $context_name) {
// If this is a GenericEvent get the context for the rule from the event
// arguments.
if ($event instanceof GenericEvent) {
$reaction_rule->setContextValue($context_name, $event->getArgument($context_name));
}
}
$reaction_rule->execute();
}
}
示例2: getData
public function getData(Event $event)
{
$institutionMedicalCenter = $event->getSubject();
$institution = $institutionMedicalCenter->getInstitution();
$router = $this->container->get('router');
$urlCenter = $router->generate('institution_medicalCenter_view', array('imcId' => $institutionMedicalCenter->getId()), true);
$to = $event->getArgument('userEmail');
$inquiriesEmail = $institutionMedicalCenter->getContactEmail();
if (empty($inquiriesEmail)) {
if (!($inquiriesEmail = $institution->getContactEmail())) {
$inquiriesEmail = $this->container->get('services.institution')->getAccountOwner($institution)->getEmail();
}
}
$bcc = array('jason.coppage@chromedia.com' => 'Jason Coppage', 'greg.mogab@healthcareabroad.com' => 'Greg Mogab', 'kimberly.damlani@healthcareabroad.com' => 'Kimberly Damlani', 'harold.modesto@chromedia.com' => 'Harold Modesto');
$data = array('clinic_name' => $institutionMedicalCenter->getName(), 'institution_name' => $institution->getName(), 'to' => $to, 'bcc' => $bcc, 'email' => array('inquiries' => $inquiriesEmail), 'url' => array('center' => $urlCenter, 'add_centers' => $router->generate('institution_medicalCenter_index', array(), true), 'center_gallery' => $router->generate('institution_mediaGallery_index', array(), true), 'center_treatments' => $urlCenter . '#specializations', 'center_doctors' => $urlCenter . '#doctors', 'contact_info' => $urlCenter . '#contact-details'));
$accountOwnerEmail = $this->container->get('services.institution')->getAccountOwner($institution)->getEmail();
if (strtolower($to) != strtolower($accountOwnerEmail)) {
$data['cc'] = $accountOwnerEmail;
}
return $data;
}
示例3: onRulesEvent
/**
* Reacts on the given event and invokes configured reaction rules.
*
* @param \Symfony\Component\EventDispatcher\Event $event
* The event object containing context for the event.
* @param string $event_name
* The event name.
*/
public function onRulesEvent(Event $event, $event_name)
{
// Load reaction rule config entities by $event_name.
$storage = $this->entityTypeManager->getStorage('rules_reaction_rule');
// @todo Only load active reaction rules here.
$configs = $storage->loadByProperties(['event' => $event_name]);
// Set up an execution state with the event context.
$event_definition = $this->eventManager->getDefinition($event_name);
$state = ExecutionState::create();
foreach ($event_definition['context'] as $context_name => $context_definition) {
// If this is a GenericEvent get the context for the rule from the event
// arguments.
if ($event instanceof GenericEvent) {
$value = $event->getArgument($context_name);
} else {
$value = $event->{$context_name};
}
$state->setVariable($context_name, $context_definition, $value);
}
// Loop over all rules and execute them.
foreach ($configs as $config) {
/** @var \Drupal\rules\Entity\ReactionRuleConfig $config */
$config->getExpression()->executeWithState($state);
}
$state->autoSave();
}
示例4: getVerboseError
/**
* Get detailed error message
*
* @param Event $event
* @return string error message
*/
protected function getVerboseError(Event $event)
{
$errorTrace = $event->getArgument('exception')->getTraceAsString();
$error = sprintf("\nBacktrace:\n%s", $errorTrace);
$jsonRequest = $event->getArgument('request');
if (isset($jsonRequest)) {
$jsonRequest = json_encode($jsonRequest);
$error .= sprintf("\nRequest:\n%s", $jsonRequest);
}
return $error;
}