本文整理汇总了PHP中Nette\DI\ContainerBuilder::getByType方法的典型用法代码示例。如果您正苦于以下问题:PHP ContainerBuilder::getByType方法的具体用法?PHP ContainerBuilder::getByType怎么用?PHP ContainerBuilder::getByType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\DI\ContainerBuilder
的用法示例。
在下文中一共展示了ContainerBuilder::getByType方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getDefinitionNameByTypeChecked
/**
* @param ContainerBuilder $builder
* @param string $type
* @return string
* @throws ServiceNotFoundException
*/
private static function getDefinitionNameByTypeChecked(ContainerBuilder $builder, $type)
{
$defName = $builder->getByType($type);
if ($defName === null) {
throw new ServiceNotFoundException();
}
return $defName;
}
示例2: setPresenterMapping
/**
* $mapping => ['NAMESPACE' => 'NAMESPACE\\*Module\\Presenters\\*Presenter']
*
* @param ContainerBuilder $builder
* @param array $mapping
*/
public function setPresenterMapping(ContainerBuilder $builder, array $mapping)
{
$builder->getDefinition($builder->getByType(IPresenterFactory::class))->addSetup('setMapping', [$mapping]);
}
示例3: getCache
private function getCache($prefix, ContainerBuilder $builder)
{
if (strlen($builder->getByType('Doctrine\\Common\\Cache\\Cache')) > 0) {
return '@' . $builder->getByType('Doctrine\\Common\\Cache\\Cache');
} else {
$builder->addDefinition($prefix . ".cache")->setClass(self::DOCTRINE_DEFAULT_CACHE);
return '@' . $prefix . ".cache";
}
}
示例4: setupProxyAuthorizator
/**
* @param \Nette\DI\ContainerBuilder $builder
*/
private function setupProxyAuthorizator(ContainerBuilder $builder)
{
if ($default = $builder->getByType('Nette\\Security\\IAuthorizator')) {
$builder->getDefinition($default)->setAutowired(FALSE);
$builder->getDefinition($this->prefix('proxy'))->addSetup('setAuthorizator', ['@' . $default]);
} else {
$builder->removeDefinition($this->prefix('proxy'));
}
}