Menu

## ObjectCreator
in package
implements DefinitionResolver

ObjectCreator.php : 27

Create objects based on an object definition.

##### Tags

template-implements

  DefinitionResolver<ObjectDefinition>

since
  4.0
author

  Matthieu Napoli matthieu@mnapoli.fr

### Table of Contents

#### Interfaces

DefinitionResolver
  Resolves a definition to a value.

#### Properties

$definitionResolver : DefinitionResolver
$parameterResolver : ParameterResolver
$proxyFactory : ProxyFactory

#### Methods

__construct() : mixed
isResolvable() : bool
  The definition is not resolvable if the class is not instantiable (interface or abstract) or if the class doesn't exist.
resolve() : mixed
  Resolve a class definition to a value.
setPrivatePropertyValue() : void
injectMethodsAndProperties() : void
createInstance() : object
  Creates an instance of the class and injects dependencies.
createProxy() : LazyLoadingInterface
  Returns a proxy instance.
injectProperty() : void
  Inject dependencies into properties.

### Properties

#### $definitionResolver

ObjectCreator.php : 36
`private DefinitionResolver $definitionResolver`

#### $parameterResolver

ObjectCreator.php : 29
`private ParameterResolver $parameterResolver`

#### $proxyFactory

ObjectCreator.php : 37
`private ProxyFactory $proxyFactory`

### Methods

#### __construct()

ObjectCreator.php : 35
`public __construct(DefinitionResolver $definitionResolver, ProxyFactory $proxyFactory) : mixed`

##### Parameters

$definitionResolver : DefinitionResolver

  Used to resolve nested definitions.

$proxyFactory : ProxyFactory

  Used to create proxies for lazy injections.

#### isResolvable()

ObjectCreator.php : 65

The definition is not resolvable if the class is not instantiable (interface or abstract) or if the class doesn't exist.

`public isResolvable(ObjectDefinition $definition[, array<string|int, mixed> $parameters = [] ]) : bool`

##### Parameters

$definition : ObjectDefinition
$parameters : array<string|int, mixed> = []

  Optional parameters to use to build the entry.

##### Return values

bool

#### resolve()

ObjectCreator.php : 49

Resolve a class definition to a value.

`public resolve(ObjectDefinition $definition[, array<string|int, mixed> $parameters = [] ]) : mixed`

This will create a new instance of the class using the injections points defined.

##### Parameters

$definition : ObjectDefinition
$parameters : array<string|int, mixed> = []

  Optional parameters to use to build the entry.

##### Return values

mixed —

Value obtained from the definition.

#### setPrivatePropertyValue()

ObjectCreator.php : 197
`public static setPrivatePropertyValue(string|null $className, mixed $object, string $propertyName, mixed $propertyValue) : void`

##### Parameters

$className : string|null
$object : mixed
$propertyName : string
$propertyValue : mixed

#### injectMethodsAndProperties()

ObjectCreator.php : 149
`protected injectMethodsAndProperties(object $object, ObjectDefinition $objectDefinition) : void`

##### Parameters

$object : object
$objectDefinition : ObjectDefinition

#### createInstance()

ObjectCreator.php : 97

Creates an instance of the class and injects dependencies.

`private createInstance(ObjectDefinition $definition, array<string|int, mixed> $parameters) : object`

.

##### Parameters

$definition : ObjectDefinition
$parameters : array<string|int, mixed>

  Optional parameters to use to create the instance.

##### Tags

throws
  DependencyException
throws
  InvalidDefinition

##### Return values

object

#### createProxy()

ObjectCreator.php : 73

Returns a proxy instance.

`private createProxy(ObjectDefinition $definition, array<string|int, mixed> $parameters) : LazyLoadingInterface`

##### Parameters

$definition : ObjectDefinition
$parameters : array<string|int, mixed>

##### Return values

LazyLoadingInterface

#### injectProperty()

ObjectCreator.php : 173

Inject dependencies into properties.

`private injectProperty(object $object, PropertyInjection $propertyInjection) : void`

##### Parameters

$object : object

  Object to inject dependencies into

$propertyInjection : PropertyInjection

  Property injection definition

##### Tags

throws
  DependencyException

## Search results