1: <?php
2:
3: 4: 5: 6: 7: 8: 9: 10:
11:
12: namespace Nette\Config\Extensions;
13:
14: use Nette,
15: Nette\DI\ContainerBuilder;
16:
17:
18:
19: 20: 21: 22: 23:
24: class PhpExtension extends Nette\Config\CompilerExtension
25: {
26:
27: public function afterCompile(Nette\Utils\PhpGenerator\ClassType $class)
28: {
29: $initialize = $class->methods['initialize'];
30: foreach ($this->getConfig() as $name => $value) {
31: if (!is_scalar($value)) {
32: throw new Nette\InvalidStateException("Configuration value for directive '$name' is not scalar.");
33:
34: } elseif ($name === 'include_path') {
35: $initialize->addBody('set_include_path(?);', array(str_replace(';', PATH_SEPARATOR, $value)));
36:
37: } elseif ($name === 'ignore_user_abort') {
38: $initialize->addBody('ignore_user_abort(?);', array($value));
39:
40: } elseif ($name === 'max_execution_time') {
41: $initialize->addBody('set_time_limit(?);', array($value));
42:
43: } elseif ($name === 'date.timezone') {
44: $initialize->addBody('date_default_timezone_set(?);', array($value));
45:
46: } elseif (function_exists('ini_set')) {
47: $initialize->addBody('ini_set(?, ?);', array($name, $value));
48:
49: } elseif (ini_get($name) != $value) {
50: throw new Nette\NotSupportedException('Required function ini_set() is disabled.');
51: }
52: }
53: }
54:
55: }
56: