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

Breadcrumb

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

function BindTrait::bind

Sets bindings.

Bindings map $named or FQCN arguments to values that should be injected in the matching parameters (of the constructor, of methods called and of controller actions).

Parameters

string $nameOrFqcn A parameter name with its "$" prefix, or an FQCN:

mixed $valueOrRef The value or reference to bind:

Return value

$this

File

vendor/symfony/dependency-injection/Loader/Configurator/Traits/BindTrait.php, line 32

Class

BindTrait

Namespace

Symfony\Component\DependencyInjection\Loader\Configurator\Traits

Code

public final function bind(string $nameOrFqcn, mixed $valueOrRef) : static {
    $valueOrRef = static::processValue($valueOrRef, true);
    $bindings = $this->definition
        ->getBindings();
    $type = $this instanceof DefaultsConfigurator ? BoundArgument::DEFAULTS_BINDING : ($this instanceof InstanceofConfigurator ? BoundArgument::INSTANCEOF_BINDING : BoundArgument::SERVICE_BINDING);
    $bindings[$nameOrFqcn] = new BoundArgument($valueOrRef, true, $type, $this->path ?? null);
    $this->definition
        ->setBindings($bindings);
    return $this;
}

API Navigation

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