Support from Acquia helps fund testing for Drupal Acquia logo

Comments

sergeypavlenko’s picture

Assigned: sergeypavlenko » Unassigned
Status: Active » Needs review
FileSize
316 bytes

Replaced the function.

dmouse’s picture

#1 the system_config_form has removed.

Note that the system_config_form() helper that was added during Drupal 8 development has been removed.

I'm working on this

#admin_menu-routing.yml
admin_menu_config:
  pattern: 'admin/config/admin/admin_menu'
  defaults:
    _form: 'Drupal\admin_menu\Form\AdminMenuForm'
  requirements:
    _permission: 'administer site configuration'
// admin_menu.module
function admin_menu_menu(){
  //...
  $items['admin/config/admin/admin_menu'] = array(
    'title' => 'Administration menu',
    'description' => 'Adjust administration menu settings.',
    'route_name' => 'admin_menu_config',
    'type' => MENU_CALLBACK,
  );
  //...
}

 /**
 * @file
 * Contains \Drupal\admin_menu\Form\AdminMenuForm.
 */

namespace Drupal\admin_menu\Form;

use Drupal\Core\Config\ConfigFactory;
use Drupal\Core\Config\Context\ContextInterface;
use Drupal\Core\Path\AliasManagerInterface;
use Drupal\system\SystemConfigFormBase;
use Symfony\Component\DependencyInjection\ContainerInterface;

class AdminMenuForm extends SystemConfigFormBase {
  /**
   * The path alias manager.
   *
   * @var \Drupal\Core\Path\AliasManagerInterface
   */
  protected $aliasManager;

  /**
   * Constructs a SiteInformationForm object.
   *
   * @param \Drupal\Core\Config\ConfigFactory $config_factory
   *   The factory for configuration objects.
   * @param \Drupal\Core\Config\Context\ContextInterface $context
   *   The configuration context used for this configuration object.
   * @param \Drupal\Core\Path\AliasManagerInterface $alias_manager
   *   The path alias manager.
   */
  public function __construct(ConfigFactory $config_factory, ContextInterface $context, AliasManagerInterface $alias_manager) {
    parent::__construct($config_factory, $context);
    $this->aliasManager = $alias_manager;
  }

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container) {
    return new static(
      $container->get('config.factory'),
      $container->get('config.context.free'),
      $container->get('path.alias_manager')
    );
  }

  /**
   * {@inheritdoc}
   */
  public function getFormID() {
    return 'admin_menu_form_config';
  }

  public function admin_menu_js_cache(){

    return admin_menu_js_cache();
  }

  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, array &$form_state) {

    $config = $this->configFactory->get('system.admin_menus');

    $form['admin_menu_margin_top'] = array(
      '#type' => 'checkbox',
      '#title' => t('Adjust top margin'),
      '#default_value' => $config->get('admin_menu_margin_top', 1),
  }   '#description' => t('Shifts the site output down by approximately 20 pixels from the top of the viewport. If disabled, absolute- or fixed-positioned page elements may be covered by the administration menu.'),
    );
  /**
   *$form['admin_menu_position_fixed'] = array(
   */ '#type' => 'checkbox',
  publ'#title' => t('Keep menu at top of page'),
    re'#default_value' => $config->get('admin_menu_position_fixed', 1),
  }   '#description' => t('Displays the administration menu always at the top of the browser viewport (even when scrolling the page).'),
    );
  public function admin_menu_js_cache(){
    // @todo Re-confirm this with latest browser versions.
    $form['admin_menu_position_fixed']['#description'] .= '<br /><strong>' . t('In some browsers, this setting may result in a malformed page, an invisible cursor, non-selectable elements in forms, or other issues.') . '</strong>';

    $form['advanced'] = array(
      '#type' => 'vertical_tabs',
      '#title' => t('Advanced settings'),
    );

    $form['plugins'] = array(
      '#type' => 'details',
      '#title' => t('Plugins'),
      '#group' => 'advanced',
    );
    $form['plugins']['admin_menu_components'] = array(
      '#type' => 'checkboxes',
      '#title' => t('Enabled components'),
      '#options' => array(
        'admin_menu.icon' => t('Icon menu'),
        'admin_menu.menu' => t('Administration menu'),
        'admin_menu.search' => t('Search bar'),
        'admin_menu.users' => t('User counts'),
        'admin_menu.account' => t('Account links'),
      ),
    );

    $form['plugins']['admin_menu_components']['#default_value'] = array_keys(array_filter($config->get('admin_menu_components', $form['plugins']['admin_menu_components']['#options'])));

    $process = element_info_property('checkboxes', '#process', array());

    // TODO: check this
    $form['plugins']['admin_menu_components']['#process'] = array_merge(array('admin_menu_settings_process_components'), $process);
    $form['#attached']['js'][] = drupal_get_path('module', 'admin_menu') . '/admin_menu.admin.js';

    $form['tweaks'] = array(
      '#type' => 'details',
      '#title' => t('System tweaks'),
      '#group' => 'advanced',
    );
    $form['tweaks']['admin_menu_tweak_modules'] = array(
      '#type' => 'checkbox',
      '#title' => t('Collapse module groups on the <a href="!modules-url">%modules</a> page', array(
        '%modules' => t('Modules'),
        '!modules-url' => url('admin/modules'),
      )),
      '#default_value' => $config->get('admin_menu_tweak_modules', 0),
    );
    if (module_exists('util')) {
      $form['tweaks']['admin_menu_tweak_modules']['#description'] .= '<br /><strong>' . t('If the Utility module was installed for this purpose, it can be safely disabled and uninstalled.') . '</strong>';
    }
    $form['tweaks']['admin_menu_tweak_permissions'] = array(
      '#type' => 'checkbox',
      '#title' => t('Collapse module groups on the <a href="@permissions-url">%permissions</a> page', array(
        '%permissions' => t('Permissions'),
        '@permissions-url' => url('admin/people/permissions'),
      )),
      '#default_value' => $config->get('admin_menu_tweak_permissions', 0),
    );
    $form['tweaks']['admin_menu_tweak_tabs'] = array(
      '#type' => 'checkbox',
      '#title' => t('Move local tasks into menu'),
      '#default_value' => $config->get('admin_menu_tweak_tabs', 0),
      '#description' => t('Moves the tabs on all pages into the administration menu. Only possible for themes using the CSS classes tabs primary and tabs secondary.'),
    );

    $form['performance'] = array(
      '#type' => 'details',
      '#title' => t('Performance'),
      '#group' => 'advanced',
    );
    $form['performance']['admin_menu_cache_client'] = array(
      '#type' => 'checkbox',
      '#title' => t('Cache menu in client-side browser'),
      '#default_value' => $config->get('admin_menu_cache_client', 1),
    );

    return parent::buildForm($form, $form_state);
  }

  /**
   * {@inheritdoc}
   */
  public function validateForm(array &$form, array &$form_state) {

    parent::validateForm($form, $form_state);
  }

  /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, array &$form_state) {

    dpm($form_state);

    $this->configFactory->get('system.admin_menu')
      ->set('admin_menu_margin_top', $form_state['input']['admin_menu_margin_top'])
      ->set('admin_menu_position_fixed', $form_state['input']['admin_menu_position_fixed'])
      ->set('admin_menu_components', $form_state['input']['admin_menu_components'])
      ->save();

    parent::submitForm($form, $form_state);
  }
}
jibran’s picture

