Moodle PHP Documentation 4.4
Moodle 4.4.1 (Build: 20240610) (db07c09afc5)
DI\Definition\Helper\AutowireDefinitionHelper Class Reference
Inheritance diagram for DI\Definition\Helper\AutowireDefinitionHelper:
DI\Definition\Helper\CreateDefinitionHelper DI\Definition\Helper\DefinitionHelper

Public Member Functions

 constructor (mixed ... $parameters)
 Defines the arguments to use to call the constructor.
 
 constructorParameter (string|int $parameter, mixed $value)
 Defines a value for a specific argument of the constructor.
 
 getDefinition (string $entryName)
 
 lazy ()
 Define the entry as lazy.
 
 method (string $method, mixed ... $parameters)
 Defines a method to call and the arguments to use.
 
 methodParameter (string $method, string|int $parameter, mixed $value)
 Defines a method to call and a value for a specific argument.
 
 property (string $property, mixed $value)
 Defines a value to inject in a property of the object.
 

Public Attributes

const DEFINITION_CLASS = AutowireDefinition::class
 

Protected Attributes

array $constructor = []
 Array of constructor parameters.
 
array $methods = []
 Array of methods and their parameters.
 

Member Function Documentation

◆ constructor()

DI\Definition\Helper\CreateDefinitionHelper::constructor ( mixed ... $parameters)
inherited

Defines the arguments to use to call the constructor.

This method takes a variable number of arguments, example: ->constructor($param1, $param2, $param3)

Parameters
mixed...$parameters Parameters to use for calling the constructor of the class.
Return values
$this

◆ constructorParameter()

DI\Definition\Helper\AutowireDefinitionHelper::constructorParameter ( string|int $parameter,
mixed $value )

Defines a value for a specific argument of the constructor.

This method is usually used together with attributes or autowiring, when a parameter is not (or cannot be) type-hinted. Using this method instead of constructor() allows to avoid defining all the parameters (letting them being resolved using attributes or autowiring) and only define one.

Parameters
string | int$parameterParameter name of position for which the value will be given.
mixed$valueValue to give to this parameter.
Return values
$this

◆ getDefinition()

DI\Definition\Helper\CreateDefinitionHelper::getDefinition ( string $entryName)
inherited
Parameters
string$entryNameContainer entry name

Implements DI\Definition\Helper\DefinitionHelper.

◆ lazy()

DI\Definition\Helper\CreateDefinitionHelper::lazy ( )
inherited

Define the entry as lazy.

A lazy entry is created only when it is used, a proxy is injected instead.

Return values
$this

◆ method()

DI\Definition\Helper\CreateDefinitionHelper::method ( string $method,
mixed ... $parameters )
inherited

Defines a method to call and the arguments to use.

This method takes a variable number of arguments after the method name, example:

->method('myMethod', $param1, $param2)

Can be used multiple times to declare multiple calls.

Parameters
string$methodName of the method to call.
mixed...$parameters Parameters to use for calling the method.
Return values
$this

◆ methodParameter()

DI\Definition\Helper\AutowireDefinitionHelper::methodParameter ( string $method,
string|int $parameter,
mixed $value )

Defines a method to call and a value for a specific argument.

This method is usually used together with attributes or autowiring, when a parameter is not (or cannot be) type-hinted. Using this method instead of method() allows to avoid defining all the parameters (letting them being resolved using attributes or autowiring) and only define one.

If multiple calls to the method have been configured already (e.g. in a previous definition) then this method only overrides the parameter for the first call.

Parameters
string$methodName of the method to call.
string | int$parameterParameter name of position for which the value will be given.
mixed$valueValue to give to this parameter.
Return values
$this

◆ property()

DI\Definition\Helper\CreateDefinitionHelper::property ( string $property,
mixed $value )
inherited

Defines a value to inject in a property of the object.

Parameters
string$propertyEntry in which to inject the value.
mixed$valueValue to inject in the property.
Return values
$this

The documentation for this class was generated from the following file: