本文整理匯總了PHP中Nette\DI\Compiler::addExtension方法的典型用法代碼示例。如果您正苦於以下問題:PHP Compiler::addExtension方法的具體用法?PHP Compiler::addExtension怎麽用?PHP Compiler::addExtension使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Nette\DI\Compiler
的用法示例。
在下文中一共展示了Compiler::addExtension方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: registerAdditionalExtension
/**
* Register extension if not registered by user.
*/
private static function registerAdditionalExtension(\Nette\DI\Compiler $compiler, $name, $newExtension)
{
$extensions = [];
foreach (isset($compiler->config['extensions']) ? $compiler->config['extensions'] : [] as $extension) {
if (is_string($extension)) {
$extensions[] = $extension;
} elseif ($extension instanceof \Nette\DI\Statement) {
$extensions[] = $extension->getEntity();
}
}
if ($extensions && !in_array(get_class($newExtension), $extensions)) {
$compiler->addExtension($name, $newExtension);
}
}
示例3: createCompiler
/**
* @return Compiler
*/
protected function createCompiler()
{
$compiler = new DI\Compiler();
foreach ($this->defaultExtensions as $name => $class) {
$compiler->addExtension($name, new $class());
}
return $compiler;
}
示例4: _before
protected function _before()
{
$this->compiler = new \Nette\DI\Compiler();
$this->compiler->addExtension('multiplier', new \WebChemistry\Forms\Controls\DI\MultiplierExtension());
}
示例5: createCompiler
/**
* @return Compiler
*/
protected function createCompiler()
{
$compiler = new DI\Compiler();
$compiler->addExtension('php', new DI\Extensions\PhpExtension())->addExtension('constants', new DI\Extensions\ConstantsExtension())->addExtension('nette', new DI\Extensions\NetteExtension())->addExtension('extensions', new DI\Extensions\ExtensionsExtension());
return $compiler;
}
示例6: 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" : '');
}