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 35)
Public Method Summary
ServiceLocator
__construct ([IServiceLocator $parent = NULL])
void
addService (string $name, mixed $service, [bool $singleton = TRUE], [$options = NULL])
Adds the specified service to the service container.
IServiceLocator|NULL
Returns the parent container if any.
mixed
getService (string $name, [$options = NULL])
Gets the service object of the specified type.
bool
hasService (string $name, [bool $created = FALSE])
Exists the service?
void
removeService ($name)
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 51

__construct

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

Input
IServiceLocator $parent
Output
ServiceLocator  

line 66

addService

public void addService (string $name, mixed $service, [bool $singleton = TRUE], [$options = NULL])

Adds the specified service to the service container.

Implementation of:

Input
string $name service name
mixed $service object, class name or factory callback
bool $singleton is singleton?
$options factory options
Output
void  

line 201

getParent

public IServiceLocator|NULL getParent ()

Returns the parent container if any.

Output
IServiceLocator|NULL  

line 115

getService

public mixed getService (string $name, [$options = NULL])

Gets the service object of the specified type.

Implementation of:

Input
string $name service name
$options options in case service is not singleton
Output
mixed  

line 185

hasService

public bool hasService (string $name, [bool $created = FALSE])

Exists the service?

Implementation of:

Input
string $name service name
bool $created must be created yet?
Output
bool  

line 97

removeService

public void removeService ($name)

Removes the specified service type from the service container.

Input
$name
Output
void