You are here

public function SynonymConfigController::overviewEntityTypeBundle in Synonyms 8

Routing callback to overview a particular entity type and behavior service.

1 string reference to 'SynonymConfigController::overviewEntityTypeBundle'
synonyms.routing.yml in ./synonyms.routing.yml
synonyms.routing.yml

File

src/Controller/SynonymConfigController.php, line 107

Class

SynonymConfigController
Controller for admin UI of the module.

Namespace

Drupal\synonyms\Controller

Code

public function overviewEntityTypeBundle(EntityTypeInterface $synonyms_entity_type, $bundle, SynonymsBehaviorInterface $synonyms_behavior_service) {
  $table = [
    '#type' => 'table',
    '#header' => [
      $this
        ->t('Provider'),
      $this
        ->t('Operations'),
    ],
  ];
  foreach ($this
    ->entityTypeManager()
    ->getStorage('synonym')
    ->loadMultiple() as $synonym_config) {
    $provider_instance = $synonym_config
      ->getProviderPluginInstance();
    $provider_definition = $provider_instance
      ->getPluginDefinition();
    if ($provider_definition['controlled_entity_type'] == $synonyms_entity_type
      ->id() && $provider_definition['controlled_bundle'] == $bundle && $this->behaviorService
      ->getBehaviorService($provider_definition['synonyms_behavior_service'])['service'] == $synonyms_behavior_service) {
      $table[] = [
        [
          '#markup' => Html::escape($synonym_config
            ->label()),
        ],
        [
          '#type' => 'operations',
          '#links' => $this
            ->entityTypeManager()
            ->getListBuilder($synonym_config
            ->getEntityTypeId())
            ->getOperations($synonym_config),
        ],
      ];
    }
  }
  return $table;
}