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

Classes

Interfaces

Exceptions

  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Other releases
  • Nette homepage

Class DIContainer

The dependency injection container default implementation.

Object
Extended by FreezableObject implements IFreezable
Extended by DIContainer implements IDIContainer
Package: Nette\DI
Author: David Grudl
Located at DI/Container.php
Methods summary
public
# __construct( array $params = array() )
public array
# getParameters( )

Returns

array
public DIContainer
# addService( string $name, mixed $service, array $meta = NULL )

Adds the service or service factory to the container.

Adds the service or service factory to the container.

Parameters

$name
string
$service
mixed
object, class name or callable
$meta
array
service meta information

Returns

DIContainer

Implementation of

IDIContainer::addService()
public
# removeService( string $name )

Removes the service from the container.

Removes the service from the container.

Parameters

$name
string

Implementation of

IDIContainer::removeService()
public object
# getService( string $name )

Gets the service object by name.

Gets the service object by name.

Parameters

$name
string

Returns

object

Implementation of

IDIContainer::getService()
public boolean
# hasService( string $name )

Does the service exist?

Does the service exist?

Parameters

$name
string
service name

Returns

boolean

Implementation of

IDIContainer::hasService()
public boolean
# isCreated( string $name )

Is the service created?

Is the service created?

Parameters

$name
string
service name

Returns

boolean
public object
# getByType( string $class, boolean $need = TRUE )

Resolves service by type.

Resolves service by type.

Parameters

$class
string
class or interface
$need
boolean
throw exception if service doesn't exist?

Returns

object
service or NULL

Throws

MissingServiceException
public array
# findByTag( string $tag )

Gets the service names of the specified tag.

Gets the service names of the specified tag.

Parameters

$tag
string

Returns

array
of [service name => tag attributes]
public object
# createInstance( string $class, array $args = array() )

Creates new instance using autowiring.

Creates new instance using autowiring.

Parameters

$class
string
class
$args
array
arguments

Returns

object

Throws

InvalidArgumentException
public mixed
# callMethod( mixed $function, array $args = array() )

Calls method using autowiring.

Calls method using autowiring.

Parameters

$function
mixed
class, object, function, callable
$args
array
arguments

Returns

mixed
public mixed
# expand( mixed $s )

Expands %placeholders%.

Expands %placeholders%.

Parameters

$s
mixed

Returns

mixed
public object &
# __get( string $name )

Gets the service object, shortcut for getService().

Gets the service object, shortcut for getService().

Parameters

$name
string

Returns

object

Throws

MemberAccessException
if the property is not defined.

Overrides

Object::__get()
public
# __set( string $name, object $service )

Adds the service object.

Adds the service object.

Parameters

$name
string
$service
object

Throws

MemberAccessException
if the property is not defined or is read-only

Overrides

Object::__set()
public boolean
# __isset( string $name )

Does the service exist?

Does the service exist?

Parameters

$name
string

Returns

boolean

Overrides

Object::__isset()
public
# __unset( string $name )

Removes the service, shortcut for removeService().

Removes the service, shortcut for removeService().

Parameters

$name
string
property name

Throws

MemberAccessException

Overrides

Object::__unset()
public static
# getMethodName( $name, $isService = TRUE )
Methods inherited from FreezableObject
__clone(), freeze(), isFrozen(), updating()
Methods inherited from Object
__call(), __callStatic(), extensionMethod(), getReflection()
Constants summary
string TAGS 'tags'
#
Properties summary
public array $parameters array()
#
public array $params array()
#

Deprecated

public array $classes array()
#
public array $meta array()
#
Magic properties inherited from FreezableObject
$frozen
Magic properties inherited from Object
$reflection
Nette Framework 2.0.18 (for PHP 5.2, un-prefixed) API documentation generated by ApiGen 2.8.0