| Moodle PHP Documentation 5.1
    Moodle 5.1dev (Build: 20250711) (9addea9f0ac) | 
Add a definition to the Dependency Injection container.
Add a definition to the Dependency Injection container.A definition is a callable that returns an instance of the service.
The callable can take arguments which are resolved using the DI container, for example a definition for the following example service requires moodle_database, and core\formatting which will be resolved using the DI container.
 $hook->add_definition( id: mod::example::service::class, definition: function ( moodle_database $db, core\formatting $formatter, ): mod::example::service { return new mod::example::service( $database, $formatter, $some, $other, $args, )' }, ); 
| string | $id | The identifier of the container entry | 
| callable | Definition::Definition | Definition::SelfResolvingDefinition | Definition::Helper::DefinitionHelper | $definition | The definition of the container entry | 
| self |