本文整理匯總了PHP中Phalcon\Di::getService方法的典型用法代碼示例。如果您正苦於以下問題:PHP Di::getService方法的具體用法?PHP Di::getService怎麽用?PHP Di::getService使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Phalcon\Di
的用法示例。
在下文中一共展示了Di::getService方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testResolvingService
/**
* Tests resolving service
*
* @author Serghei Iakovlev <serghei@phalconphp.com>
* @since 2016-01-29
*/
public function testResolvingService()
{
$this->specify("Di does not resolves service correctly", function () {
$di = new Di();
$di->set('resolved', function () {
return new \SomeService();
});
$di->set('notResolved', function () {
return new \SomeService();
});
expect($di->getService('resolved')->isResolved())->false();
expect($di->getService('notResolved')->isResolved())->false();
$di->get('resolved');
expect($di->getService('resolved')->isResolved())->true();
expect($di->getService('notResolved')->isResolved())->false();
});
}
示例2: initEventsManager
protected function initEventsManager(Di $di)
{
if (!$di->has('eventsManager') || $di->getService('eventsManager')->getDefinition() == 'Phalcon\\Events\\Manager') {
$di->setShared('eventsManager', $this->getEventsManager());
}
$this->setEventsManager($di->get('eventsManager'));
}
示例3: getService
public function getService($name)
{
return parent::getService($name);
}