Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. AutowireCallable.php

function AutowireCallable::buildDefinition

Overrides AutowireInline::buildDefinition

2 calls to AutowireCallable::buildDefinition()
AutowireMethodOf::buildDefinition in vendor/symfony/dependency-injection/Attribute/AutowireMethodOf.php
AutowireMethodOf::buildDefinition in vendor/symfony/dependency-injection/Attribute/AutowireMethodOf.php
1 method overrides AutowireCallable::buildDefinition()
AutowireMethodOf::buildDefinition in vendor/symfony/dependency-injection/Attribute/AutowireMethodOf.php

File

vendor/symfony/dependency-injection/Attribute/AutowireCallable.php, line 46

Class

AutowireCallable
Attribute to tell which callable to give to an argument of type Closure.

Namespace

Symfony\Component\DependencyInjection\Attribute

Code

public function buildDefinition(mixed $value, ?string $type, \ReflectionParameter $parameter) : Definition {
    return (new Definition($type = \is_array($this->lazy) ? current($this->lazy) : ($type ?: 'Closure')))
        ->setFactory([
        'Closure',
        'fromCallable',
    ])
        ->setArguments([
        \is_array($value) ? $value + [
            1 => '__invoke',
        ] : $value,
    ])
        ->setLazy($this->lazy || 'Closure' !== $type && 'callable' !== (string) $parameter->getType());
}
RSS feed
Powered by Drupal