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

Classes

Interfaces

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