本文整理汇总了PHP中Nette\DI\Compiler::parseServices方法的典型用法代码示例。如果您正苦于以下问题:PHP Compiler::parseServices方法的具体用法?PHP Compiler::parseServices怎么用?PHP Compiler::parseServices使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\DI\Compiler
的用法示例。
在下文中一共展示了Compiler::parseServices方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: load
public function load(Nette\DI\Compiler $compiler, Nette\DI\ContainerBuilder $containerBuilder)
{
$aspects = [];
foreach ($this->aspectsList as $def) {
if (!is_array($def)) {
if (!is_string($def) && (!$def instanceof \stdClass || empty($def->value)) && !$def instanceof Nette\DI\Statement) {
$serialised = Nette\Utils\Json::encode($def);
throw new Kdyby\Aop\UnexpectedValueException("The service definition {$serialised} is expected to be an array or Neon entity.");
}
$def = ['factory' => $def];
}
$def['tags'][] = AspectsExtension::ASPECT_TAG;
$aspects[] = $def;
}
$compiler->parseServices($containerBuilder, ['services' => $aspects], $this->prefix ? substr($this->extension->prefix('self'), 0, -5) : NULL);
}
示例2: loadConfiguration
public function loadConfiguration()
{
$builder = $this->getContainerBuilder();
$config = $this->validateConfig($this->defaults);
// Add themes
$params = [];
$neon = new NeonAdapter();
foreach (Finder::findFiles('theme.neon')->limitDepth(2)->from($config['themes']) as $file => $splfile) {
// Parse config
$expandConfig = ['themeDir' => dirname($splfile->getRealPath())];
$themeConfig = Helpers::expand($neon->load($file), $expandConfig, TRUE);
// Validate theme configs
$this->validateConfig($this->themeDefaults, $themeConfig, 'themes');
$this->validateConfig($this->themeDefaults['theme'], $themeConfig['theme'], 'theme');
// Parse theme name
$themeName = strtolower($themeConfig['theme']['name']);
// Check duplicity
if (array_key_exists($themeName, $params)) {
throw new InvalidStateException('Theme "' . $themeName . '" is already defined.');
}
// Add to array
$params[$themeName] = $themeConfig;
}
// Check if selected template is not null
Validators::assertField($params, $config['theme'], NULL, 'template "%s"');
$theme = $params[$config['theme']];
// Add parameters to global parameters
$builder->parameters['themes'] = [];
$builder->parameters['themes']['theme'] = $theme['theme'];
$builder->parameters['themes']['vars'] = $config['template'];
$builder->parameters['themes']['output'] = $config['output'];
// Add template model to container
Compiler::parseServices($builder, ['services' => $theme['model']], $this->prefix('model'));
// Add command manager (fake presenter)
$builder->addDefinition($this->prefix('ui.manager'))->setClass('Generator\\UI\\CommandManager');
// Add template factory
$builder->addDefinition($this->prefix('latte.templateFactory'))->setClass('Generator\\Latte\\TemplateFactory')->setAutowired();
// Add commands
$builder->addDefinition($this->prefix('commands.info'))->setClass('Generator\\Commands\\InfoCommand')->setInject();
$builder->addDefinition($this->prefix('commands.generate'))->setClass('Generator\\Commands\\GenerateCommand', [$builder->parameters['themes']])->setInject();
$builder->addDefinition($this->prefix('commands.deploy'))->setClass('Generator\\Commands\\DeployCommand')->setInject();
$builder->addDefinition($this->prefix('commands.error'))->setClass('Generator\\Commands\\ErrorCommand')->setInject();
}