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

Breadcrumb

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

function Definition::addMethodCall

Adds a method to call after service initialization.

Parameters

string $method The method name to call:

array $arguments An array of arguments to pass to the method call:

bool $returnsClone Whether the call returns the service instance or not:

Return value

$this

Throws

InvalidArgumentException on empty $method param

1 call to Definition::addMethodCall()
Definition::setMethodCalls in vendor/symfony/dependency-injection/Definition.php
Sets the methods to call after service initialization.

File

vendor/symfony/dependency-injection/Definition.php, line 327

Class

Definition
Definition represents a service definition.

Namespace

Symfony\Component\DependencyInjection

Code

public function addMethodCall(string $method, array $arguments = [], bool $returnsClone = false) : static {
    if (!$method) {
        throw new InvalidArgumentException('Method name cannot be empty.');
    }
    $this->calls[] = $returnsClone ? [
        $method,
        $arguments,
        true,
    ] : [
        $method,
        $arguments,
    ];
    return $this;
}
RSS feed
Powered by Drupal