/**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state, Request $request = NULL)
 {
     $current_url = Url::createFromRequest($request);
     $devel_config = $this->config('devel.settings');
     $form['page_alter'] = array('#type' => 'checkbox', '#title' => t('Display $page array'), '#default_value' => $devel_config->get('page_alter'), '#description' => t('Display $page array from <a href="http://api.drupal.org/api/function/hook_page_alter/7">hook_page_alter()</a> in the messages area of each page.'));
     $form['raw_names'] = array('#type' => 'checkbox', '#title' => t('Display machine names of permissions and modules'), '#default_value' => $devel_config->get('raw_names'), '#description' => t('Display the language-independent machine names of the permissions in mouse-over hints on the <a href=":permissions_url">Permissions</a> page and the module base file names on the Permissions and <a href=":modules_url">Modules</a> pages.', array(':permissions_url' => Url::fromRoute('user.admin_permissions')->toString(), ':modules_url' => Url::fromRoute('system.modules_list')->toString())));
     $error_handlers = devel_get_handlers();
     $form['error_handlers'] = array('#type' => 'select', '#title' => t('Error handlers'), '#options' => array(DEVEL_ERROR_HANDLER_NONE => t('None'), DEVEL_ERROR_HANDLER_STANDARD => t('Standard Drupal'), DEVEL_ERROR_HANDLER_BACKTRACE_DPM => t('Kint backtrace in the message area'), DEVEL_ERROR_HANDLER_BACKTRACE_KINT => t('Kint backtrace above the rendered page')), '#multiple' => TRUE, '#default_value' => empty($error_handlers) ? DEVEL_ERROR_HANDLER_NONE : $error_handlers, '#description' => [['#markup' => $this->t('Select the error handler(s) to use, in case you <a href=":choose">choose to show errors on screen</a>.', [':choose' => $this->url('system.logging_settings')])], ['#theme' => 'item_list', '#items' => [$this->t('<em>None</em> is a good option when stepping through the site in your debugger.'), $this->t('<em>Standard Drupal</em> does not display all the information that is often needed to resolve an issue.'), $this->t('<em>Kint backtrace</em> displays nice debug information when any type of error is noticed, but only to users with the %perm permission.', ['%perm' => t('Access developer information')])]], ['#markup' => $this->t('Depending on the situation, the theme, the size of the call stack and the arguments, etc., some handlers may not display their messages, or display them on the subsequent page. Select <em>Standard Drupal</em> <strong>and</strong> <em>Kint backtrace above the rendered page</em> to maximize your chances of not missing any messages.') . '<br />' . $this->t('Demonstrate the current error handler(s):') . ' ' . $this->l('notice', $current_url->setOption('query', ['demo' => 'notice'])) . ', ' . $this->l('notice+warning', $current_url->setOption('query', ['demo' => 'warning'])) . ', ' . $this->l('notice+warning+error', $current_url->setOption('query', ['demo' => 'error'])) . ' (' . $this->t('The presentation of the @error is determined by PHP.', ['@error' => 'error']) . ')']]);
     $form['error_handlers']['#size'] = count($form['error_handlers']['#options']);
     if ($request->query->has('demo')) {
         if ($request->getMethod() == 'GET') {
             $this->demonstrateErrorHandlers($request->query->get('demo'));
         }
         $request->query->remove('demo');
     }
     $form['rebuild_theme'] = array('#type' => 'checkbox', '#title' => t('Rebuild the theme information like the registry'), '#description' => t('While creating new templates, change the $theme.info.yml and theme_ overrides the theme information needs to be rebuilt.'), '#default_value' => $devel_config->get('rebuild_theme'));
     $dumper = $devel_config->get('devel_dumper');
     $default = $this->dumperManager->isPluginSupported($dumper) ? $dumper : $this->dumperManager->getFallbackPluginId(NULL);
     $form['dumper'] = array('#type' => 'radios', '#title' => $this->t('Variables Dumper'), '#options' => [], '#default_value' => $default, '#description' => $this->t('Select the debugging tool used for formatting and displaying the variables inspected through the debug functions of Devel. You can enable the <a href=":kint_install">Kint module</a> (shipped with Devel) and select the Kint debugging tool for an improved debugging experience. <strong>NOTE</strong>: Some of these plugins require external libraries for to be enabled. Learn how install external libraries with <a href=":url">Composer</a>.', [':url' => 'https://www.drupal.org/node/2404989', ':kint_install' => Url::fromRoute('system.modules_list')->toString()]));
     foreach ($this->dumperManager->getDefinitions() as $id => $definition) {
         $form['dumper']['#options'][$id] = $definition['label'];
         $supported = $this->dumperManager->isPluginSupported($id);
         $form['dumper'][$id]['#disabled'] = !$supported;
         $form['dumper'][$id]['#description'] = ['#type' => 'inline_template', '#template' => '{{ description }}{% if not supported %}<div><small>{% trans %}<strong>Not available</strong>. You may need to install external dependencies for use this plugin.{% endtrans %}</small></div>{% endif %}', '#context' => ['description' => $definition['description'], 'supported' => $supported]];
     }
     return parent::buildForm($form, $form_state);
 }
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state, Request $request = NULL)
 {
     $current_path = $request->attributes->get('_system_path');
     $current_url = Url::createFromRequest($request);
     $devel_config = $this->config('devel.settings');
     $form['queries'] = array('#type' => 'fieldset', '#title' => t('Query log'));
     $description = t('Display a log of the database queries needed to generate the current page, and the execution time for each. Also, queries which are repeated during a single page view are summed in the # column, and printed in red since they are candidates for caching.');
     $form['queries']['query_display'] = array('#type' => 'checkbox', '#title' => t('Display query log'), '#default_value' => $devel_config->get('query_display'), '#description' => $description);
     $form['queries']['settings'] = array('#type' => 'container', '#states' => array('invisible' => array('input[name="query_display"]' => array('checked' => FALSE))));
     $form['queries']['settings']['query_sort'] = array('#type' => 'radios', '#title' => t('Sort query log'), '#default_value' => $devel_config->get('query_sort'), '#options' => array(t('by source'), t('by duration')), '#description' => t('The query table can be sorted in the order that the queries were executed or by descending duration.'));
     $form['queries']['settings']['execution'] = array('#type' => 'textfield', '#title' => t('Slow query highlighting'), '#default_value' => $devel_config->get('execution'), '#size' => 4, '#maxlength' => 4, '#description' => t('Enter an integer in milliseconds. Any query which takes longer than this many milliseconds will be highlighted in the query log. This indicates a possibly inefficient query, or a candidate for caching.'));
     $form['api_url'] = array('#type' => 'textfield', '#title' => t('API Site'), '#default_value' => $devel_config->get('api_url'), '#description' => t('The base URL for your developer documentation links. You might change this if you run <a href="!url">api.module</a> locally.', array('!url' => Url::fromUri('http://drupal.org/project/api')->toString())));
     $form['timer'] = array('#type' => 'checkbox', '#title' => t('Display page timer'), '#default_value' => $devel_config->get('timer'), '#description' => t('Display page execution time in the query log box.'));
     $form['memory'] = array('#type' => 'checkbox', '#title' => t('Display memory usage'), '#default_value' => $devel_config->get('memory'), '#description' => t('Display how much memory is used to generate the current page. This will show memory usage when devel_init() is called and when devel_exit() is called.'));
     $form['redirect_page'] = array('#type' => 'checkbox', '#title' => t('Display redirection page'), '#default_value' => $devel_config->get('redirect_page'), '#description' => t('When a module executes drupal_goto(), the query log and other developer information is lost. Enabling this setting presents an intermediate page to developers so that the log can be examined before continuing to the destination page.'));
     $form['page_alter'] = array('#type' => 'checkbox', '#title' => t('Display $page array'), '#default_value' => $devel_config->get('page_alter'), '#description' => t('Display $page array from <a href="http://api.drupal.org/api/function/hook_page_alter/7">hook_page_alter()</a> in the messages area of each page.'));
     $form['raw_names'] = array('#type' => 'checkbox', '#title' => t('Display machine names of permissions and modules'), '#default_value' => $devel_config->get('raw_names'), '#description' => t('Display the language-independent machine names of the permissions in mouse-over hints on the !Permissions page and the module base file names on the @Permissions and !Modules pages.', array('!Permissions' => $this->l(t('Permissions'), Url::fromRoute('user.admin_permissions')), '@Permissions' => t('Permissions'), '!Modules' => $this->l(t('Modules'), Url::fromRoute('system.modules_list')))));
     $error_handlers = devel_get_handlers();
     $form['error_handlers'] = array('#type' => 'select', '#title' => t('Error handlers'), '#options' => array(DEVEL_ERROR_HANDLER_NONE => t('None'), DEVEL_ERROR_HANDLER_STANDARD => t('Standard Drupal'), DEVEL_ERROR_HANDLER_BACKTRACE_DPM => t('Krumo backtrace in the message area'), DEVEL_ERROR_HANDLER_BACKTRACE_KRUMO => t('Krumo backtrace above the rendered page')), '#multiple' => TRUE, '#default_value' => empty($error_handlers) ? DEVEL_ERROR_HANDLER_NONE : $error_handlers, '#description' => SafeMarkup::set(t('Select the error handler(s) to use, in case you <a href="@choose">choose to show errors on screen</a>.', array('@choose' => $this->url('system.logging_settings'))) . '<ul>' . '<li>' . t('<em>None</em> is a good option when stepping through the site in your debugger.') . '</li>' . '<li>' . t('<em>Standard Drupal</em> does not display all the information that is often needed to resolve an issue.') . '</li>' . '<li>' . t('<em>Krumo backtrace</em> displays nice debug information when any type of error is noticed, but only to users with the %perm permission.', array('%perm' => t('Access developer information'))) . '</li></ul>' . t('Depending on the situation, the theme, the size of the call stack and the arguments, etc., some handlers may not display their messages, or display them on the subsequent page. Select <em>Standard Drupal</em> <strong>and</strong> <em>Krumo backtrace above the rendered page</em> to maximize your chances of not missing any messages.') . '<br />' . t('Demonstrate the current error handler(s):') . ' ' . $this->l('notice', $current_url, array('query' => array('demo' => 'notice'))) . ', ' . $this->l('notice+warning', $current_url, array('query' => array('demo' => 'warning'))) . ', ' . $this->l('notice+warning+error', $current_url, array('query' => array('demo' => 'error'))) . ' ' . t('(The presentation of the @error is determined by PHP.)', array('@error' => 'error'))));
     $form['error_handlers']['#size'] = count($form['error_handlers']['#options']);
     if ($request->query->has('demo')) {
         if ($request->getMethod() == 'GET') {
             $this->demonstrateErrorHandlers($request->query->get('demo'));
         }
         $request->query->remove('demo');
     }
     $options = array('default', 'blue', 'green', 'orange', 'white', 'disabled');
     $form['krumo_skin'] = array('#type' => 'radios', '#title' => t('Krumo display'), '#description' => t('Select a skin for your debug messages or select <em>disabled</em> to display object and array output in standard PHP format.'), '#options' => array_combine($options, $options), '#default_value' => $devel_config->get('krumo_skin'));
     $form['rebuild_theme'] = array('#type' => 'checkbox', '#title' => t('Rebuild the theme information like the registry'), '#description' => t('While creating new templates, change the $theme.info.yml and theme_ overrides the theme information needs to be rebuilt.'), '#default_value' => $devel_config->get('rebuild_theme'));
     $form['use_uncompressed_jquery'] = array('#type' => 'checkbox', '#title' => t('Use uncompressed jQuery'), '#default_value' => $devel_config->get('use_uncompressed_jquery'), '#description' => t("Use a human-readable version of jQuery instead of the minified version that ships with Drupal, to make JavaScript debugging easier."));
     return parent::buildForm($form, $form_state);
 }
 /**
  * Initializes devel module requirements.
  */
 public function onRequest(GetResponseEvent $event)
 {
     if (!devel_silent()) {
         if ($this->account->hasPermission('access devel information')) {
             devel_set_handler(devel_get_handlers());
             // We want to include the class early so that anyone may call krumo()
             // as needed. See http://krumo.sourceforge.net/
             has_krumo();
             // See http://www.firephp.org/HQ/Install.htm
             $path = NULL;
             if (@(include_once 'fb.php') || @(include_once 'FirePHPCore/fb.php')) {
                 // FirePHPCore is in include_path. Probably a PEAR installation.
                 $path = '';
             } elseif ($this->moduleHandler->moduleExists('libraries')) {
                 // Support Libraries API - http://drupal.org/project/libraries
                 $firephp_path = libraries_get_path('FirePHPCore');
                 $firephp_path = $firephp_path ? $firephp_path . '/lib/FirePHPCore/' : '';
                 $chromephp_path = libraries_get_path('chromephp');
             } else {
                 $firephp_path = DRUPAL_ROOT . '/libraries/FirePHPCore/lib/FirePHPCore/';
                 $chromephp_path = './' . drupal_get_path('module', 'devel') . '/chromephp';
             }
             // Include FirePHP if it exists.
             if (!empty($firephp_path) && file_exists($firephp_path . 'fb.php')) {
                 include_once $firephp_path . 'fb.php';
                 include_once $firephp_path . 'FirePHP.class.php';
             }
             // Include ChromePHP if it exists.
             if (!empty($chromephp_path) && file_exists($chromephp_path .= '/ChromePhp.php')) {
                 include_once $chromephp_path;
             }
         }
     }
     if ($this->config->get('rebuild_theme')) {
         drupal_theme_rebuild();
         // Ensure that the active theme object is cleared.
         $theme_name = \Drupal::theme()->getActiveTheme()->getName();
         \Drupal::state()->delete('theme.active_theme.' . $theme_name);
         \Drupal::theme()->resetActiveTheme();
         /** @var \Drupal\Core\Extension\ThemeHandlerInterface $theme_handler*/
         $theme_handler = \Drupal::service('theme_handler');
         $theme_handler->refreshInfo();
         // @todo This is not needed after https://www.drupal.org/node/2330755
         $list = $theme_handler->listInfo();
         $theme_handler->addTheme($list[$theme_name]);
         if (\Drupal::service('flood')->isAllowed('devel.rebuild_theme_warning', 1)) {
             \Drupal::service('flood')->register('devel.rebuild_theme_warning');
             if (!devel_silent() && $this->account->hasPermission('access devel information')) {
                 drupal_set_message(t('The theme information is being rebuilt on every request. Remember to <a href="@url">turn off</a> this feature on production websites.', array('@url' => $this->urlGenerator->generateFromRoute('devel.admin_settings'))));
             }
         }
     }
     drupal_register_shutdown_function('devel_shutdown');
 }
 /**
  * Initializes devel module requirements.
  */
 public function onRequest(GetResponseEvent $event)
 {
     if (!devel_silent()) {
         if ($this->config->get('memory')) {
             global $memory_init;
             $memory_init = memory_get_usage();
         }
         if (devel_query_enabled()) {
             Database::startLog('devel');
         }
         if ($this->account->hasPermission('access devel information')) {
             devel_set_handler(devel_get_handlers());
             // We want to include the class early so that anyone may call krumo()
             // as needed. See http://krumo.sourceforge.net/
             has_krumo();
             // See http://www.firephp.org/HQ/Install.htm
             $path = NULL;
             if (@(include_once 'fb.php') || @(include_once 'FirePHPCore/fb.php')) {
                 // FirePHPCore is in include_path. Probably a PEAR installation.
                 $path = '';
             } elseif ($this->moduleHandler->moduleExists('libraries')) {
                 // Support Libraries API - http://drupal.org/project/libraries
                 $firephp_path = libraries_get_path('FirePHPCore');
                 $firephp_path = $firephp_path ? $firephp_path . '/lib/FirePHPCore/' : '';
                 $chromephp_path = libraries_get_path('chromephp');
             } else {
                 $firephp_path = DRUPAL_ROOT . '/libraries/FirePHPCore/lib/FirePHPCore/';
                 $chromephp_path = './' . drupal_get_path('module', 'devel') . '/chromephp';
             }
             // Include FirePHP if it exists.
             if (!empty($firephp_path) && file_exists($firephp_path . 'fb.php')) {
                 include_once $firephp_path . 'fb.php';
                 include_once $firephp_path . 'FirePHP.class.php';
             }
             // Include ChromePHP if it exists.
             if (!empty($chromephp_path) && file_exists($chromephp_path .= '/ChromePhp.php')) {
                 include_once $chromephp_path;
             }
         }
     }
     if ($this->config->get('rebuild_theme_registry')) {
         drupal_theme_rebuild();
         if (\Drupal::service('flood')->isAllowed('devel.rebuild_registry_warning', 1)) {
             \Drupal::service('flood')->register('devel.rebuild_registry_warning');
             if (!devel_silent() && $this->account->hasPermission('access devel information')) {
                 drupal_set_message(t('The theme registry is being rebuilt on every request. Remember to <a href="!url">turn off</a> this feature on production websites.', array("!url" => url('admin/config/development/devel'))));
             }
         }
     }
     drupal_register_shutdown_function('devel_shutdown');
 }
