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

Classes

  • Container
  • ContainerBuilder
  • ServiceDefinition
  • Statement

Interfaces

  • IContainer

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: 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 $internal = FALSE;
 43: 
 44: 
 45:     public function setClass($class, array $args = array())
 46:     {
 47:         $this->class = $class;
 48:         if ($args) {
 49:             $this->setFactory($class, $args);
 50:         }
 51:         return $this;
 52:     }
 53: 
 54: 
 55:     public function setFactory($factory, array $args = array())
 56:     {
 57:         $this->factory = new Statement($factory, $args);
 58:         return $this;
 59:     }
 60: 
 61: 
 62:     public function setArguments(array $args = array())
 63:     {
 64:         if ($this->factory) {
 65:             $this->factory->arguments = $args;
 66:         } else {
 67:             $this->setClass($this->class, $args);
 68:         }
 69:         return $this;
 70:     }
 71: 
 72: 
 73:     public function addSetup($target, $args = NULL)
 74:     {
 75:         $this->setup[] = new Statement($target, is_array($args) ? $args : array_slice(func_get_args(), 1));
 76:         return $this;
 77:     }
 78: 
 79: 
 80:     public function setParameters(array $params)
 81:     {
 82:         $this->shared = $this->autowired = FALSE;
 83:         $this->parameters = $params;
 84:         return $this;
 85:     }
 86: 
 87: 
 88:     public function addTag($tag, $attrs = TRUE)
 89:     {
 90:         $this->tags[$tag] = $attrs;
 91:         return $this;
 92:     }
 93: 
 94: 
 95:     public function setAutowired($on)
 96:     {
 97:         $this->autowired = $on;
 98:         return $this;
 99:     }
100: 
101: 
102:     public function setShared($on)
103:     {
104:         $this->shared = (bool) $on;
105:         $this->autowired = $this->shared ? $this->autowired : FALSE;
106:         return $this;
107:     }
108: 
109: 
110:     public function setInternal($on)
111:     {
112:         $this->internal = (bool) $on;
113:         return $this;
114:     }
115: 
116: }
117: 
Nette 2.0 API documentation generated by ApiGen 2.8.0