本文整理汇总了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);
}
示例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);
}
示例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');
}
示例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);
}
示例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);
}
示例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);
}
示例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']);
}
}
示例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);
}