diff -u b/README.txt b/README.txt --- b/README.txt +++ b/README.txt @@ -50,7 +50,8 @@ CONFIGURATION ------------- - * Visit the max bundle number setting form at (/admin/config/bundle-number/settings). + * Visit the max bundle number setting form at + (/admin/config/bundle-number/settings). * Enter the max bundle number in textfield and save the form. diff -u b/admin_toolbar_tools/admin_toolbar_tools.links.menu.yml b/admin_toolbar_tools/admin_toolbar_tools.links.menu.yml --- b/admin_toolbar_tools/admin_toolbar_tools.links.menu.yml +++ b/admin_toolbar_tools/admin_toolbar_tools.links.menu.yml @@ -81,5 +81,10 @@ - -admin_toolbar_tools.max_bundle_number: - title: 'Set Max Bundle Toolbar' - route_name: admin_toolbar.max_bundle_number_settings_form - parent: system.admin_config + +admin_toolbar_tools.admin_toolbar_tools: + title: 'Admin Toolbar Tools' + route_name: admin_toolbar.max_bundle_number_settings_form + parent: system.admin_config + +admin_toolbar_tools.max_bundle_number: + title: 'Set Max Bundle Toolbar' + route_name: admin_toolbar.max_bundle_number_settings_form + parent: admin_toolbar_tools.admin_toolbar_tools diff -u b/admin_toolbar_tools/admin_toolbar_tools.routing.yml b/admin_toolbar_tools/admin_toolbar_tools.routing.yml --- b/admin_toolbar_tools/admin_toolbar_tools.routing.yml +++ b/admin_toolbar_tools/admin_toolbar_tools.routing.yml @@ -87,9 +87,9 @@ _permission: 'administer site configuration' - -admin_toolbar.max_bundle_number_settings_form: - path: '/admin/config/bundle-number/settings' - defaults: - _form: '\Drupal\admin_toolbar_tools\Form\BundleSettingsForm' - _title: 'BundleSettingsForm' - requirements: + +admin_toolbar.max_bundle_number_settings_form: + path: '/admin/config/bundle-number/settings' + defaults: + _form: '\Drupal\admin_toolbar_tools\Form\BundleSettingsForm' + _title: 'BundleSettingsForm' + requirements: _permission: 'administer site configuration' reverted: --- b/admin_toolbar_tools/src/Form/BundleSettingsForm.php +++ /dev/null @@ -1,60 +0,0 @@ -config('max_bundle.settings'); - $max_bundle_number = $config->get('max_bundle_number'); - $form['max_bundle_number'] = array( - '#type' => 'textfield', - '#title' => $this->t('Set Max Bundle Number'), - '#default_value' => !empty($max_bundle_number) ? $max_bundle_number : 20, - ); - return parent::buildForm($form, $form_state); - } - /** - * {@inheritdoc} - */ - public function validateForm(array &$form, FormStateInterface $form_state) { - parent::validateForm($form, $form_state); - if (!is_numeric($form_state->getValue('max_bundle_number'))) { - $form_state->setErrorByName('max_bundle_number', $this->t('Max Bundle Number must be numeric')); - } - } - /** - * {@inheritdoc} - */ - public function submitForm(array &$form, FormStateInterface $form_state) { - parent::submitForm($form, $form_state); - $this->config('max_bundle.settings') - ->set('max_bundle_number', $form_state->getValue('max_bundle_number')) - ->save(); - } -} diff -u b/admin_toolbar_tools/src/Plugin/Derivative/ExtraLinks.php b/admin_toolbar_tools/src/Plugin/Derivative/ExtraLinks.php --- b/admin_toolbar_tools/src/Plugin/Derivative/ExtraLinks.php +++ b/admin_toolbar_tools/src/Plugin/Derivative/ExtraLinks.php @@ -48,7 +48,6 @@ */ protected $themeHandler; - /** * A config object for the system performance configuration. * @@ -59,12 +58,12 @@ /** * {@inheritdoc} */ - public function __construct($base_plugin_id, EntityTypeManagerInterface $entity_type_manager, ModuleHandlerInterface $module_handler, RouteProviderInterface $route_provider, ThemeHandlerInterface $theme_handler,ConfigFactoryInterface $config_factory) { + public function __construct($base_plugin_id, EntityTypeManagerInterface $entity_type_manager, ModuleHandlerInterface $module_handler, RouteProviderInterface $route_provider, ThemeHandlerInterface $theme_handler, ConfigFactoryInterface $config_factory) { $this->entityTypeManager = $entity_type_manager; $this->moduleHandler = $module_handler; $this->routeProvider = $route_provider; $this->themeHandler = $theme_handler; - $this->config = $config = $config_factory->get('max_bundle.settings'); + $this->config = $config_factory->get('max_bundle.settings'); } /** @@ -122,7 +121,7 @@ // link. $content_entity_bundle_root = 'entity.' . $content_entity_bundle . '.overview_form.' . $machine_name; $links[$content_entity_bundle_root] = [ - 'title' => $this->t($bundle->label()), + 'title' => $bundle->label(), 'route_name' => 'entity.' . $content_entity_bundle . '.overview_form', 'parent' => 'entity.' . $content_entity_bundle . '.collection', 'route_parameters' => [$content_entity_bundle => $machine_name], @@ -131,7 +130,7 @@ if ($this->routeExists('entity.' . $content_entity_bundle . '.edit_form')) { $key = 'entity.' . $content_entity_bundle . '.edit_form.' . $machine_name; $links[$key] = [ - 'title' => $this->t($bundle->label()), + 'title' => $bundle->label(), 'route_name' => 'entity.' . $content_entity_bundle . '.edit_form', 'parent' => 'entity.' . $content_entity_bundle . '.collection', 'route_parameters' => [$content_entity_bundle => $machine_name], @@ -141,7 +140,7 @@ } else { $links[$key]['parent'] = $base_plugin_definition['id'] . ':' . $content_entity_bundle_root; - $links[$key]['title'] = t('Edit'); + $links[$key]['title'] = $this->t('Edit'); } } if ($this->moduleHandler->moduleExists('field_ui')) { @@ -201,23 +200,23 @@ 'parent' => 'entity.user.collection', ] + $base_plugin_definition; $links['user.admin_permissions'] = [ - 'title' => t('Permissions'), + 'title' => $this->t('Permissions'), 'route_name' => 'user.admin_permissions', 'parent' => 'entity.user.collection', ] + $base_plugin_definition; $links['entity.user_role.collection'] = [ - 'title' => t('Roles'), + 'title' => $this->t('Roles'), 'route_name' => 'entity.user_role.collection', 'parent' => 'entity.user.collection', ] + $base_plugin_definition; $links['user.logout'] = [ - 'title' => t('Logout'), + 'title' => $this->t('Logout'), 'route_name' => 'user.logout', 'parent' => 'admin_toolbar_tools.help', 'weight' => 10, ] + $base_plugin_definition; $links['user.role_add'] = [ - 'title' => t('Add role'), + 'title' => $this->t('Add role'), 'route_name' => 'user.role_add', 'parent' => $base_plugin_definition['id'] . ':entity.user_role.collection', 'weight' => -5, @@ -290,7 +289,7 @@ // Adds node links for each content type. foreach ($this->entityTypeManager->getStorage('node_type')->loadMultiple() as $type) { $links['node.add.' . $type->id()] = [ - 'title' => $this->t($type->label()), + 'title' => $type->label(), 'route_name' => 'node.add', 'parent' => $base_plugin_definition['id'] . ':node.add', 'route_parameters' => ['node_type' => $type->id()], diff -u b/admin_toolbar_tools/src/SearchLinks.php b/admin_toolbar_tools/src/SearchLinks.php --- b/admin_toolbar_tools/src/SearchLinks.php +++ b/admin_toolbar_tools/src/SearchLinks.php @@ -2,7 +2,6 @@ namespace Drupal\admin_toolbar_tools; -use Drupal\admin_toolbar_tools\Plugin\Derivative\ExtraLinks; use Drupal\Core\Cache\Cache; use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Cache\Context\CacheContextsManager; @@ -57,8 +56,7 @@ */ protected $toolbarCache; - - /** + /** * A config object for the system performance configuration. * * @var \Drupal\Core\Config\Config @@ -74,7 +72,7 @@ $this->routeProvider = $route_provider; $this->cacheContextManager = $cache_context_manager; $this->toolbarCache = $toolbar_cache; - $this->config = $config = $config_factory->get('max_bundle.settings'); + $this->config = $config_factory->get('max_bundle.settings'); } /**