本文整理汇总了PHP中Phalcon\Loader::setEventsManager方法的典型用法代码示例。如果您正苦于以下问题:PHP Loader::setEventsManager方法的具体用法?PHP Loader::setEventsManager怎么用?PHP Loader::setEventsManager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Phalcon\Loader
的用法示例。
在下文中一共展示了Loader::setEventsManager方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
*
* @param Di $diFactory
*/
public function __construct(Di $diFactory)
{
$this->diFactory = $diFactory;
$this->loader = new Loader();
$ev = new EventsManager();
$ev->enablePriorities(true);
$ev->collectResponses(true);
$diFactory->set('autoloaderEventsManager', $ev, true);
$this->loader->setEventsManager($ev);
}
示例2: _initLoader
/**
* Init loader.
*
* @param DI $di Dependency Injection.
* @param Config $config Config object.
* @param EventsManager $eventsManager Event manager.
*
* @return Loader
*/
protected function _initLoader($di, $config, $eventsManager)
{
/**
* Add all required namespaces and modules from registry.
* @var [type]
*/
$registry = $di->get('registry');
$namespaces = [];
$bootstraps = [];
foreach ($registry->modules as $module) {
$moduleName = ucfirst($module);
$namespaces[$moduleName] = $registry->directories->modules . $moduleName;
$bootstraps[$module] = $moduleName . '\\Bootstrap';
}
$namespaces['Engine'] = $registry->directories->engine;
$loader = new PhLoader();
$loader->registerNamespaces($namespaces);
// Register some directories
$loader->registerDirs([ROOT_PATH . '/app/libraries']);
$loader->setEventsManager($eventsManager);
$loader->register();
$this->registerModules($bootstraps);
$di->set('loader', $loader);
return $loader;
}
示例3: registerAutoloaders
/**
* Registers an autoloader related to the module
*
* @param DiInterface $di
*/
public function registerAutoloaders(DiInterface $di = null)
{
$eventsManager = new \Phalcon\Events\Manager();
$loader = new Loader();
$loader->registerNamespaces(array('Phlame\\Core\\Controllers' => __DIR__ . '/controllers/', 'Phlame\\Core\\Models' => __DIR__ . '/models/', 'Phlame\\Core\\Components' => __DIR__ . '/components/'));
// Listen all the loader events
$eventsManager->attach('loader', function ($event, $loader) {
if ($event->getType() == 'beforeCheckPath') {
echo 'beforeCheckPath:' . $loader->getCheckedPath() . '<br/>';
}
});
$loader->setEventsManager($eventsManager);
$loader->register();
}
示例4: Manager
<?php
use Phalcon\Events\Manager;
use Phalcon\Loader;
use Phalcon\Mvc\Dispatcher;
$oEventsManager = new Manager();
//$loader = new \Phalcon\Loader();
$di->setShared('loader', function () use($oEventsManager, $di) {
$oLoader = new Loader();
$oConfig = $di->getConfig();
$oLoader->setEventsManager($oEventsManager);
$oLoader->registerNamespaces(array('App\\Modules' => $oConfig->application->modulesDir, 'App\\Hooks' => $oConfig->application->hooksDir, 'App\\Util' => $oConfig->application->utilDir, 'App\\Core\\Interfaces' => $oConfig->application->ifaceDir, 'App\\Modules\\Api' => __DIR__ . '/../../app/modules/api'));
$oLogger = $di->getFileLogger();
// $oLogger->debug('namespaces registered in main loader');
// foreach ($oConfig->modules as $strNamespace => $strDirectory) {
//
// $arNamespace = array(
// 'App\Modules\\' . $strNamespace => $oConfig->application->modulesDir . '/' . $strDirectory
// );
//
// $oLogger->debug('trying to register namespaces: ' . print_r($arNamespace, true));
//
// $oLoader->registerNamespaces($arNamespace);
// }
// $oLogger = $di->getFileLogger();
$oLogger->debug('config already read; common loader initialization; here`s the beginning for "' . $di->getRequest()->getURI() . '"' . str_repeat('_', 170) . PHP_EOL . print_r($oLoader->getNamespaces(), true));
$oLoader->register();
return $oLoader;
});
//$oEventsManager->attach('loader', function($event, $loader, $strClassName) use ($di) {
//
示例5: initLoader
/**
* Initialize the Loader.
*
* Adds all required namespaces.
*
* @param DiInterface $di Dependency Injector
* @param Config $config App config
* @param EventsManager $em Events Manager
*
* @return Loader
*/
protected function initLoader(DiInterface $di, Config $config, EventsManager $em)
{
$loader = new Loader();
$loader->registerNamespaces(['Phosphorum\\Models' => $config->get('application')->modelsDir, 'Phosphorum\\Controllers' => $config->get('application')->controllersDir, 'Phosphorum' => $config->get('application')->libraryDir]);
$loader->setEventsManager($em);
$loader->register();
$di->setShared('loader', $loader);
return $loader;
}
示例6: setEventsManager
public function setEventsManager(ManagerInterface $eventsManager)
{
parent::setEventsManager($eventsManager);
}
示例7: _initLoader
/**
* Init loader.
*
* @param DI $di Dependency Injection.
* @param Config $config Config object.
* @param EventsManager $eventsManager Event manager.
*
* @return Loader
*/
protected function _initLoader($di, $config, $eventsManager)
{
// Add all required namespaces and modules.
$registry = $di->get('registry');
$namespaces = [];
$bootstraps = [];
foreach ($registry->modules as $module) {
$moduleName = ucfirst($module);
$namespaces[$moduleName] = $registry->directories->modules . $moduleName;
$bootstraps[$module] = $moduleName . '\\Bootstrap';
}
$namespaces['Engine'] = $registry->directories->engine;
$namespaces['Plugin'] = $registry->directories->plugins;
$namespaces['Widget'] = $registry->directories->widgets;
$namespaces['Library'] = $registry->directories->libraries;
$loader = new Loader();
$loader->registerNamespaces($namespaces);
if ($config->application->debug && $config->installed) {
$loader->setEventsManager($eventsManager);
}
$loader->register();
$this->registerModules($bootstraps);
$di->set('loader', $loader);
return $loader;
}