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