本文整理汇总了PHP中Event::getName方法的典型用法代码示例。如果您正苦于以下问题:PHP Event::getName方法的具体用法?PHP Event::getName怎么用?PHP Event::getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Event
的用法示例。
在下文中一共展示了Event::getName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: dispatch
/**
* @inheritdoc
*/
public function dispatch(Event $event)
{
if (isset($this->listeners[$event->getName()])) {
foreach ($this->listeners[$event->getName()] as $listener) {
call_user_func($listener, $event);
}
}
}
示例2: dispatch
public function dispatch(Event $event)
{
if (empty($this->listeners[$event->getName()])) {
return;
}
foreach ($this->listeners[$event->getName()] as $listener) {
call_user_func($listener, $event);
}
}
示例3: attach
/**
* @param \Event $event
*/
public static function attach(\Event $event)
{
if ($event->ready) {
if (!isset(self::$events[$event->getName()])) {
self::$events[$event->getName()] = [];
}
if (!is_array(self::$events[$event->getName()])) {
self::$events[$event->getName()] = [];
}
self::$events[$event->getName()][] = $event;
}
}
示例4: getEventName
/**
* @param string|Event $event
* @return string
*/
protected function getEventName($event)
{
if ($event instanceof Event) {
return $event->getName();
}
return $event;
}
示例5: apply
public function apply(Event $event)
{
$method = 'apply' . $event->getName();
if (method_exists($this, $method)) {
$this->{$method}($event);
}
}
示例6: trigger
/**
* Trigger event
* @api
* @param string $event
* @param string|object $target
* @param array|object $params
* @return string|object
*/
public function trigger($event, $target = null, $params = null)
{
if (!$event instanceof Event) {
$event = new Event($event, $target, $params);
}
if (strstr($event->getName(), ':')) {
$namespace = substr($event->getName(), 0, strpos($event->getName(), ':'));
if (isset($this->listeners[$namespace])) {
$this->fire($this->listeners[$namespace], $event);
}
}
if (isset($this->listeners[$event->getName()])) {
$this->fire($this->listeners[$event->getName()], $event);
}
return $event->getTarget();
}
示例7: filter
/**
* Filters a value by calling all listeners of a given event.
*
* @param sfEvent $event A sfEvent instance
* @param mixed $value The value to be filtered
*
* @return sfEvent The sfEvent instance
*/
public function filter(Event $event, $value)
{
foreach ($this->getListeners($event->getName()) as $listener) {
$value = call_user_func_array($listener, array($event, $value));
}
$event->setReturnValue($value);
return $event;
}
示例8: fire
public function fire(Event $event)
{
$name = $event->getName();
if (!in_array($name, $this->events)) {
return;
}
call_user_func($this->closure, $event);
}
示例9: addEvent
/**
* @return null
*/
public function addEvent(Event $event)
{
$name = $event->getName();
if (!$this->hasEvent($name)) {
$this->events[$name] = [];
}
$this->events[$name][] = $event;
}
示例10: encoder_redirect_success
function encoder_redirect_success(Event $new_Event)
{
$new_Event_name = $new_Event->getName();
$dir = "VIEW/html/Encoder/Add_Event/Event_List.php?success_edit=1";
$url = BASE_URL . $dir;
header("Location:{$url}");
//redirect the encoder to the Events add place
exit;
}
示例11: testConstruct
/**
* @covers Panadas\Event\Event::__construct()
* @covers Panadas\Event\Event::getName()
* @covers Panadas\Event\Event::setName()
* @covers Panadas\Event\Event::getPublisher()
* @covers Panadas\Event\Event::setPublisher()
* @covers Panadas\Event\Event::getParams()
* @covers Panadas\Event\Event::setParams()
*/
public function testConstruct()
{
$name = "foo";
$publisher = new Publisher();
$params = ["paramkey" => "paramvalue"];
$event = new Event($name, $publisher, $params);
$this->assertEquals($name, $event->getName());
$this->assertInstanceOf("Panadas\\Event\\DataStructure\\EventParams", $event->getParams());
$this->assertSame($publisher, $event->getPublisher());
}
示例12: fireEvent
private function fireEvent(Event $event)
{
$listeners = $this->getListeners($event->getName());
if (!$listeners) {
return;
}
foreach ($listeners as $listener) {
$listener->handle($event);
}
}
示例13: encoder_redirect_success
function encoder_redirect_success(Event $event)
{
$Name = $event->getName();
$Name_Amharic = $event->getNameAmharic();
$dir = "VIEW/html/Encoder/Add_Event/Add_Events.php?success=1&Name={$Name}&Name_Amharic={$Name_Amharic}";
$url = BASE_URL . $dir;
header("Location:{$url}");
//redirect the encoder to the regions add place
exit;
}
示例14: broadcast
public function broadcast(Event $event)
{
$name = $event->getName();
if (!isset($this->listeners[$name])) {
return;
}
foreach ($this->listeners[$name] as $listener) {
if ($event->isPropagationStopped()) {
break;
}
$listener->fire($event);
}
}
示例15: triggerEvent
public function triggerEvent(Event $event)
{
$eventName = $event->getName();
if (!isset($this->handlers[$eventName])) {
return $event;
}
foreach ($this->handlers[$eventName] as $handler) {
$handler->handle($event);
if ($event->isCancelled()) {
break;
}
}
return $event;
}