当前位置: 首页>>代码示例>>PHP>>正文


PHP EventManager::addListener方法代码示例

本文整理汇总了PHP中EventManager::addListener方法的典型用法代码示例。如果您正苦于以下问题:PHP EventManager::addListener方法的具体用法?PHP EventManager::addListener怎么用?PHP EventManager::addListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EventManager的用法示例。


在下文中一共展示了EventManager::addListener方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: itFallbackToCallHookIfGivenCallbackDoesNotExist

 public function itFallbackToCallHookIfGivenCallbackDoesNotExist()
 {
     $event = 'an_event';
     $params = array('some_params');
     $listener = new Event2MockEventListener($this);
     stub($listener)->CallHook($event, $params)->once();
     $em = new EventManager();
     $em->addListener($event, $listener, 'doSomething', false);
     $em->processEvent($event, $params);
 }
开发者ID:pombredanne,项目名称:tuleap,代码行数:10,代码来源:EventManagerTest.php

示例2: EventManager

 function testProcessEvent1()
 {
     //The listeners
     $l1 = new Event1MockEventListener($this);
     $l1->expectOnce('doSomething');
     $l2 = new Event1MockEventListener($this);
     $l2->expectOnce('doSomething');
     $l3 = new Event2MockEventListener($this);
     $l3->expectNever('CallHook');
     //The events
     $e1 = 'event1';
     $e2 = 'event2';
     //The event Manager
     $m = new EventManager();
     //We register the listeners for the type
     $m->addListener($e1, $l1, 'doSomething', false, 0);
     $m->addListener($e1, $l2, 'doSomething', false, 0);
     $m->addListener($e2, $l3, 'CallHook', true, 0);
     //We process event
     $params = array();
     $m->processEvent($e1, $params);
 }
开发者ID:nterray,项目名称:tuleap,代码行数:22,代码来源:EventManagerTest.php

示例3: itRaisesAnExceptionIfPluginForbidLogin

 public function itRaisesAnExceptionIfPluginForbidLogin()
 {
     $this->expectException('User_InvalidPasswordWithUserException');
     $user = aUser()->withPassword('password')->withStatus(PFUser::STATUS_ACTIVE)->build();
     stub($this->user_manager)->getUserByUserName()->returns($user);
     $this->event_manager->addListener(Event::SESSION_AFTER_LOGIN, $this, 'refuseLogin', false);
     $this->login_manager->authenticate('john', 'password');
 }
开发者ID:pombredanne,项目名称:tuleap,代码行数:8,代码来源:LoginManagerTest.php

示例4: setUp

 public function setUp()
 {
     parent::setUp();
     $event_manager = new EventManager();
     $event_manager->addListener(Event::GET_LDAP_LOGIN_NAME_FOR_USER, $this, 'hookReturnsLdapUser', false, 0);
     EventManager::setInstance($event_manager);
     $this->ldap_login = 'bla blo';
     $this->ldap_result = stub('LDAPResult')->getLogin()->returns($this->ldap_login);
 }
开发者ID:rinodung,项目名称:tuleap,代码行数:9,代码来源:UserAccountManagerTest.php

示例5: addListener

 private function addListener($hook, PluginProxy $proxy)
 {
     $proxy->addListener($hook['event'], $hook['callback'], $hook['recall_event']);
     $this->event_manager->addListener($hook['event'], $proxy, 'processEvent', true);
 }
开发者ID:ranjanasim,项目名称:tuleap,代码行数:5,代码来源:PluginManager.class.php

示例6: itPassUserByReference

    public function itPassUserByReference() {
        $user_row = array('user_id' => 90);

        $event_manager = new EventManager();
        $event_manager->addListener(Event::USER_MANAGER_GET_USER_INSTANCE, $this, 'mockedMethodForEventTest', false, 0);
        EventManager::setInstance($event_manager);
        $result_expected = 'thatValue';

        $result = $this->user_manager->getUserInstanceFromRow($user_row);
        $this->assertEqual($result, $result_expected);
    }
开发者ID:rinodung,项目名称:tuleap,代码行数:11,代码来源:UserManagerTest.php

示例7: attach

 /**
  * Attach handler with EventManager.
  *
  * @return void
  */
 public function attach()
 {
     foreach ($this->eventNames as $callable) {
         $this->dispatcher->addListener($callable['name'], array($this, $callable['method']), $callable['weight']);
     }
 }
开发者ID:rtznprmpftl,项目名称:Zikulacore,代码行数:11,代码来源:AbstractEventHandler.php

示例8: addListener

 /**
  * add an event listener to the event driven application
  * @access public
  * @param string methodName callback method, must be a method of the
  *   current event-driven instance
  * @param string eventType event type
  * @return string eventlistener ID
  */
 public function addListener($eventType, $methodName)
 {
     $listener = new EventListener(array(&$this, $methodName));
     return EventManager::addListener($eventType, $listener);
 }
开发者ID:rhertzog,项目名称:lcs,代码行数:13,代码来源:event.lib.php


注:本文中的EventManager::addListener方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。