本文整理匯總了PHP中Phalcon\Events\Manager::fire方法的典型用法代碼示例。如果您正苦於以下問題:PHP Manager::fire方法的具體用法?PHP Manager::fire怎麽用?PHP Manager::fire使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Phalcon\Events\Manager
的用法示例。
在下文中一共展示了Manager::fire方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: dispatch
public function dispatch(Command $command)
{
//If beforeCommand fails abort
if ($this->_eventsManager->fire('command:beforeCommand', $command) === false) {
return false;
}
//If run the commands fails abort too
if ($command->run($command->getParameters()) === false) {
return false;
}
$this->_eventsManager->fire('command:afterCommand', $command);
}
示例2: testListenDispatchEvents
public function testListenDispatchEvents()
{
$dispatcherMock = $this->getMockBuilder(Dispatcher::class)->disableOriginalConstructor()->getMock();
$listener = $this->getMockBuilder(ListenerDispatch::class)->getMock();
$listener->expects($this->once())->method('beforeDispatchLoop');
$listener->expects($this->once())->method('beforeExecuteRoute');
// $listener->expects($this->once())
// ->method('afterExecuteRoute');
// $listener->expects($this->once())
// ->method('beforeNotFoundAction');
// $listener->expects($this->once())
// ->method('beforeException');
// $listener->expects($this->once())
// ->method('afterDispatchLoop');
$this->listener->listenDispatchEvents($listener);
$this->em->fire('dispatch:beforeDispatchLoop', $dispatcherMock, null);
$this->em->fire('dispatch:beforeExecuteRoute', $dispatcherMock, null);
// $this->em->fire('dispatch:afterExecuteRoute', $dispatcherMock, null);
// $this->em->fire('dispatch:beforeNotFoundAction', $dispatcherMock, null);
// $this->em->fire('dispatch:beforeException', $dispatcherMock, null);
// $this->em->fire('dispatch:afterDispatchLoop', $dispatcherMock, null);
}
示例3: render
/**
* Renders output file using renderer object
*
* @throws InvalidRendererException
* @return string
*/
public function render()
{
if ($this->eventsManager instanceof ManagerInterface) {
$this->eventsManager->fire('generator:beforeRender', $this);
}
if (!$this->renderer instanceof RendererInterface) {
throw new InvalidRendererException();
}
$output = $this->renderer->render();
if ($this->eventsManager instanceof ManagerInterface) {
$this->eventsManager->fire('generator:afterRender', $this);
}
return $output;
}
示例4: fire
public static function fire($eventType, $source, $data = null, $cancelable = true)
{
static::$event or static::$event = static::$di->getShared('eventsManager');
return static::$event->fire($eventType, $source, $data, $cancelable);
}
示例5: EventsManager
<?php
use Phalcon\Events\Manager as EventsManager;
$evManager = new EventsManager();
//Set up the events manager to collect responses
$evManager->collectResponses(true);
//Attach a listener
$evManager->attach('custom:custom', function () {
return 'first response';
});
//Attach a listener
$evManager->attach('custom:custom', function () {
return 'second response';
});
//Fire the event
$evManager->fire('custom:custom', null);
//Get all the collected responses
print_r($evManager->getResponses());