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