本文整理匯總了PHP中Symfony\Component\EventDispatcher\Event::getName方法的典型用法代碼示例。如果您正苦於以下問題:PHP Event::getName方法的具體用法?PHP Event::getName怎麽用?PHP Event::getName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Symfony\Component\EventDispatcher\Event
的用法示例。
在下文中一共展示了Event::getName方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: addSuccessFlash
public function addSuccessFlash(Event $event)
{
if (!isset(self::$successMessages[$event->getName()])) {
throw new \InvalidArgumentException('This event does not correspond to a known flash message');
}
$this->session->getFlashBag()->add('success', $this->trans(self::$successMessages[$event->getName()]));
}
示例2: buildActionEvent
/**
* Build action event with objects mapped from cause event
*
* @access public
* @param mixed $name
* @param Event $mappedEvent (default: null)
* @param array $mappedObjects (default: array())
* @return Event
*/
public function buildActionEvent(ActionEventInterface $actionEvent, Event $mappedEvent)
{
$mappedObjects = $actionEvent->getObjects();
if (!($mappedEventMap = $this->getEventMap($mappedEvent->getName()))) {
throw new \InvalidArgumentException('Undefined mapped event "' . $mappedEvent->getName() . '"');
}
if (!($eventMap = $this->getEventMap($actionEvent->getName()))) {
throw new \InvalidArgumentException('Undefined action event "' . $actionEvent->getName() . '"');
}
$eventClass = $eventMap->getClass();
$event = new $eventClass();
foreach ($eventMap->getSetters() as $method => $setterMeta) {
$field = $setterMeta['field'];
$value = null;
if (isset($mappedObjects[$field])) {
$value = $mappedObjects[$field];
} else {
foreach ($mappedEventMap->getGetters() as $getterMethod => $getterMeta) {
if ($setterMeta['field'] == $getterMeta['field']) {
$value = $mappedEvent->{$getterMethod}();
break;
}
}
}
if ($value) {
$isFunction = 'is_' . $setterMeta['type'];
$validObject = false;
if (function_exists($isFunction) && $isFunction($value)) {
$validObject = true;
} elseif ($value instanceof $setterMeta['type']) {
$validObject = true;
}
if ($validObject) {
$event->{$method}($value);
continue;
}
}
if ($setterMeta['required']) {
throw new \UnexpectedValueException(sprintf('Not found object for method "%s" of the event "%s" (with event name "%s")', $method, $eventClass, $actionEvent->getName()));
}
}
return $event;
}
示例3: addSuccessFlash
public function addSuccessFlash(Event $event, $eventName = null)
{
// BC for SF < 2.4
if (null === $eventName) {
$eventName = $event->getName();
}
if (!isset(self::$successMessages[$eventName])) {
throw new \InvalidArgumentException('This event does not correspond to a known flash message');
}
$this->session->getFlashBag()->add('success', $this->trans(self::$successMessages[$eventName]));
}
示例4: getTemplateConfigName
public function getTemplateConfigName(Event $event = null)
{
switch ($event->getName()) {
case MailerBundleEvents::NOTIFICATIONS_PASSWORD_RESET:
return 'notification.password_reset';
case MailerBundleEvents::NOTIFICATIONS_PASSWORD_CONFIRM:
return 'notification.password_confirm';
default:
throw new \Exception('Unsupported event.');
}
}
示例5: filter
/**
* Filters a value by calling all listeners of a given event.
*
* @param Event $event A Event instance
* @param mixed $value The value to be filtered
*
* @return Event The Event instance
*/
public function filter(Event $event, $value)
{
foreach ($this->getListeners($event->getName()) as $listener) {
if (null !== $this->logger) {
$this->logger->debug(sprintf('Notifying (filter) event "%s" to listener "%s"', $event->getName(), $this->listenerToString($listener)));
}
$value = call_user_func($listener, $event, $value);
}
$event->setReturnValue($value);
return $event;
}
示例6: handleEvent
public function handleEvent(Event $event)
{
$rules = $this->ruleManager->findRulesByEventName($event->getName());
if (sizeof($rules)) {
foreach ($rules as $rule) {
if ($this->evaluateRule($rule, $event)) {
$this->dispatchActionEvents($rule, $event);
}
}
}
return $event;
}
示例7: brocast
protected function brocast(Event $event)
{
$eventName = $event->getName();
$listeners = [];
foreach ($this->events[$eventName] as &$eventGroup) {
foreach ($eventGroup as $listenerArray) {
list($listener, $priority) = $listenerArray;
$listeners[$priority][] = $listener;
}
}
krsort($listeners);
$processCount = 0;
foreach ($listeners as $listener) {
foreach ($listener as $callback) {
if ($event && $event->isPropagationStopped()) {
return $processCount;
}
$callback($event);
$processCount++;
}
}
return $processCount;
}
示例8: testSetName
public function testSetName()
{
$this->event->setName('foo');
$this->assertEquals('foo', $this->event->getName());
}
示例9: testLegacySetName
public function testLegacySetName()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$this->event->setName('foo');
$this->assertEquals('foo', $this->event->getName());
}
示例10: dispatchAsync
/**
* Serialize the event data and publish it to the redis queue.
*
* @param Event $event
*
* @return Event
*/
public function dispatchAsync(Event $event = null)
{
$this->getMqService()->publish($event->getName(), serialize($event));
return $event;
}
示例11: getTestName
protected function getTestName(Event $e)
{
if ($e instanceof TestEvent || $e instanceof FailEvent) {
$test = $e->getTest();
return method_exists($test, 'getSignature') ? $test->getSignature() : get_class($test) . ":{$test->getName(false)}";
} elseif ($e instanceof SuiteEvent) {
return $e->getSuite()->getName();
} else {
return $e->getName();
}
}
示例12: fireStepHooks
/**
* Handle Step Events & Fire Associated Hooks.
*
* @param Event $event event
*/
public function fireStepHooks(Event $event)
{
switch ($event->getName()) {
case 'step.run.before':
$hookName = 'step.before';
break;
case 'step.run.after':
$hookName = 'step.after';
break;
}
$step = $event->getSubject();
$tagsFilter = $this->tagsFilter;
$nameFilter = $this->nameFilter;
$this->fireHooks($event, $hookName, function ($hook) use($step, $tagsFilter) {
return $tagsFilter->isStepMatchFilter($step, $hook[0]);
}, function ($hook) use($step, $nameFilter) {
return $nameFilter->isStepMatchFilter($step, $hook[0]);
});
}
示例13: addCall
protected function addCall(Event $event, $listener, $type)
{
$listener = $this->listenerToString($listener);
if (null !== $this->logger) {
$this->logger->debug(sprintf('Notified event "%s" to listener "%s" (%s)', $event->getName(), $listener, $type));
}
$this->called[$event->getName() . '.' . $listener] = array('event' => $event->getName(), 'caller' => null !== $event->getSubject() ? get_class($event->getSubject()) : null, 'listener' => $listener);
}
示例14: onCatalogDEvent
public function onCatalogDEvent(Event $event)
{
$this->logger->debug(sprintf('Fired event "%s"', $event->getName()));
}
示例15: recordNotification
public function recordNotification(Event $event)
{
$this->lastNotification = $event->getName();
}