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

Breadcrumb

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

function AutowireCallable::__construct

Parameters

string|array|null $callable The callable to autowire:

string|null $service The service containing the callable to autowire:

string|null $method The method name that will be autowired:

bool|class-string $lazy Whether to use lazy-loading for this argument:

Overrides AutowireInline::__construct

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

File

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

Class

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

Namespace

Symfony\Component\DependencyInjection\Attribute

Code

public function __construct(string|array|null $callable = null, ?string $service = null, ?string $method = null, bool|string $lazy = false) {
    if (!(null !== $callable xor null !== $service)) {
        throw new LogicException('#[AutowireCallable] attribute must declare exactly one of $callable or $service.');
    }
    if (null === $service && null !== $method) {
        throw new LogicException('#[AutowireCallable] attribute cannot have a $method without a $service.');
    }
    Autowire::__construct($callable ?? [
        new Reference($service),
        $method ?? '__invoke',
    ], lazy: $lazy);
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal