Coduo\TuTu\ServiceContainer::setDefinition PHP Method

setDefinition() public method

Callback will be executed with $this (ServiceContainer) as a argument.
public setDefinition ( $id, Closure $definition, array $tags = [] )
$id
$definition Closure
$tags array
    public function setDefinition($id, \Closure $definition, $tags = [])
    {
        $this->serviceDefinitions[$id] = $definition;
        $this->tags[$id] = $tags;
    }

Usage Example

Example #1
0
 private function registerResponseBuilder()
 {
     $this->container->setDefinition('request.path.parser', function ($container) {
         return new Parser();
     });
     $this->container->setDefinition('response.builder', function ($container) {
         return new Builder($container->getService('twig'), $container->getService('request.path.parser'));
     });
 }