class ContainerBuilder extends Object

Basic container builder.

Constants

THIS_SERVICE

THIS_CONTAINER

Properties

array $parameters
string $currentService
ServiceDefinition[] read-only $definitions
array read-only $dependencies

Methods

addDefinition($name, ServiceDefinition $definition = NULL)

Adds new service definition.

void
removeDefinition($name)

Removes the specified service definition.

getDefinition($name)

Gets the service definition.

getDefinitions()

Gets all service definitions.

bool
hasDefinition($name)

Does the service definition exist?

string
getByType($class)

Resolves service name by type.

array
findByTag($tag)

Gets the service objects of the specified tag.

array
autowireArguments($class, $method, array $arguments)

Creates a list of arguments using autowiring.

array
prepareClassList()

Generates $dependencies, $classes and normalizes class names.

addExcludedClasses(array $classes)

No description

addDependency($file)

Adds a file to the list of dependencies.

array
getDependencies()

Returns the list of dependent files.

ClassType[]
generateClasses($className = 'Container', $parentName = 'Nette\\DI\\Container')

Generates PHP classes. First class is the container.

string
formatStatement(Statement $statement)

Formats PHP code for class instantiating, function calling or property setting in PHP.

string
formatPhp($statement, $args)

Formats PHP statement.

mixed
expand($value)

Expands %placeholders% in strings.

static PhpLiteral
literal($phpCode)

No description

normalizeEntity($entity)

No description

string
getServiceName($arg)

Converts @service or @\Class -> service name and checks its existence.

Details

at line 56
ServiceDefinition addDefinition($name, ServiceDefinition $definition = NULL)

Adds new service definition.

Parameters

$name
ServiceDefinition $definition

Return Value

ServiceDefinition

at line 73
void removeDefinition($name)

Removes the specified service definition.

Parameters

$name

Return Value

void

at line 84
ServiceDefinition getDefinition($name)

Gets the service definition.

Parameters

$name

Return Value

ServiceDefinition

at line 97
ServiceDefinition[] getDefinitions()

Gets all service definitions.

Return Value

ServiceDefinition[]

at line 108
bool hasDefinition($name)

Does the service definition exist?

Parameters

$name

Return Value

bool

at line 123
string getByType($class)

Resolves service name by type.

Parameters

$class

Return Value

string

service name or NULL

Exceptions

ServiceCreationException

at line 147
array findByTag($tag)

Gets the service objects of the specified tag.

Parameters

$tag

Return Value

array

of [service name => tag attributes]

at line 163
array autowireArguments($class, $method, array $arguments)

Creates a list of arguments using autowiring.

Parameters

$class
$method
array $arguments

Return Value

array

at line 186
array prepareClassList()

Generates $dependencies, $classes and normalizes class names.

Return Value

array

at line 368
ContainerBuilder addExcludedClasses(array $classes)

No description

Parameters

array $classes

Return Value

ContainerBuilder

at line 379
ContainerBuilder addDependency($file)

Adds a file to the list of dependencies.

Parameters

$file

Return Value

ContainerBuilder

at line 390
array getDependencies()

Returns the list of dependent files.

Return Value

array

at line 404
ClassType[] generateClasses($className = 'Container', $parentName = 'Nette\\DI\\Container')

Generates PHP classes. First class is the container.

Parameters

$className
$parentName

Return Value

ClassType[]

at line 560
string formatStatement(Statement $statement)

internal  
 

Formats PHP code for class instantiating, function calling or property setting in PHP.

Parameters

Statement $statement

Return Value

string

at line 624
string formatPhp($statement, $args)

Formats PHP statement.

Parameters

$statement
$args

Return Value

string

at line 667
mixed expand($value)

Expands %placeholders% in strings.

Parameters

$value

Return Value

mixed

at line 676
static PhpLiteral literal($phpCode)

No description

Parameters

$phpCode

Return Value

PhpLiteral

at line 683
normalizeEntity($entity)

internal  
 

No description

Parameters

$entity

at line 706
string getServiceName($arg)

Converts @service or @\Class -> service name and checks its existence.

Parameters

$arg

Return Value

string

of FALSE, if argument is not service name