Namespaces

  • 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

  • Container
  • ContainerBuilder
  • Helpers
  • ServiceDefinition
  • Statement

Interfaces

  • IContainer

Exceptions

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