Issue summary: View changes

I have created a fork of admin_menu 8.x-3.x on github. Please help me fix it for Drupal 8
PRs are welcome. https://github.com/jibran/admin_menu

kerby70’s picture

Attached is a patch converting the form builder system_settings_form to the new form class. This lines up with the changes proposed in #2402185: Convert hook_menu() to routing system https://www.drupal.org/node/2402185#comment-9689639

The variable names have been shortened and placed under the $config = $this->config('admin_menu.admin_config'); since variable_get() has been removed and I am not so sure the use of system.admin_menu is appropriate from #2.

kerby70’s picture

kerby70’s picture

FileSize
10.1 KB
kerby70’s picture

Status: Needs review » Needs work

I am looking into include the admin_menu.settings.yml and changes to the 'admin_menu.settings' naming instead of 'admin_menu.admin_config' for the settings.

kerby70’s picture

Attached are the changes including admin_menu.settings.yml. Included are two additional fixes resolving the change of module_exist() and the other url(). And fixed a bug in my previous for save arrays.

kerby70’s picture

Status: Needs work » Needs review
kerby70’s picture

While reviewing #2401457: replace system variables with configuration API I realized I am duplicating the admin_menu.settings.yml that is already there. I am removing that section from my changes.

kerby70’s picture

My last patches didn't capture the correct changes and both #8 and #10 had lost the form.

Attached are the changes including the two additional fixes resolving the change of module_exist() and the other url(). And fixed a bug in [#4] form save arrays. It does not include the settings.yml which is included in #2401457: replace system variables with configuration API

kerby70’s picture

Removing /module/admin_menu from the file path of #11.

kerby70’s picture

kerby70’s picture

kerby70’s picture

Realized the form call in #2402185: Convert hook_menu() to routing system was inline with the core modules calling ModuleSettingsForm instead of ModuleConfigForm. Here is that change.

Status: Needs review » Needs work

The last submitted patch, 15: admin_menu-convert-config-form-2012194-15.patch, failed testing.

Andrew.Mikhailov’s picture

Assigned: Unassigned » Andrew.Mikhailov

I try to fix this issue asap.
Best regards.

Andrew.Mikhailov’s picture

Status: Needs work » Active

Status: Active » Needs review
thalles’s picture

Category: Bug report » Support request

This module has been deprecated for Drupal 8.
For Drupal 8: the Admin Toolbar provides an experience similar to admin_menu with the core toolbar.

thalles’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.