Symfony\Component\DependencyInjection\Definition::getConfigurator PHP Method

getConfigurator() public method

Gets the configurator to call after the service is fully initialized.
public getConfigurator ( ) : callable | null
return callable | null The PHP callable to call
    public function getConfigurator()
    {
        return $this->configurator;
    }

Usage Example

示例#1
0
 /**
  * Adds a service.
  *
  * @param Definition  $definition
  * @param string      $id
  * @param \DOMElement $parent
  */
 private function addService($definition, $id, \DOMElement $parent)
 {
     $service = $this->document->createElement('service');
     if (null !== $id) {
         $service->setAttribute('id', $id);
     }
     if ($definition->getClass()) {
         $service->setAttribute('class', $definition->getClass());
     }
     if ($definition->getFactoryMethod()) {
         $service->setAttribute('factory-method', $definition->getFactoryMethod());
     }
     if ($definition->getFactoryService()) {
         $service->setAttribute('factory-service', $definition->getFactoryService());
     }
     if (ContainerInterface::SCOPE_CONTAINER !== ($scope = $definition->getScope())) {
         $service->setAttribute('scope', $scope);
     }
     if (!$definition->isPublic()) {
         $service->setAttribute('public', 'false');
     }
     foreach ($definition->getTags() as $name => $tags) {
         foreach ($tags as $attributes) {
             $tag = $this->document->createElement('tag');
             $tag->setAttribute('name', $name);
             foreach ($attributes as $key => $value) {
                 $tag->setAttribute($key, $value);
             }
             $service->appendChild($tag);
         }
     }
     if ($definition->getFile()) {
         $file = $this->document->createElement('file');
         $file->appendChild($this->document->createTextNode($definition->getFile()));
         $service->appendChild($file);
     }
     if ($parameters = $definition->getArguments()) {
         $this->convertParameters($parameters, 'argument', $service);
     }
     if ($parameters = $definition->getProperties()) {
         $this->convertParameters($parameters, 'property', $service, 'name');
     }
     $this->addMethodCalls($definition->getMethodCalls(), $service);
     if ($callable = $definition->getConfigurator()) {
         $configurator = $this->document->createElement('configurator');
         if (is_array($callable)) {
             $configurator->setAttribute($callable[0] instanceof Reference ? 'service' : 'class', $callable[0]);
             $configurator->setAttribute('method', $callable[1]);
         } else {
             $configurator->setAttribute('function', $callable);
         }
         $service->appendChild($configurator);
     }
     $parent->appendChild($service);
 }
All Usage Examples Of Symfony\Component\DependencyInjection\Definition::getConfigurator