Class ServiceLocator (namespace Nette)


Service locator pattern implementation.

Object
   |
   --ServiceLocator

Implements interfaces:

IServiceLocator
Author: David Grudl
Copyright: Copyright (c) 2004, 2009 David Grudl
Located: in /ServiceLocator.php (line 38)
Constructor Summary
public
__construct ([IServiceLocator $parent = NULL])
Method Summary
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
Object::extensionMethod(), Object::getClass(), Object::getReflection(), Object::__call(), Object::__callStatic(), Object::__get(), Object::__isset(), Object::__set(), Object::__unset()

Constructor Details

line 54

__construct

public __construct ([IServiceLocator $parent = NULL])

Input
IServiceLocator $parent
Method Details

line 69

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 182

getParent

public IServiceLocator|NULL getParent ()

Returns the parent container if any.

Implementation of:

Output
IServiceLocator|NULL  

line 132

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 110

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