本文整理匯總了PHP中Phalcon\Mvc\Application::getDI方法的典型用法代碼示例。如果您正苦於以下問題:PHP Application::getDI方法的具體用法?PHP Application::getDI怎麽用?PHP Application::getDI使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Phalcon\Mvc\Application
的用法示例。
在下文中一共展示了Application::getDI方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: boot
/**
* @param Application $app
*/
public function boot(Application $app)
{
$options = $this->options;
$app->getDI()->setShared('aws', function () use($options) {
$aws = Aws::factory($options);
$aws->getEventDispatcher()->addListener('service_builder.create_client', function (Event $event) {
$clientConfig = $event['client']->getConfig();
$commandParams = $clientConfig->get(Client::COMMAND_PARAMS) ?: array();
$clientConfig->set(Client::COMMAND_PARAMS, array_merge_recursive($commandParams, array(UserAgentListener::OPTION => 'Phalcon/' . Application::VERSION)));
});
return $aws;
});
}
示例2: customServices
/**
* 自定義服務注入
*
*/
protected function customServices()
{
$di = $this->application->getDI();
// 自定義服務
$this->application->setDI($di);
}
示例3: beforeStartModule
public function beforeStartModule(Event $event, PhalconApp $app, $moduleName)
{
$di = $app->getDI();
$config = $di->get('config');
$this->setViewService($di, $config, $moduleName)->setUrlService($di, $config, $moduleName);
}
示例4: applicationSetup
/**
* Setup the phalcon application.
*
* @param null $uri
* @return string
*/
protected function applicationSetup($uri = null)
{
$app = new Application($this->di);
$app->useImplicitView('null' === $this->config['view']['default'] ? false : true);
// set event manager for application
$eventManager = $app->getDI()->getShared('eventsManager');
$this->setEventsManager($eventManager);
$this->registerEvents();
/*
* TODO This is bug on phalcon 2.0.4
*/
$app->setEventsManager($this->getEventsManager());
return $app->handle($uri)->getContent();
}
示例5: Application
$debug->listen();
/**
* Include services
*/
require __DIR__ . '/../config/services.php';
/**
* Include loaders
*/
require __DIR__ . '/../config/loader.php';
/**
* Handle the request
*/
$application = new Application();
$eventsManager = new Phalcon\Events\Manager();
$application->setEventsManager($eventsManager);
$eventsManager->attach('application:viewRender', function ($event, $application) {
$dispatcher = $application->getDI()->getDispatcher();
$controllerName = strtolower($dispatcher->getControllerName());
if (substr($controllerName, 0, 1) == '\\') {
$dispatcher->setControllerName(substr($controllerName, 1));
}
});
/**
* Assign the DI
*/
$application->setDI($di);
/**
* Include modules
*/
require __DIR__ . '/../config/modules.php';
echo $application->handle()->getContent();