Class ServiceLocator (namespace Nette)


Service locator pattern implementation.

Object
   |
   --ServiceLocator

Implements interfaces:

Author: David Grudl
Copyright: Copyright (c) 2004, 2009 David Grudl
Located: in /ServiceLocator.php (line 36)
Public Method Summary
ServiceLocator
__construct ([IServiceLocator $parent = NULL])
void
addService (mixed $service, [string $name = NULL], [bool $promote = FALSE])
Adds the specified service to the service container.
IServiceLocator|NULL
Returns the parent container if any.
mixed
getService (string $name, [bool $need = TRUE])
Gets the service object of the specified type.
void
removeService (bool $name, [$promote = TRUE])
Removes the specified service type from the service container.
Methods Inherited From Object
extensionMethod(), getClass(), getReflection(), __call(), __callStatic(), __get(), __isset(), __set(), __unset()

Method Details

line 52

__construct

public ServiceLocator __construct ([IServiceLocator $parent = NULL])

Input
IServiceLocator $parent
Output
ServiceLocator  

line 67

addService

public void addService (mixed $service, [string $name = NULL], [bool $promote = FALSE])

Adds the specified service to the service container.

Implementation of:

Input
mixed $service object, class name or service factory callback
string $name optional service name (for factories is not optional)
bool $promote promote to higher level?
Output
void  
Throws
throws InvalidArgumentException, AmbiguousServiceException

line 185

getParent

public IServiceLocator|NULL getParent ()

Returns the parent container if any.

Implementation of:

Output
IServiceLocator|NULL  

line 130

getService

public mixed getService (string $name, [bool $need = TRUE])

Gets the service object of the specified type.

Implementation of:

Input
string $name service name
bool $need throw exception if service doesn't exist?
Output
mixed  

line 108

removeService

public void removeService (bool $name, [$promote = TRUE])

Removes the specified service type from the service container.

Input
bool $name promote to higher level?
$promote
Output
void