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

  • DIContainer
  • DIContainerBuilder
  • DIHelpers
  • DIServiceDefinition
  • DIStatement

Interfaces

  • IDIContainer

Exceptions

  • MissingServiceException
  • ServiceCreationException
  • Overview
  • Package
  • 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:  * @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 DIServiceDefinition extends Object
 22: {
 23:     /** @var string  class or interface name */
 24:     public $class;
 25: 
 26:     /** @var DIStatement */
 27:     public $factory;
 28: 
 29:     /** @var array of DIStatement */
 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 DIStatement($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:         $this->setup[] = new DIStatement($target, $args);
 83:         return $this;
 84:     }
 85: 
 86: 
 87: 
 88:     public function setParameters(array $params)
 89:     {
 90:         $this->shared = $this->autowired = FALSE;
 91:         $this->parameters = $params;
 92:         return $this;
 93:     }
 94: 
 95: 
 96: 
 97:     public function addTag($tag, $attrs = TRUE)
 98:     {
 99:         $this->tags[$tag] = $attrs;
100:         return $this;
101:     }
102: 
103: 
104: 
105:     public function setAutowired($on)
106:     {
107:         $this->autowired = $on;
108:         return $this;
109:     }
110: 
111: 
112: 
113:     public function setShared($on)
114:     {
115:         $this->shared = (bool) $on;
116:         $this->autowired = $this->shared ? $this->autowired : FALSE;
117:         return $this;
118:     }
119: 
120: 
121: 
122:     public function setInternal($on)
123:     {
124:         $this->internal = (bool) $on;
125:         return $this;
126:     }
127: 
128: }
129: 
Nette Framework 2.0.0 (for PHP 5.2, un-prefixed) API API documentation generated by ApiGen 2.7.0