/usr/share/php/Nette/DI/CompilerExtension.php is in php-nette 2.1.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | <?php
/**
* This file is part of the Nette Framework (http://nette.org)
* Copyright (c) 2004 David Grudl (http://davidgrudl.com)
*/
namespace Nette\DI;
use Nette;
/**
* Configurator compiling extension.
*
* @author David Grudl
* @property-read array $config
* @property-read ContainerBuilder $containerBuilder
*/
abstract class CompilerExtension extends Nette\Object
{
/** @var Compiler */
protected $compiler;
/** @var string */
protected $name;
public function setCompiler(Compiler $compiler, $name)
{
$this->compiler = $compiler;
$this->name = $name;
return $this;
}
/**
* Returns extension configuration.
* @param array default unexpanded values.
* @return array
*/
public function getConfig(array $defaults = NULL)
{
$config = $this->compiler->getConfig();
$config = isset($config[$this->name]) ? $config[$this->name] : array();
unset($config['services'], $config['factories']);
return Config\Helpers::merge($config, $this->compiler->getContainerBuilder()->expand($defaults));
}
/**
* @return ContainerBuilder
*/
public function getContainerBuilder()
{
return $this->compiler->getContainerBuilder();
}
/**
* Reads configuration from file.
* @param string file name
* @return array
*/
public function loadFromFile($file)
{
$loader = new Config\Loader;
$res = $loader->load($file);
$container = $this->compiler->getContainerBuilder();
foreach ($loader->getDependencies() as $file) {
$container->addDependency($file);
}
return $res;
}
/**
* Prepend extension name to identifier or service name.
* @param string
* @return string
*/
public function prefix($id)
{
return substr_replace($id, $this->name . '.', substr($id, 0, 1) === '@' ? 1 : 0, 0);
}
/**
* Processes configuration data. Intended to be overridden by descendant.
* @return void
*/
public function loadConfiguration()
{
}
/**
* Adjusts DI container before is compiled to PHP class. Intended to be overridden by descendant.
* @return void
*/
public function beforeCompile()
{
}
/**
* Adjusts DI container compiled to PHP class. Intended to be overridden by descendant.
* @return void
*/
public function afterCompile(Nette\PhpGenerator\ClassType $class)
{
}
}
|