Packages

  • Nette
    • Application
      • Diagnostics
      • Responses
      • Routers
      • UI
    • Caching
      • Storages
    • ComponentModel
    • Config
      • Adapters
      • Extensions
    • Database
      • Diagnostics
      • Drivers
      • Reflection
      • Table
    • DI
      • Diagnostics
    • Diagnostics
    • Forms
      • Controls
      • Rendering
    • Http
    • Iterators
    • Latte
      • Macros
    • Loaders
    • Localization
    • Mail
    • Reflection
    • Security
      • Diagnostics
    • Templating
    • Utils
      • PhpGenerator
  • NetteModule
  • None
  • PHP

Classes

  • NConfigCompiler
  • NConfigCompilerExtension
  • NConfigHelpers
  • NConfigLoader
  • NConfigurator

Interfaces

  • IConfigAdapter
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  1: <?php
  2: 
  3: /**
  4:  * This file is part of the Nette Framework (http://nette.org)
  5:  *
  6:  * Copyright (c) 2004 David Grudl (http://davidgrudl.com)
  7:  *
  8:  * For the full copyright and license information, please view
  9:  * the file license.txt that was distributed with this source code.
 10:  * @package Nette\Config
 11:  */
 12: 
 13: 
 14: 
 15: /**
 16:  * Configurator compiling extension.
 17:  *
 18:  * @author     David Grudl
 19:  * @property-read array $config
 20:  * @property-read NDIContainerBuilder $containerBuilder
 21:  * @package Nette\Config
 22:  */
 23: abstract class NConfigCompilerExtension extends NObject
 24: {
 25:     /** @var NConfigCompiler */
 26:     protected $compiler;
 27: 
 28:     /** @var string */
 29:     protected $name;
 30: 
 31: 
 32:     public function setCompiler(NConfigCompiler $compiler, $name)
 33:     {
 34:         $this->compiler = $compiler;
 35:         $this->name = $name;
 36:         return $this;
 37:     }
 38: 
 39: 
 40:     /**
 41:      * Returns extension configuration.
 42:      * @param  array default values.
 43:      * @param  bool  perform %parameters% expansion?
 44:      * @return array
 45:      */
 46:     public function getConfig(array $defaults = NULL, $expand = TRUE)
 47:     {
 48:         $config = $this->compiler->getConfig();
 49:         $config = isset($config[$this->name]) ? $config[$this->name] : array();
 50:         unset($config['services'], $config['factories']);
 51:         $config = NConfigHelpers::merge($config, $defaults);
 52:         return $expand ? $this->compiler->getContainerBuilder()->expand($config) : $config;
 53:     }
 54: 
 55: 
 56:     /**
 57:      * @return NDIContainerBuilder
 58:      */
 59:     public function getContainerBuilder()
 60:     {
 61:         return $this->compiler->getContainerBuilder();
 62:     }
 63: 
 64: 
 65:     /**
 66:      * Reads configuration from file.
 67:      * @param  string  file name
 68:      * @return array
 69:      */
 70:     public function loadFromFile($file)
 71:     {
 72:         $loader = new NConfigLoader;
 73:         $res = $loader->load($file);
 74:         $container = $this->compiler->getContainerBuilder();
 75:         foreach ($loader->getDependencies() as $file) {
 76:             $container->addDependency($file);
 77:         }
 78:         return $res;
 79:     }
 80: 
 81: 
 82:     /**
 83:      * Prepend extension name to identifier or service name.
 84:      * @param  string
 85:      * @return string
 86:      */
 87:     public function prefix($id)
 88:     {
 89:         return substr_replace($id, $this->name . '.', substr($id, 0, 1) === '@' ? 1 : 0, 0);
 90:     }
 91: 
 92: 
 93:     /**
 94:      * Processes configuration data. Intended to be overridden by descendant.
 95:      * @return void
 96:      */
 97:     public function loadConfiguration()
 98:     {
 99:     }
100: 
101: 
102:     /**
103:      * Adjusts DI container before is compiled to PHP class. Intended to be overridden by descendant.
104:      * @return void
105:      */
106:     public function beforeCompile()
107:     {
108:     }
109: 
110: 
111:     /**
112:      * Adjusts DI container compiled to PHP class. Intended to be overridden by descendant.
113:      * @return void
114:      */
115:     public function afterCompile(NPhpClassType $class)
116:     {
117:     }
118: 
119: }
120: 
Nette Framework 2.0.12 (for PHP 5.2, prefixed) API API documentation generated by ApiGen 2.8.0