'ajax_example.description', 'batch_example' => 'batch_example.form', 'block_example' => 'block_example.description', 'cache_example' => 'cache_example.description', 'config_entity_example' => 'entity.robot.list', 'content_entity_example' => 'entity.content_entity_example_contact.collection', 'cron_example' => 'cron_example', 'dbtng_example' => 'dbtng_example', 'email_example' => 'email_example.description', 'events_example' => 'events_example.description', 'form_api_example' => 'form_api_example.description', 'field_example' => 'field_example.description', 'field_permission_example' => 'field_permission_example.description', 'file_example' => 'file_example.fileapi', 'hooks_example' => 'hooks_example.description', 'js_example' => 'js_example.info', 'node_type_example' => 'config_node_type_example.description', 'page_example' => 'page_example_description', 'pager_example' => 'pager_example.page', 'phpunit_example' => 'phpunit_example_description', 'plugin_type_example' => 'plugin_type_example.description', 'simpletest_example' => 'simpletest_example_description', 'tabledrag_example' => 'tabledrag_example.description', 'stream_wrapper_example' => 'stream_wrapper_example.description', 'testing_example' => 'testing_example.description', 'queue_example' => 'queue_example', 'tablesort_example' => 'tablesort_example_description', 'tour_example' => 'tour_example_description', ]; // Build a list of links for the menu. $links = []; foreach ($examples as $module => $route) { // Get the module info (title, description) from Drupal. $info = system_get_info('module', $module); // If there's no info, the example isn't enabled, so don't display it. if (!empty($info)) { $links[$module] = [ 'title' => t($info['name']), 'url' => Url::fromRoute($route), 'attributes' => [ 'title' => t($info['description']), ], ]; } } // Add a link to enable all examples. $links['enable_examples'] = [ 'title' => t('Enable Examples'), 'url' => Url::fromRoute('system.modules_list'), 'options' => [ 'title' => t('Enable more examples in on the Extend page.'), ], 'fragment' => 'edit-modules-example-modules', ]; // Create the examples toolbar render array. $items['examples'] = [ '#type' => 'toolbar_item', 'tab' => [ '#type' => 'link', '#title' => t('Examples'), '#url' => Url::fromRoute(''), '#attributes' => [ 'title' => t('Developer Examples'), 'class' => ['toolbar-icon', 'toolbar-icon-examples'], ], ], 'tray' => [ '#heading' => t('Developer Examples'), 'shortcuts' => [ '#theme' => 'links__toolbar_example', '#links' => $links, '#attributes' => [ 'class' => ['toolbar-menu'], ], ], ], '#weight' => 99, '#attached' => [ 'library' => [ 'examples/examples.icons', ], ], ]; return $items; } /** * @} End of 'defgroup examples'. */