function EntityMethodDeriver::addDerivative

Same name in other branches
  1. 11.x core/lib/Drupal/Core/Config/Action/Plugin/ConfigAction/Deriver/EntityMethodDeriver.php \Drupal\Core\Config\Action\Plugin\ConfigAction\Deriver\EntityMethodDeriver::addDerivative()

Adds a derivative.

Parameters

string $action_id: The action ID.

\Drupal\Core\Config\Entity\ConfigEntityTypeInterface $entity_type: The entity type.

array $derivative: The derivative definition.

string $methodName: The method name.

1 call to EntityMethodDeriver::addDerivative()
EntityMethodDeriver::processMethod in core/lib/Drupal/Core/Config/Action/Plugin/ConfigAction/Deriver/EntityMethodDeriver.php
Processes a method to create derivatives.

File

core/lib/Drupal/Core/Config/Action/Plugin/ConfigAction/Deriver/EntityMethodDeriver.php, line 135

Class

EntityMethodDeriver
Derives config action methods from attributed config entity methods.

Namespace

Drupal\Core\Config\Action\Plugin\ConfigAction\Deriver

Code

private function addDerivative(string $action_id, ConfigEntityTypeInterface $entity_type, array $derivative, string $methodName) : void {
    $id = $entity_type->getConfigPrefix() . PluginBase::DERIVATIVE_SEPARATOR . $action_id;
    if (isset($this->derivatives[$id])) {
        throw new EntityMethodException(sprintf('Duplicate action can not be created for ID \'%s\' for %s::%s(). The existing action is for the ::%s() method', $id, $entity_type->getClass(), $methodName, $this->derivatives[$id]['constructor_args']['method']));
    }
    $this->derivatives[$id] = $derivative;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.