本文整理汇总了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());