Namespaces

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

Classes

  • Compiler
  • CompilerExtension
  • Container
  • ContainerBuilder
  • 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 (https://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: class ServiceDefinition extends Nette\Object
 19: {
 20:     /** @var string  class or interface name */
 21:     public $class;
 22: 
 23:     /** @var Statement */
 24:     public $factory;
 25: 
 26:     /** @var Statement[] */
 27:     public $setup = array();
 28: 
 29:     /** @var array */
 30:     public $parameters = array();
 31: 
 32:     /** @var array */
 33:     public $tags = array();
 34: 
 35:     /** @var mixed */
 36:     public $autowired = TRUE;
 37: 
 38:     /** @var bool */
 39:     public $shared = TRUE;
 40: 
 41:     /** @var bool */
 42:     public $inject = FALSE;
 43: 
 44:     /** @var string  interface name */
 45:     public $implement;
 46: 
 47:     /** @internal @var string  create | get */
 48:     public $implementType;
 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:     public function setFactory($factory, array $args = array())
 62:     {
 63:         $this->factory = new Statement($factory, $args);
 64:         return $this;
 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:     public function addSetup($target, array $args = array())
 80:     {
 81:         $this->setup[] = new Statement($target, $args);
 82:         return $this;
 83:     }
 84: 
 85: 
 86:     public function setParameters(array $params)
 87:     {
 88:         $this->shared = $this->autowired = FALSE;
 89:         $this->parameters = $params;
 90:         return $this;
 91:     }
 92: 
 93: 
 94:     public function addTag($tag, $attrs = TRUE)
 95:     {
 96:         $this->tags[$tag] = $attrs;
 97:         return $this;
 98:     }
 99: 
100: 
101:     public function setAutowired($on)
102:     {
103:         $this->autowired = $on;
104:         return $this;
105:     }
106: 
107: 
108:     /** @deprecated */
109:     public function setShared($on)
110:     {
111:         $this->shared = (bool) $on;
112:         $this->autowired = $this->shared ? $this->autowired : FALSE;
113:         return $this;
114:     }
115: 
116: 
117:     public function setInject($on)
118:     {
119:         $this->inject = (bool) $on;
120:         return $this;
121:     }
122: 
123: 
124:     public function setImplement($implement)
125:     {
126:         $this->implement = $implement;
127:         $this->shared = TRUE;
128:         return $this;
129:     }
130: 
131: }
132: 
Nette 2.1 API documentation generated by ApiGen 2.8.0