You are here

class TestDerivativeDiscoveryWithObject in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Core/Plugin/Discovery/TestDerivativeDiscoveryWithObject.php \Drupal\Tests\Core\Plugin\Discovery\TestDerivativeDiscoveryWithObject
  2. 9 core/tests/Drupal/Tests/Core/Plugin/Discovery/TestDerivativeDiscoveryWithObject.php \Drupal\Tests\Core\Plugin\Discovery\TestDerivativeDiscoveryWithObject

Defines test derivative discovery using an object..

Hierarchy

Expanded class hierarchy of TestDerivativeDiscoveryWithObject

File

core/tests/Drupal/Tests/Core/Plugin/Discovery/TestDerivativeDiscoveryWithObject.php, line 10

Namespace

Drupal\Tests\Core\Plugin\Discovery
View source
class TestDerivativeDiscoveryWithObject implements DeriverInterface {

  /**
   * {@inheritdoc}
   * @param string $derivative_id
   *   The ID for the derivative.
   * @param array $base_plugin_definition
   *   An associative array defining the base plugin.
   *
   * @return array
   */
  public function getDerivativeDefinition($derivative_id, $base_plugin_definition) {
    $definitions = $this
      ->getDerivativeDefinitions($base_plugin_definition);
    return $definitions[$derivative_id];
  }

  /**
   * {@inheritdoc}
   * @param array $base_plugin_definition
   *   An associative array defining the base plugin.
   *
   * @return array
   */
  public function getDerivativeDefinitions($base_plugin_definition) {
    $plugins = [];
    for ($i = 0; $i < 2; $i++) {
      $plugins['test_discovery_' . $i] = $base_plugin_definition;
    }
    return $plugins;
  }

}

Members