Namespaces

  • Latte
    • Loaders
    • Macros
    • Runtime
  • Nette
    • Application
      • Responses
      • Routers
      • UI
    • Bridges
      • ApplicationDI
      • ApplicationLatte
      • ApplicationTracy
      • CacheDI
      • CacheLatte
      • DatabaseDI
      • DatabaseTracy
      • DITracy
      • FormsDI
      • FormsLatte
      • Framework
      • HttpDI
      • HttpTracy
      • MailDI
      • ReflectionDI
      • SecurityDI
      • SecurityTracy
    • Caching
      • Storages
    • ComponentModel
    • Database
      • Conventions
      • Drivers
      • Table
    • DI
      • Config
        • Adapters
      • Extensions
    • Forms
      • Controls
      • Rendering
    • Http
    • Iterators
    • Loaders
    • Localization
    • Mail
    • Neon
    • PhpGenerator
      • Traits
    • Reflection
    • Security
    • Tokenizer
    • Utils
  • Tracy
    • Bridges
      • Nette
  • none

Classes

  • Compiler
  • CompilerExtension
  • Container
  • ContainerBuilder
  • ContainerLoader
  • DependencyChecker
  • Helpers
  • PhpGenerator
  • PhpReflection
  • ServiceDefinition
  • Statement

Exceptions

  • MissingServiceException
  • ServiceCreationException
  • Overview
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Other releases

Class ContainerBuilder

Container builder.

Nette\DI\ContainerBuilder uses Nette\SmartObject
Namespace: Nette\DI
Located at DI/ContainerBuilder.php
Methods summary
public Nette\DI\ServiceDefinition
# addDefinition( string $name, Nette\DI\ServiceDefinition $definition = null )

Adds new service definition.

Adds new service definition.

Parameters

$name
$definition

Returns

Nette\DI\ServiceDefinition
ServiceDefinition
public
# removeDefinition( string $name )

Removes the specified service definition.

Removes the specified service definition.

Parameters

$name
public Nette\DI\ServiceDefinition
# getDefinition( string $name )

Gets the service definition.

Gets the service definition.

Parameters

$name

Returns

Nette\DI\ServiceDefinition
ServiceDefinition
public Nette\DI\ServiceDefinition[]
# getDefinitions( )

Gets all service definitions.

Gets all service definitions.

Returns

Nette\DI\ServiceDefinition[]
ServiceDefinition[]
public boolean
# hasDefinition( string $name )

Does the service definition or alias exist?

Does the service definition or alias exist?

Parameters

$name

Returns

boolean
bool
public
# addAlias( string $alias, string $service )

Parameters

$alias
$service
public
# removeAlias( $alias )

Removes the specified alias.

Removes the specified alias.

public array
# getAliases( )

Gets all service aliases.

Gets all service aliases.

Returns

array
array
public Nette\DI\ContainerBuilder
# addExcludedClasses( array $types )

Parameters

$types

Returns

Nette\DI\ContainerBuilder
static
public
# setClassName( $name )

Deprecated

public
# getClassName( )

Deprecated

public string|null
# getByType( string $type, boolean $throw = false )

Resolves service name by type.

Resolves service name by type.

Parameters

$type
or interface
$throw
exception if service doesn't exist?

Returns

string|null
service name or null

Throws

Nette\DI\ServiceCreationException
ServiceCreationException
public Nette\DI\ServiceDefinition
# getDefinitionByType( string $type )

Gets the service definition of the specified type.

Gets the service definition of the specified type.

Parameters

$type

Returns

Nette\DI\ServiceDefinition
ServiceDefinition
public Nette\DI\ServiceDefinition[]
# findByType( string $type )

Gets the service names and definitions of the specified type.

Gets the service names and definitions of the specified type.

Parameters

$type

Returns

Nette\DI\ServiceDefinition[]
ServiceDefinition[]
public array
# findByTag( string $tag )

Gets the service objects of the specified tag.

Gets the service objects of the specified tag.

Parameters

$tag

Returns

array
of [service name => tag attributes]
public
# getClassList( )

Internal

public
# prepareClassList( )

Generates $dependencies, $classList and normalizes class names.

Generates $dependencies, $classList and normalizes class names.

Internal

public
# complete( )
public Nette\DI\Statement
# completeStatement( Nette\DI\Statement $statement )

Returns

Nette\DI\Statement
Statement
public Nette\DI\ContainerBuilder
# addDependency( ReflectionClass|ReflectionFunctionAbstract|string $dep )

Adds item to the list of dependencies.

Adds item to the list of dependencies.

Parameters

$dep

Returns

Nette\DI\ContainerBuilder
static

Internal

public array
# getDependencies( )

Returns the list of dependencies.

Returns the list of dependencies.

Returns

array
array
public mixed
# expand( $value )

Expands %placeholders% in strings.

Expands %placeholders% in strings.

Deprecated

Returns

mixed
mixed
public static Nette\PhpGenerator\PhpLiteral
# literal( $code, array $args = null )

Returns

Nette\PhpGenerator\PhpLiteral
Nette\PhpGenerator\PhpLiteral
public string|array
# normalizeEntity( $entity )

Returns

string|array
Class, @service, [Class, member], [@service, member], [, globalFunc], [Statement, member]

Internal

public string
# getServiceName( $arg )

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

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

Returns

string
of false, if argument is not service name

Internal

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

Creates a list of arguments using autowiring.

Creates a list of arguments using autowiring.

Returns

array
array

Internal

public
# generateClasses( $className = 'Container', $parentName = null )

Deprecated

public
# formatStatement( Nette\DI\Statement $statement )

Deprecated

public
# formatPhp( $statement, $args )

Deprecated

Methods used from Nette\SmartObject
__call(), __callStatic(), __get(), __isset(), __set(), __unset(), extensionMethod(), getReflection()
Constants summary
string THIS_SERVICE
#'self'
string THIS_CONTAINER
#'container'
Properties summary
public array $parameters
#[]
Nette 2.4-20180918 API API documentation generated by ApiGen 2.8.0