本文整理匯總了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'));
}
}