Namespaces

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

Classes

  • Compiler
  • CompilerExtension
  • Container
  • ContainerBuilder
  • ContainerFactory
  • Helpers
  • ServiceDefinition
  • Statement

Exceptions

  • MissingServiceException
  • ServiceCreationException
  • 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 (http://davidgrudl.com)
  6:  */
  7: 
  8: namespace Nette\DI;
  9: 
 10: use Nette;
 11: 
 12: 
 13: /**
 14:  * Definition used by ContainerBuilder.
 15:  *
 16:  * @author     David Grudl
 17:  *
 18:  * @method string getClass()
 19:  * @method Statement getFactory()
 20:  * @method ServiceDefinition setSetup(Statement[])
 21:  * @method Statement[] getSetup()
 22:  * @method ServiceDefinition setParameters(array)
 23:  * @method array getParameters()
 24:  * @method ServiceDefinition setTags(array)
 25:  * @method array getTags()
 26:  * @method ServiceDefinition setAutowired(bool)
 27:  * @method bool isAutowired()
 28:  * @method ServiceDefinition setInject(bool)
 29:  * @method bool getInject()
 30:  * @method ServiceDefinition setImplement(string)
 31:  * @method string getImplement()
 32:  * @method ServiceDefinition setImplementType(string)
 33:  * @method string getImplementType()
 34:  */
 35: class ServiceDefinition extends Nette\Object
 36: {
 37:     /** @var string|NULL  class or interface name */
 38:     private $class;
 39: 
 40:     /** @var Statement|NULL */
 41:     private $factory;
 42: 
 43:     /** @var Statement[] */
 44:     private $setup = array();
 45: 
 46:     /** @var array */
 47:     public $parameters = array();
 48: 
 49:     /** @var array */
 50:     private $tags = array();
 51: 
 52:     /** @var bool */
 53:     private $autowired = TRUE;
 54: 
 55:     /** @var bool */
 56:     public $inject = FALSE;
 57: 
 58:     /** @var string|NULL  interface name */
 59:     private $implement;
 60: 
 61:     /** @var string|NULL  create | get */
 62:     private $implementType;
 63: 
 64: 
 65:     public function setClass($class, array $args = array())
 66:     {
 67:         $this->class = $class;
 68:         if ($args) {
 69:             $this->setFactory($class, $args);
 70:         }
 71:         return $this;
 72:     }
 73: 
 74: 
 75:     public function setFactory($factory, array $args = array())
 76:     {
 77:         $this->factory = $factory instanceof Statement ? $factory : new Statement($factory, $args);
 78:         return $this;
 79:     }
 80: 
 81: 
 82:     public function setArguments(array $args = array())
 83:     {
 84:         if ($this->factory) {
 85:             $this->factory->arguments = $args;
 86:         } else {
 87:             $this->setClass($this->class, $args);
 88:         }
 89:         return $this;
 90:     }
 91: 
 92: 
 93:     public function addSetup($target, array $args = array())
 94:     {
 95:         $this->setup[] = new Statement($target, $args);
 96:         return $this;
 97:     }
 98: 
 99: 
100:     public function addTag($tag, $attrs = TRUE)
101:     {
102:         $this->tags[$tag] = $attrs;
103:         return $this;
104:     }
105: 
106: 
107:     public function getTag($tag)
108:     {
109:         return isset($this->tags[$tag]) ? $this->tags[$tag] : NULL;
110:     }
111: 
112: 
113:     /** @deprecated */
114:     public function setShared($on)
115:     {
116:         trigger_error(__METHOD__ . '() is deprecated.', E_USER_DEPRECATED);
117:         $this->autowired = $on ? $this->autowired : FALSE;
118:         return $this;
119:     }
120: 
121: 
122:     /** @deprecated */
123:     public function isShared()
124:     {
125:         trigger_error(__METHOD__ . '() is deprecated.', E_USER_DEPRECATED);
126:     }
127: 
128: }
129: 
Nette 2.2 API documentation generated by ApiGen 2.8.0