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

  • NDIContainer
  • NDIContainerBuilder
  • NDIHelpers
  • NDIServiceDefinition
  • NDIStatement

Interfaces

  • IDIContainer

Exceptions

  • NMissingServiceException
  • NServiceCreationException
  • 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\DI
 11:  */
 12: 
 13: 
 14: 
 15: /**
 16:  * Definition used by ContainerBuilder.
 17:  *
 18:  * @author     David Grudl
 19:  * @package Nette\DI
 20:  */
 21: class NDIServiceDefinition extends NObject
 22: {
 23:     /** @var string  class or interface name */
 24:     public $class;
 25: 
 26:     /** @var NDIStatement */
 27:     public $factory;
 28: 
 29:     /** @var NDIStatement[] */
 30:     public $setup = array();
 31: 
 32:     /** @var array */
 33:     public $parameters = array();
 34: 
 35:     /** @var array */
 36:     public $tags = array();
 37: 
 38:     /** @var mixed */
 39:     public $autowired = TRUE;
 40: 
 41:     /** @var bool */
 42:     public $shared = TRUE;
 43: 
 44:     /** @var bool */
 45:     public $internal = FALSE;
 46: 
 47: 
 48: 
 49:     public function setClass($class, array $args = array())
 50:     {
 51:         $this->class = $class;
 52:         if ($args) {
 53:             $this->setFactory($class, $args);
 54:         }
 55:         return $this;
 56:     }
 57: 
 58: 
 59: 
 60:     public function setFactory($factory, array $args = array())
 61:     {
 62:         $this->factory = new NDIStatement($factory, $args);
 63:         return $this;
 64:     }
 65: 
 66: 
 67: 
 68:     public function setArguments(array $args = array())
 69:     {
 70:         if ($this->factory) {
 71:             $this->factory->arguments = $args;
 72:         } else {
 73:             $this->setClass($this->class, $args);
 74:         }
 75:         return $this;
 76:     }
 77: 
 78: 
 79: 
 80:     public function addSetup($target, $args = NULL)
 81:     {
 82:         if (!is_array($args)) {
 83:             $args = func_get_args();
 84:             array_shift($args);
 85:         }
 86:         $this->setup[] = new NDIStatement($target, $args);
 87:         return $this;
 88:     }
 89: 
 90: 
 91: 
 92:     public function setParameters(array $params)
 93:     {
 94:         $this->shared = $this->autowired = FALSE;
 95:         $this->parameters = $params;
 96:         return $this;
 97:     }
 98: 
 99: 
100: 
101:     public function addTag($tag, $attrs = TRUE)
102:     {
103:         $this->tags[$tag] = $attrs;
104:         return $this;
105:     }
106: 
107: 
108: 
109:     public function setAutowired($on)
110:     {
111:         $this->autowired = $on;
112:         return $this;
113:     }
114: 
115: 
116: 
117:     public function setShared($on)
118:     {
119:         $this->shared = (bool) $on;
120:         $this->autowired = $this->shared ? $this->autowired : FALSE;
121:         return $this;
122:     }
123: 
124: 
125: 
126:     public function setInternal($on)
127:     {
128:         $this->internal = (bool) $on;
129:         return $this;
130:     }
131: 
132: }
133: 
Nette Framework 2.0.10 (for PHP 5.2, prefixed) API API documentation generated by ApiGen 2.8.0