本文整理汇总了PHP中Phalcon\DI\FactoryDefault::getEventsManager方法的典型用法代码示例。如果您正苦于以下问题:PHP FactoryDefault::getEventsManager方法的具体用法?PHP FactoryDefault::getEventsManager怎么用?PHP FactoryDefault::getEventsManager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Phalcon\DI\FactoryDefault
的用法示例。
在下文中一共展示了FactoryDefault::getEventsManager方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getDI
/**
* Configuration application default DI
*
* @return FactoryDefault| CLI
*/
public function getDI()
{
if ($this->di) {
return $this->di;
}
if ($this->appMode == 'cli') {
$di = new FactoryDefault\CLI();
} else {
$di = new FactoryDefault();
}
//PHP5.3 not support $this in closure
$self = $this;
/**********************************
* DI initialize for MVC core
***********************************/
//$di->set('application', $this);
//call loadmodules will overwrite this
$di->set('moduleManager', function () use($di) {
$moduleManager = new ModuleManager();
$moduleManager->setEventsManager($di->getEventsManager());
return $moduleManager;
}, true);
//System global events manager
$di->set('eventsManager', function () use($di) {
$eventsManager = new EventsManager();
$eventsManager->enablePriorities(true);
// dispatch caching event handler
$eventsManager->attach("dispatch", new DispatchInterceptor(), -1);
$eventsManager->enablePriorities(true);
return $eventsManager;
}, true);
$di->set('config', function () use($self) {
return $self->diConfig();
}, true);
$di->set('router', function () use($self) {
return $self->diRouter();
}, true);
$di->set('dispatcher', function () use($di) {
$dispatcher = new Dispatcher();
$dispatcher->setEventsManager($di->getEventsManager());
return $dispatcher;
}, true);
$di->set('modelsMetadata', function () use($self) {
return $self->diModelsMetadata();
}, true);
$di->set('modelsManager', function () use($di) {
$config = $di->getConfig();
ModelManager::setDefaultPrefix($config->dbAdapter->prefix);
//for solving db master/slave under static find method
$modelsManager = new ModelManager();
return $modelsManager;
});
$di->set('view', function () use($di) {
$view = new View();
$view->setViewsDir(__DIR__ . '/views/');
$view->setEventsManager($di->getEventsManager());
return $view;
});
$di->set('session', function () use($self) {
return $self->diSession();
});
$di->set('tokenStorage', function () use($self) {
return $self->diTokenStorage();
}, true);
/**********************************
* DI initialize for database
***********************************/
$di->set('dbMaster', function () use($self) {
return $self->diDbMaster();
}, true);
$di->set('dbSlave', function () use($self) {
return $self->diDbSlave();
}, true);
$di->set('transactions', function () use($di) {
$transactions = new \Phalcon\Mvc\Model\Transaction\Manager();
$transactions->setDbService('dbMaster');
return $transactions;
}, true);
/**********************************
* DI initialize for cache
***********************************/
$di->set('globalCache', function () use($self) {
return $self->diGlobalCache();
}, true);
$di->set('viewCache', function () use($self) {
return $self->diViewCache();
}, true);
$di->set('modelsCache', function () use($self) {
return $self->diModelsCache();
}, true);
$di->set('apiCache', function () use($self) {
return $self->diApiCache();
}, true);
$di->set('fastCache', function () use($self) {
return $self->diFastCache();
//.........这里部分代码省略.........