You are here

ExplorerMenuLinkDeriver.php in GraphQL 8.4

Same filename and directory in other branches
  1. 8.3 src/Plugin/MenuLink/Deriver/ExplorerMenuLinkDeriver.php

File

src/Plugin/MenuLink/Deriver/ExplorerMenuLinkDeriver.php
View source
<?php

namespace Drupal\graphql\Plugin\MenuLink\Deriver;

use Drupal\Component\Plugin\Derivative\DeriverBase;
use Drupal\graphql\Entity\Server;

/**
 * Generates one menu link per GraphQL server for Explorer.
 *
 * @package Drupal\graphql\Plugin\MenuLink\Deriver
 *
 * @codeCoverageIgnore
 */
class ExplorerMenuLinkDeriver extends DeriverBase {

  /**
   * {@inheritdoc}
   */
  public function getDerivativeDefinitions($basePluginDefinition) {
    $servers = array_keys(Server::loadMultiple());
    foreach ($servers as $id) {
      $this->derivatives[$id] = [
        'route_name' => "graphql.explorer.{$id}",
        'parent' => 'entity.graphql_server.collection',
      ] + $basePluginDefinition;
    }
    return $this->derivatives;
  }

}

Classes

Namesort descending Description
ExplorerMenuLinkDeriver Generates one menu link per GraphQL server for Explorer.