本文整理汇总了PHP中Nette\DI\Compiler::addConfig方法的典型用法代码示例。如果您正苦于以下问题:PHP Compiler::addConfig方法的具体用法?PHP Compiler::addConfig怎么用?PHP Compiler::addConfig使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\DI\Compiler
的用法示例。
在下文中一共展示了Compiler::addConfig方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _before
protected function _before()
{
$this->compiler = new \Nette\DI\Compiler();
$this->compiler->addConfig(['parameters' => ['debugMode' => TRUE]]);
$this->compiler->addExtension('params', new \WebChemistry\Parameters\DI\ParametersExtension());
$this->compiler->addExtension('http', new \Nette\Bridges\HttpDI\HttpExtension());
$this->compiler->addExtension('mock', new MockExtension());
}
示例2: testOptions
public function testOptions()
{
$this->compiler->setClassName('Container_Controls');
$this->compiler->addConfig(['controls' => ['date' => ['format' => 'foo'], 'translations' => ['enable' => TRUE, 'date' => 'bar']]]);
$this->compile();
eval($this->compile());
$container = new Container_Controls();
$count = count(\Nette\Forms\Validator::$messages);
$container->initialize();
$this->assertNotSame($count, count(\Nette\Forms\Validator::$messages));
$this->assertSame('bar', \Nette\Forms\Validator::$messages[\WebChemistry\Forms\Controls\Date::VALID]);
$this->assertSame('foo', \WebChemistry\Forms\Controls\Date::$dateFormat);
}
示例3: testCustomName
public function testCustomName()
{
$this->compiler->addConfig(['multiplier' => ['name' => 'addCustom']]);
$code = $this->fixCompile($this->compiler);
$this->assertContains('WebChemistry\\Forms\\Controls\\Multiplier::register(\'addCustom\');', $code);
}
示例4: generateContainer
/**
* @return string
* @internal
*/
public function generateContainer(DI\Compiler $compiler)
{
$loader = $this->createLoader();
$compiler->addConfig(['parameters' => $this->parameters]);
$fileInfo = [];
foreach ($this->files as $info) {
if (is_scalar($info[0])) {
$fileInfo[] = "// source: {$info['0']} {$info['1']}";
$info[0] = $loader->load($info[0], $info[1]);
}
$compiler->addConfig($this->fixCompatibility($info[0]));
}
$compiler->addDependencies($loader->getDependencies());
$builder = $compiler->getContainerBuilder();
$builder->addExcludedClasses($this->autowireExcludedClasses);
foreach ($this->defaultExtensions as $name => $extension) {
list($class, $args) = is_string($extension) ? [$extension, []] : $extension;
if (class_exists($class)) {
$args = DI\Helpers::expand($args, $this->parameters, TRUE);
$compiler->addExtension($name, (new \ReflectionClass($class))->newInstanceArgs($args));
}
}
$this->onCompile($this, $compiler);
$classes = $compiler->compile();
if (!empty($builder->parameters['container']['parent'])) {
$classes[0]->setExtends($builder->parameters['container']['parent']);
}
return implode("\n", $fileInfo) . "\n\n" . implode("\n\n\n", $classes) . (($tmp = $builder->parameters['container']['class']) ? "\nclass {$tmp} extends {$builder->getClassName()} {}\n" : '');
}
示例5: generateContainer
/**
* @param Compiler $compiler
* @return string
*/
public function generateContainer(Compiler $compiler)
{
// Load configs
$loader = new Loader();
$compiler->addConfig(['parameters' => $this->parameters]);
foreach ($this->configs as $config) {
$compiler->addConfig($loader->load($config));
}
$compiler->addDependencies($loader->getDependencies());
// Exclude classes
$builder = $compiler->getContainerBuilder();
$builder->addExcludedClasses($this->excludedClasses);
// Fire events
foreach ($this->onCompile as $cb) {
call_user_func_array($cb, [$compiler]);
}
// Compile container
$classes = $compiler->compile();
$classes[0]->setExtends(PiDiContainer::class);
return implode("\n", []) . "\n\n" . implode("\n\n\n", $classes);
}