devportal-8.x-2.0-alpha10/modules/api_bundle/devportal_api_bundle.module

modules/api_bundle/devportal_api_bundle.module
<?php

/**
 * @file
 * Main module file for Devportal API Bundle.
 */

/**
 * Provides the list of API Bundle related node bundles.
 *
 * @return array
 *   An array of node bundles.
 */
function devportal_api_bundle_bundles() {
  return ['api_bundle'];
}

/**
 * Implements hook_menu_links_discovered_alter().
 *
 * @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
 */
function devportal_api_bundle_menu_links_discovered_alter(&$links) {
  // Add menu links for API Bundle bundles.
  foreach (\Drupal::entityTypeManager()->getStorage('node_type')->loadMultiple() as $type) {
    if (in_array($type->id(), devportal_api_bundle_bundles(), TRUE)) {
      // Menu link for node add form.
      $links["entity.api_bundle.add.{$type->id()}"] = [
        'title' => t('Add @label', [
          '@label' => $type->label(),
        ]),
        'parent' => 'entity.api_bundle.collection',
        'route_name' => 'node.add',
        'route_parameters' => [
          'node_type' => $type->id(),
        ],
      ];
      // Menu link for node bundle configuration.
      $links["entity.api_bundle.configuration.{$type->id()}"] = [
        'title' => t($type->label()),
        'parent' => 'system.admin_devportal_config',
        'description' => t('Manage @label configuration.', [
          '@label' => $type->label(),
        ]),
        'route_name' => 'entity.node_type.edit_form',
        'route_parameters' => [
          'node_type' => $type->id(),
        ],
      ];
    }
  }
}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc