Namespaces

  • Latte
    • Loaders
    • Macros
    • Runtime
  • Nette
    • Application
      • Responses
      • Routers
      • UI
    • Bridges
      • ApplicationDI
      • ApplicationLatte
      • ApplicationTracy
      • CacheDI
      • CacheLatte
      • DatabaseDI
      • DatabaseTracy
      • DITracy
      • FormsDI
      • FormsLatte
      • Framework
      • HttpDI
      • HttpTracy
      • MailDI
      • ReflectionDI
      • SecurityDI
      • SecurityTracy
    • Caching
      • Storages
    • ComponentModel
    • Database
      • Conventions
      • Drivers
      • Reflection
      • Table
    • DI
      • Config
        • Adapters
      • Extensions
    • Forms
      • Controls
      • Rendering
    • Http
    • Iterators
    • Loaders
    • Localization
    • Mail
    • Neon
    • PhpGenerator
    • Reflection
    • Security
    • Utils
  • none
  • Tracy
    • Bridges
      • Nette

Classes

  • ConstantsExtension
  • DecoratorExtension
  • DIExtension
  • ExtensionsExtension
  • InjectExtension
  • PhpExtension
  • Overview
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Other releases
  • Nette homepage
 1: <?php
 2: 
 3: /**
 4:  * This file is part of the Nette Framework (https://nette.org)
 5:  * Copyright (c) 2004 David Grudl (https://davidgrudl.com)
 6:  */
 7: 
 8: namespace Nette\DI\Extensions;
 9: 
10: use Nette;
11: 
12: 
13: /**
14:  * PHP directives definition.
15:  */
16: class PhpExtension extends Nette\DI\CompilerExtension
17: {
18: 
19:     public function afterCompile(Nette\PhpGenerator\ClassType $class)
20:     {
21:         $initialize = $class->getMethod('initialize');
22:         foreach ($this->getConfig() as $name => $value) {
23:             if ($value === NULL) {
24:                 continue;
25: 
26:             } elseif (!is_scalar($value)) {
27:                 throw new Nette\InvalidStateException("Configuration value for directive '$name' is not scalar.");
28: 
29:             } elseif ($name === 'include_path') {
30:                 $initialize->addBody('set_include_path(?);', array(str_replace(';', PATH_SEPARATOR, $value)));
31: 
32:             } elseif ($name === 'ignore_user_abort') {
33:                 $initialize->addBody('ignore_user_abort(?);', array($value));
34: 
35:             } elseif ($name === 'max_execution_time') {
36:                 $initialize->addBody('set_time_limit(?);', array($value));
37: 
38:             } elseif ($name === 'date.timezone') {
39:                 $initialize->addBody('date_default_timezone_set(?);', array($value));
40: 
41:             } elseif (function_exists('ini_set')) {
42:                 $initialize->addBody('ini_set(?, ?);', array($name, $value));
43: 
44:             } elseif (ini_get($name) != $value) { // intentionally ==
45:                 throw new Nette\NotSupportedException('Required function ini_set() is disabled.');
46:             }
47:         }
48:     }
49: 
50: }
51: 
Nette 2.3-20161221 API API documentation generated by ApiGen 2.8.0