Exemple #5
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state, Request $request = NULL)
 {
     $current_url = Url::createFromRequest($request);
     $devel_config = $this->config('devel.settings');
     $form['api_url'] = array('#type' => 'textfield', '#title' => t('API Site'), '#default_value' => $devel_config->get('api_url'), '#description' => t('The base URL for your developer documentation links. You might change this if you run <a href=":url">api.module</a> locally.', array(':url' => Url::fromUri('http://drupal.org/project/api')->toString())));
     $form['page_alter'] = array('#type' => 'checkbox', '#title' => t('Display $page array'), '#default_value' => $devel_config->get('page_alter'), '#description' => t('Display $page array from <a href="http://api.drupal.org/api/function/hook_page_alter/7">hook_page_alter()</a> in the messages area of each page.'));
     $form['raw_names'] = array('#type' => 'checkbox', '#title' => t('Display machine names of permissions and modules'), '#default_value' => $devel_config->get('raw_names'), '#description' => t('Display the language-independent machine names of the permissions in mouse-over hints on the <a href=":permissions_url">Permissions</a> page and the module base file names on the Permissions and <a href=":modules_url">Modules</a> pages.', array(':permissions_url' => Url::fromRoute('user.admin_permissions')->toString(), ':modules_url' => Url::fromRoute('system.modules_list')->toString())));
     $error_handlers = devel_get_handlers();
     $form['error_handlers'] = array('#type' => 'select', '#title' => t('Error handlers'), '#options' => array(DEVEL_ERROR_HANDLER_NONE => t('None'), DEVEL_ERROR_HANDLER_STANDARD => t('Standard Drupal'), DEVEL_ERROR_HANDLER_BACKTRACE_DPM => t('Kint backtrace in the message area'), DEVEL_ERROR_HANDLER_BACKTRACE_KINT => t('Kint backtrace above the rendered page')), '#multiple' => TRUE, '#default_value' => empty($error_handlers) ? DEVEL_ERROR_HANDLER_NONE : $error_handlers, '#description' => [['#markup' => $this->t('Select the error handler(s) to use, in case you <a href=":choose">choose to show errors on screen</a>.', [':choose' => $this->url('system.logging_settings')])], ['#theme' => 'item_list', '#items' => [$this->t('<em>None</em> is a good option when stepping through the site in your debugger.'), $this->t('<em>Standard Drupal</em> does not display all the information that is often needed to resolve an issue.'), $this->t('<em>Kint backtrace</em> displays nice debug information when any type of error is noticed, but only to users with the %perm permission.', ['%perm' => t('Access developer information')])]], ['#markup' => $this->t('Depending on the situation, the theme, the size of the call stack and the arguments, etc., some handlers may not display their messages, or display them on the subsequent page. Select <em>Standard Drupal</em> <strong>and</strong> <em>Kint backtrace above the rendered page</em> to maximize your chances of not missing any messages.') . '<br />' . $this->t('Demonstrate the current error handler(s):') . ' ' . $this->l('notice', $current_url->setOption('query', ['demo' => 'notice'])) . ', ' . $this->l('notice+warning', $current_url->setOption('query', ['demo' => 'warning'])) . ', ' . $this->l('notice+warning+error', $current_url->setOption('query', ['demo' => 'error'])) . ' (' . $this->t('The presentation of the @error is determined by PHP.', ['@error' => 'error']) . ')']]);
     $form['error_handlers']['#size'] = count($form['error_handlers']['#options']);
     if ($request->query->has('demo')) {
         if ($request->getMethod() == 'GET') {
             $this->demonstrateErrorHandlers($request->query->get('demo'));
         }
         $request->query->remove('demo');
     }
     $form['rebuild_theme'] = array('#type' => 'checkbox', '#title' => t('Rebuild the theme information like the registry'), '#description' => t('While creating new templates, change the $theme.info.yml and theme_ overrides the theme information needs to be rebuilt.'), '#default_value' => $devel_config->get('rebuild_theme'));
     return parent::buildForm($form, $form_state);
 }