You are here

final class EdgeEntityFieldConfigListRouteSubscriber in Apigee Edge 8

Replaces the controller on Apigee Edge entities' field config listing UI.

Hierarchy

Expanded class hierarchy of EdgeEntityFieldConfigListRouteSubscriber

1 string reference to 'EdgeEntityFieldConfigListRouteSubscriber'
apigee_edge.services.yml in ./apigee_edge.services.yml
apigee_edge.services.yml
1 service uses EdgeEntityFieldConfigListRouteSubscriber
route_subscriber.apigee_edge.entity_field_config_list in ./apigee_edge.services.yml
Drupal\apigee_edge\Routing\EdgeEntityFieldConfigListRouteSubscriber

File

src/Routing/EdgeEntityFieldConfigListRouteSubscriber.php, line 33

Namespace

Drupal\apigee_edge\Routing
View source
final class EdgeEntityFieldConfigListRouteSubscriber implements EventSubscriberInterface {

  /**
   * The entity type manager service.
   *
   * @var \Drupal\Core\Entity\EntityTypeManagerInterface
   */
  private $entityTypeManager;

  /**
   * AppFieldConfigListUiRouteSubscriber constructor.
   *
   * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
   *   The entity type manager service.
   */
  public function __construct(EntityTypeManagerInterface $entity_type_manager) {
    $this->entityTypeManager = $entity_type_manager;
  }

  /**
   * {@inheritdoc}
   */
  public static function getSubscribedEvents() {
    $events = [];
    $events[RoutingEvents::ALTER] = [
      'alterRoutes',
      -1024,
    ];
    return $events;
  }

  /**
   * Alters Apigee Edge entity related field config listing UI routes.
   *
   * @param \Drupal\Core\Routing\RouteBuildEvent $event
   *   The route build event.
   */
  public function alterRoutes(RouteBuildEvent $event) {
    foreach ($this->entityTypeManager
      ->getDefinitions() as $entity_type) {
      if (in_array(EdgeEntityInterface::class, class_implements($entity_type
        ->getOriginalClass())) && ($route = $event
        ->getRouteCollection()
        ->get("entity.{$entity_type->id()}.field_ui_fields"))) {
        $route
          ->setDefault('_controller', EdgeEntityFieldConfigListController::class . '::listing');
      }
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
EdgeEntityFieldConfigListRouteSubscriber::$entityTypeManager private property The entity type manager service.
EdgeEntityFieldConfigListRouteSubscriber::alterRoutes public function Alters Apigee Edge entity related field config listing UI routes.
EdgeEntityFieldConfigListRouteSubscriber::getSubscribedEvents public static function Returns an array of event names this subscriber wants to listen to.
EdgeEntityFieldConfigListRouteSubscriber::__construct public function AppFieldConfigListUiRouteSubscriber constructor.