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