You are here

class TypePluginManagerAggregator in GraphQL 8.3

Hierarchy

Expanded class hierarchy of TypePluginManagerAggregator

2 files declare their use of TypePluginManagerAggregator
PluggableSchemaDeriver.php in src/Plugin/Deriver/PluggableSchemaDeriver.php
SchemaPluginBase.php in src/Plugin/GraphQL/Schemas/SchemaPluginBase.php
1 string reference to 'TypePluginManagerAggregator'
graphql.services.yml in ./graphql.services.yml
graphql.services.yml
1 service uses TypePluginManagerAggregator
graphql.type_manager_aggregator in ./graphql.services.yml
Drupal\graphql\Plugin\TypePluginManagerAggregator

File

src/Plugin/TypePluginManagerAggregator.php, line 5

Namespace

Drupal\graphql\Plugin
View source
class TypePluginManagerAggregator implements \IteratorAggregate {

  /**
   * List of registered plugin managers.
   *
   * @var \Drupal\graphql\Plugin\TypePluginManagerInterface[]
   */
  protected $pluginManagers = [];

  /**
   * Registers a plugin manager.
   *
   * @param \Drupal\graphql\Plugin\TypePluginManagerInterface $pluginManager
   *   The plugin manager to register.
   * @param $id
   *   The id of the service.
   */
  public function addTypeManager(TypePluginManagerInterface $pluginManager, $id) {
    $pieces = explode('.', $id);
    $key = end($pieces);
    $this->pluginManagers[$key] = $pluginManager;
  }

  /**
   * Retrieves a plugin manager by its type.
   *
   * @param string $type
   *   The plugin type.
   *
   * @return \Drupal\graphql\Plugin\TypePluginManagerInterface
   *   The plugin managers for the given plugin type.
   */
  public function getTypeManager($type) {
    if (isset($this->pluginManagers[$type])) {
      return $this->pluginManagers[$type];
    }
    throw new \LogicException(sprintf("Couldn't find a plugin manager for type '%s'.", $type));
  }

  /**
   * {@inheritdoc}
   */
  public function getIterator() {
    return new \ArrayIterator($this->pluginManagers);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
TypePluginManagerAggregator::$pluginManagers protected property List of registered plugin managers.
TypePluginManagerAggregator::addTypeManager public function Registers a plugin manager.
TypePluginManagerAggregator::getIterator public function
TypePluginManagerAggregator::getTypeManager public function Retrieves a plugin manager by its type.