devel.module 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616
  1. <?php
  2. /**
  3. * @file
  4. * This module holds functions useful for Drupal development.
  5. * Please contribute!
  6. */
  7. define('DEVEL_ERROR_HANDLER_NONE', 0);
  8. define('DEVEL_ERROR_HANDLER_STANDARD', 1);
  9. define('DEVEL_ERROR_HANDLER_BACKTRACE_KINT', 2);
  10. define('DEVEL_ERROR_HANDLER_BACKTRACE_DPM', 4);
  11. define('DEVEL_MIN_TEXTAREA', 50);
  12. use Drupal\comment\CommentInterface;
  13. use Drupal\Core\Database\Database;
  14. use Drupal\Core\Database\Query\AlterableInterface;
  15. use Drupal\Core\Entity\EntityInterface;
  16. use Drupal\Core\Form\FormStateInterface;
  17. use Drupal\Core\Logger\RfcLogLevel;
  18. use Drupal\Core\Menu\LocalTaskDefault;
  19. use Drupal\Core\Render\Element;
  20. use Drupal\Core\Routing\RouteMatchInterface;
  21. use Drupal\Core\Url;
  22. use Drupal\Core\Utility\Error;
  23. use Drupal\devel\EntityTypeInfo;
  24. use Drupal\devel\ToolbarHandler;
  25. use Drupal\Core\StringTranslation\TranslatableMarkup;
  26. /**
  27. * Implements hook_help().
  28. */
  29. function devel_help($route_name, RouteMatchInterface $route_match) {
  30. switch ($route_name) {
  31. case 'help.page.devel':
  32. $output = '';
  33. $output .= '<h3>' . t('About') . '</h3>';
  34. $output .= '<p>' . t('The Devel module provides a suite of modules containing fun for module developers and themers. For more information, see the <a href=":url">online documentation for the Devel module</a>.', [':url' => 'https://www.drupal.org/docs/8/modules/devel']) . '</p>';
  35. $output .= '<h3>' . t('Uses') . '</h3>';
  36. $output .= '<dl>';
  37. $output .= '<dt>' . t('Inspecting Service Container') . '</dt>';
  38. $output .= '<dd>' . t('The module allows you to inspect Services and Parameters registered in the Service Container. You can see those informations on <a href=":url">Container info</a> page.', [':url' => Url::fromRoute('devel.container_info.service')->toString()]) . '</dd>';
  39. $output .= '<dt>' . t('Inspecting Routes') . '</dt>';
  40. $output .= '<dd>' . t('The module allows you to inspect routes information, gathering all routing data from <em>.routing.yml</em> files and from classes which subscribe to the route build/alter events. You can see those informations on <a href=":url">Routes info</a> page.', [':url' => Url::fromRoute('devel.route_info')->toString()]) . '</dd>';
  41. $output .= '<dt>' . t('Inspecting Events') . '</dt>';
  42. $output .= '<dd>' . t('The module allow you to inspect listeners registered in the event dispatcher. You can see those informations on <a href=":url">Events info</a> page.', [':url' => Url::fromRoute('devel.event_info')->toString()]) . '</dd>';
  43. $output .= '</dl>';
  44. return $output;
  45. case 'devel.container_info.service':
  46. case 'devel.container_info.parameter':
  47. $output = '';
  48. $output .= '<p>' . t('Displays Services and Parameters registered in the Service Container. For more informations on the Service Container, see the <a href=":url">Symfony online documentation</a>.', [':url' => 'http://symfony.com/doc/current/service_container.html']) . '</p>';
  49. return $output;
  50. case 'devel.route_info':
  51. $output = '';
  52. $output .= '<p>' . t('Displays registered routes for the site. For a complete overview of the routing system, see the <a href=":url">online documentation</a>.', [':url' => 'https://www.drupal.org/docs/8/api/routing-system']) . '</p>';
  53. return $output;
  54. case 'devel.event_info':
  55. $output = '';
  56. $output .= '<p>' . t('Displays events and listeners registered in the event dispatcher. For a complete overview of the event system, see the <a href=":url">Symfony online documentation</a>.', [':url' => 'http://symfony.com/doc/current/components/event_dispatcher.html']) . '</p>';
  57. return $output;
  58. case 'devel.reinstall':
  59. $output = '<p>' . t('<strong>Warning</strong> - will delete your module tables and configuration.') . '</p>';
  60. $output .= '<p>' . t('Uninstall and then install the selected modules. <code>hook_uninstall()</code> and <code>hook_install()</code> will be executed and the schema version number will be set to the most recent update number.') . '</p>';
  61. return $output;
  62. case 'devel/session':
  63. return '<p>' . t('Here are the contents of your <code>$_SESSION</code> variable.') . '</p>';
  64. case 'devel.state_system_page':
  65. return '<p>' . t('This is a list of state variables and their values. For more information read online documentation of <a href=":documentation">State API in Drupal 8</a>.', array(':documentation' => "https://www.drupal.org/developing/api/8/state")) . '</p>';
  66. case 'devel.layout_info':
  67. $output = '';
  68. $output .= '<p>' . t('Displays layouts available to the site. For a complete overview of the layout system, see the <a href=":url">Layout API documentation</a>.', [':url' => 'https://www.drupal.org/docs/8/api/layout-api']) . '</p>';
  69. return $output;
  70. }
  71. }
  72. /**
  73. * Implements hook_entity_type_alter().
  74. */
  75. function devel_entity_type_alter(array &$entity_types) {
  76. return \Drupal::service('class_resolver')
  77. ->getInstanceFromDefinition(EntityTypeInfo::class)
  78. ->entityTypeAlter($entity_types);
  79. }
  80. /**
  81. * Implements hook_entity_operation().
  82. */
  83. function devel_entity_operation(EntityInterface $entity) {
  84. return \Drupal::service('class_resolver')
  85. ->getInstanceFromDefinition(EntityTypeInfo::class)
  86. ->entityOperation($entity);
  87. }
  88. /**
  89. * Implements hook_toolbar().
  90. */
  91. function devel_toolbar() {
  92. return \Drupal::service('class_resolver')
  93. ->getInstanceFromDefinition(ToolbarHandler::class)
  94. ->toolbar();
  95. }
  96. /**
  97. * Implements hook_menu_links_discovered_alter().
  98. */
  99. function devel_menu_links_discovered_alter(&$links) {
  100. // Conditionally add the Layouts info menu link.
  101. if (\Drupal::moduleHandler()->moduleExists('layout_discovery')) {
  102. $links['devel.layout_info'] = [
  103. 'title' => new TranslatableMarkup('Layouts Info'),
  104. 'route_name' => 'devel.layout_info',
  105. 'description' => new TranslatableMarkup('Overview of layouts available to the site.'),
  106. 'menu_name' => 'devel',
  107. ];
  108. }
  109. }
  110. /**
  111. * Implements hook_local_tasks_alter().
  112. */
  113. function devel_local_tasks_alter(&$local_tasks) {
  114. if (\Drupal::moduleHandler()->moduleExists('toolbar')) {
  115. $local_tasks['devel.toolbar.settings_form'] = [
  116. 'title' => 'Toolbar Settings',
  117. 'base_route' => 'devel.admin_settings',
  118. 'route_name' => 'devel.toolbar.settings_form',
  119. 'class' => LocalTaskDefault::class,
  120. 'options' => [],
  121. ];
  122. }
  123. }
  124. /**
  125. * Sets message.
  126. */
  127. function devel_set_message($msg, $type = NULL) {
  128. if (function_exists('drush_log')) {
  129. drush_log($msg, $type);
  130. }
  131. else {
  132. drupal_set_message($msg, $type, TRUE);
  133. }
  134. }
  135. /**
  136. * Gets error handlers.
  137. */
  138. function devel_get_handlers() {
  139. $error_handlers = \Drupal::config('devel.settings')->get('error_handlers');
  140. if (!empty($error_handlers)) {
  141. unset($error_handlers[DEVEL_ERROR_HANDLER_NONE]);
  142. }
  143. return $error_handlers;
  144. }
  145. /**
  146. * Sets a new error handler or restores the prior one.
  147. */
  148. function devel_set_handler($handlers) {
  149. if (empty($handlers)) {
  150. restore_error_handler();
  151. }
  152. elseif (count($handlers) == 1 && isset($handlers[DEVEL_ERROR_HANDLER_STANDARD])) {
  153. // Do nothing.
  154. }
  155. else {
  156. set_error_handler('backtrace_error_handler');
  157. }
  158. }
  159. /**
  160. * Displays backtrace showing the route of calls to the current error.
  161. *
  162. * @param int $error_level
  163. * The level of the error raised.
  164. * @param string $message
  165. * The error message.
  166. * @param string $filename
  167. * The filename that the error was raised in.
  168. * @param int $line
  169. * The line number the error was raised at.
  170. * @param array $context
  171. * An array that points to the active symbol table at the point the error
  172. * occurred.
  173. */
  174. function backtrace_error_handler($error_level, $message, $filename, $line, $context) {
  175. // Hide stack trace and parameters from unqualified users.
  176. if (!\Drupal::currentUser()->hasPermission('access devel information')) {
  177. // Do what core does in bootstrap.inc and errors.inc.
  178. // (We need to duplicate the core code here rather than calling it
  179. // to avoid having the backtrace_error_handler() on top of the call stack.)
  180. if ($error_level & error_reporting()) {
  181. $types = drupal_error_levels();
  182. list($severity_msg, $severity_level) = $types[$error_level];
  183. $backtrace = debug_backtrace();
  184. $caller = Error::getLastCaller($backtrace);
  185. // We treat recoverable errors as fatal.
  186. _drupal_log_error(array(
  187. '%type' => isset($types[$error_level]) ? $severity_msg : 'Unknown error',
  188. '@message' => $message,
  189. '%function' => $caller['function'],
  190. '%file' => $caller['file'],
  191. '%line' => $caller['line'],
  192. 'severity_level' => $severity_level,
  193. 'backtrace' => $backtrace,
  194. ), $error_level == E_RECOVERABLE_ERROR);
  195. }
  196. return;
  197. }
  198. // Don't respond to the error if it was suppressed with a '@'
  199. if (error_reporting() == 0) {
  200. return;
  201. }
  202. // Don't respond to warning caused by ourselves.
  203. if (preg_match('#Cannot modify header information - headers already sent by \\([^\\)]*[/\\\\]devel[/\\\\]#', $message)) {
  204. return;
  205. }
  206. if ($error_level & error_reporting()) {
  207. // Only write each distinct NOTICE message once, as repeats do not give any
  208. // further information and can choke the page output.
  209. if ($error_level == E_NOTICE) {
  210. static $written = array();
  211. if (!empty($written[$line][$filename][$message])) {
  212. return;
  213. }
  214. $written[$line][$filename][$message] = TRUE;
  215. }
  216. $types = drupal_error_levels();
  217. list($severity_msg, $severity_level) = $types[$error_level];
  218. $backtrace = debug_backtrace();
  219. $caller = Error::getLastCaller($backtrace);
  220. $variables = array(
  221. '%type' => isset($types[$error_level]) ? $severity_msg : 'Unknown error',
  222. '@message' => $message,
  223. '%function' => $caller['function'],
  224. '%file' => $caller['file'],
  225. '%line' => $caller['line'],
  226. );
  227. $msg = t('%type: @message in %function (line %line of %file).', $variables);
  228. // Show message if error_level is ERROR_REPORTING_DISPLAY_SOME or higher.
  229. // (This is Drupal's error_level, which is different from $error_level,
  230. // and we purposely ignore the difference between _SOME and _ALL,
  231. // see #970688!)
  232. if (\Drupal::config('system.logging')->get('error_level') != 'hide') {
  233. $error_handlers = devel_get_handlers();
  234. if (!empty($error_handlers[DEVEL_ERROR_HANDLER_STANDARD])) {
  235. drupal_set_message($msg, ($severity_level <= RfcLogLevel::NOTICE ? 'error' : 'warning'), TRUE);
  236. }
  237. if (!empty($error_handlers[DEVEL_ERROR_HANDLER_BACKTRACE_KINT])) {
  238. print kpr(ddebug_backtrace(TRUE, 1), TRUE, $msg);
  239. }
  240. if (!empty($error_handlers[DEVEL_ERROR_HANDLER_BACKTRACE_DPM])) {
  241. dpm(ddebug_backtrace(TRUE, 1), $msg, 'warning');
  242. }
  243. }
  244. \Drupal::logger('php')->log($severity_level, $msg);
  245. }
  246. }
  247. /**
  248. * Implements hook_page_attachments_alter().
  249. */
  250. function devel_page_attachments_alter(&$page) {
  251. if (\Drupal::currentUser()->hasPermission('access devel information') && \Drupal::config('devel.settings')->get('page_alter')) {
  252. dpm($page, 'page');
  253. }
  254. }
  255. /**
  256. * Wrapper for DevelDumperManager::dump().
  257. *
  258. * Calls the http://www.firephp.org/ fb() function if it is found.
  259. *
  260. * @see \Drupal\devel\DevelDumperManager::dump()
  261. */
  262. function dfb() {
  263. $args = func_get_args();
  264. \Drupal::service('devel.dumper')->dump($args, NULL, 'firephp');
  265. }
  266. /**
  267. * Wrapper for DevelDumperManager::dump().
  268. *
  269. * Calls dfb() to output a backtrace.
  270. *
  271. * @see \Drupal\devel\DevelDumperManager::dump()
  272. */
  273. function dfbt($label) {
  274. \Drupal::service('devel.dumper')->dump(FirePHP::TRACE, $label, 'firephp');
  275. }
  276. /**
  277. * Wrapper for DevelDumperManager::dump().
  278. *
  279. * Wrapper for ChromePHP Class log method.
  280. *
  281. * @see \Drupal\devel\DevelDumperManager::dump()
  282. */
  283. function dcp() {
  284. $args = func_get_args();
  285. \Drupal::service('devel.dumper')->dump($args, NULL, 'chromephp');
  286. }
  287. if (!function_exists('dd')) {
  288. /**
  289. * Wrapper for DevelDumperManager::debug().
  290. *
  291. * @see \Drupal\devel\DevelDumperManager::debug()
  292. */
  293. function dd($data, $label = NULL) {
  294. return \Drupal::service('devel.dumper')->debug($data, $label, 'default');
  295. }
  296. }
  297. /**
  298. * Wrapper for DevelDumperManager::message().
  299. *
  300. * Prints a variable to the 'message' area of the page.
  301. *
  302. * Uses drupal_set_message().
  303. *
  304. * @param $input
  305. * An arbitrary value to output.
  306. * @param string $name
  307. * Optional name for identifying the output.
  308. * @param string $type
  309. * Optional message type for drupal_set_message(), defaults to 'status'.
  310. *
  311. * @return input
  312. * The unaltered input value.
  313. *
  314. * @see \Drupal\devel\DevelDumperManager::message()
  315. */
  316. function dpm($input, $name = NULL, $type = 'status') {
  317. \Drupal::service('devel.dumper')->message($input, $name, $type);
  318. return $input;
  319. }
  320. /**
  321. * Wrapper for DevelDumperManager::message().
  322. *
  323. * Displays a Variable::export() variable to the 'message' area of the page.
  324. *
  325. * Uses drupal_set_message().
  326. *
  327. * @param $input
  328. * An arbitrary value to output.
  329. * @param string $name
  330. * Optional name for identifying the output.
  331. *
  332. * @return input
  333. * The unaltered input value.
  334. *
  335. * @see \Drupal\devel\DevelDumperManager::message()
  336. */
  337. function dvm($input, $name = NULL) {
  338. \Drupal::service('devel.dumper')->message($input, $name, 'status', 'drupal_variable');
  339. return $input;
  340. }
  341. /**
  342. * An alias for dpm(), for historic reasons.
  343. */
  344. function dsm($input, $name = NULL) {
  345. return dpm($input, $name);
  346. }
  347. /**
  348. * Wrapper for DevelDumperManager::dumpOrExport().
  349. *
  350. * An alias for the devel.dumper service. Saves carpal tunnel syndrome.
  351. *
  352. * @see \Drupal\devel\DevelDumperManager::dumpOrExport()
  353. */
  354. function dpr($input, $export = FALSE, $name = NULL) {
  355. return \Drupal::service('devel.dumper')->dumpOrExport($input, $name, $export, 'default');
  356. }
  357. /**
  358. * Wrapper for DevelDumperManager::dumpOrExport().
  359. *
  360. * An alias for devel_dump(). Saves carpal tunnel syndrome.
  361. *
  362. * @see \Drupal\devel\DevelDumperManager::dumpOrExport()
  363. */
  364. function kpr($input, $export = FALSE, $name = NULL) {
  365. return \Drupal::service('devel.dumper')->dumpOrExport($input, $name, $export);
  366. }
  367. /**
  368. * Wrapper for DevelDumperManager::dumpOrExport().
  369. *
  370. * Like dpr(), but uses Variable::export() instead.
  371. *
  372. * @see \Drupal\devel\DevelDumperManager::dumpOrExport()
  373. */
  374. function dvr($input, $export = FALSE, $name = NULL) {
  375. return \Drupal::service('devel.dumper')->dumpOrExport($input, $name, $export, 'drupal_variable');
  376. }
  377. /**
  378. * Prints the arguments passed into the current function.
  379. */
  380. function dargs($always = TRUE) {
  381. static $printed;
  382. if ($always || !$printed) {
  383. $bt = debug_backtrace();
  384. print kpr($bt[1]['args'], TRUE);
  385. $printed = TRUE;
  386. }
  387. }
  388. /**
  389. * Prints a SQL string from a DBTNG Select object. Includes quoted arguments.
  390. *
  391. * @param object $query
  392. * An object that implements the SelectInterface interface.
  393. * @param boolean $return
  394. * Whether to return the string. Default is FALSE, meaning to print it
  395. * and return $query instead.
  396. * @param string $name
  397. * Optional name for identifying the output.
  398. *
  399. * @return object|string
  400. * The $query object, or the query string if $return was TRUE.
  401. */
  402. function dpq($query, $return = FALSE, $name = NULL) {
  403. if (\Drupal::currentUser()->hasPermission('access devel information')) {
  404. if (method_exists($query, 'preExecute')) {
  405. $query->preExecute();
  406. }
  407. $sql = (string) $query;
  408. $quoted = array();
  409. $connection = Database::getConnection();
  410. foreach ((array) $query->arguments() as $key => $val) {
  411. $quoted[$key] = is_null($val) ? 'NULL' : $connection->quote($val);
  412. }
  413. $sql = strtr($sql, $quoted);
  414. if ($return) {
  415. return $sql;
  416. }
  417. dpm($sql, $name);
  418. }
  419. return ($return ? NULL : $query);
  420. }
  421. /**
  422. * Prints a renderable array element to the screen using kprint_r().
  423. *
  424. * #pre_render and/or #post_render pass-through callback for kprint_r().
  425. *
  426. * @todo Investigate appending to #suffix.
  427. * @todo Investigate label derived from #id, #title, #name, and #theme.
  428. */
  429. function devel_render() {
  430. $args = func_get_args();
  431. // #pre_render and #post_render pass the rendered $element as last argument.
  432. kpr(end($args));
  433. // #pre_render and #post_render expect the first argument to be returned.
  434. return reset($args);
  435. }
  436. /**
  437. * Prints the function call stack.
  438. *
  439. * @param $return
  440. * Pass TRUE to return the formatted backtrace rather than displaying it in
  441. * the browser via kprint_r().
  442. * @param $pop
  443. * How many items to pop from the top of the stack; useful when calling from
  444. * an error handler.
  445. * @param $options
  446. * Options to pass on to PHP's debug_backtrace().
  447. *
  448. * @return string|NULL
  449. * The formatted backtrace, if requested, or NULL.
  450. *
  451. * @see http://php.net/manual/en/function.debug-backtrace.php
  452. */
  453. function ddebug_backtrace($return = FALSE, $pop = 0, $options = DEBUG_BACKTRACE_PROVIDE_OBJECT) {
  454. if (\Drupal::currentUser()->hasPermission('access devel information')) {
  455. $backtrace = debug_backtrace($options);
  456. while ($pop-- > 0) {
  457. array_shift($backtrace);
  458. }
  459. $counter = count($backtrace);
  460. $path = $backtrace[$counter - 1]['file'];
  461. $path = substr($path, 0, strlen($path) - 10);
  462. $paths[$path] = strlen($path) + 1;
  463. $paths[DRUPAL_ROOT] = strlen(DRUPAL_ROOT) + 1;
  464. $nbsp = "\xC2\xA0";
  465. // Show message if error_level is ERROR_REPORTING_DISPLAY_SOME or higher.
  466. // (This is Drupal's error_level, which is different from $error_level,
  467. // and we purposely ignore the difference between _SOME and _ALL,
  468. // see #970688!)
  469. if (\Drupal::config('system.logging')->get('error_level') != 'hide') {
  470. while (!empty($backtrace)) {
  471. $call = array();
  472. if (isset($backtrace[0]['file'])) {
  473. $call['file'] = $backtrace[0]['file'];
  474. foreach ($paths as $path => $len) {
  475. if (strpos($backtrace[0]['file'], $path) === 0) {
  476. $call['file'] = substr($backtrace[0]['file'], $len);
  477. }
  478. }
  479. $call['file'] .= ':' . $backtrace[0]['line'];
  480. }
  481. if (isset($backtrace[1])) {
  482. if (isset($backtrace[1]['class'])) {
  483. $function = $backtrace[1]['class'] . $backtrace[1]['type'] . $backtrace[1]['function'] . '()';
  484. }
  485. else {
  486. $function = $backtrace[1]['function'] . '()';
  487. }
  488. $backtrace[1] += array('args' => array());
  489. foreach ($backtrace[1]['args'] as $key => $value) {
  490. $call['args'][$key] = $value;
  491. }
  492. }
  493. else {
  494. $function = 'main()';
  495. $call['args'] = $_GET;
  496. }
  497. $nicetrace[($counter <= 10 ? $nbsp : '') . --$counter . ': ' . $function] = $call;
  498. array_shift($backtrace);
  499. }
  500. if ($return) {
  501. return $nicetrace;
  502. }
  503. kpr($nicetrace);
  504. }
  505. }
  506. }
  507. /**
  508. * Implements hook_form_FORM_ID_alter().
  509. *
  510. * Adds mouse-over hints on the Permissions page to display
  511. * language-independent machine names and module base names.
  512. *
  513. * @see \Drupal\user\Form\UserPermissionsForm::buildForm()
  514. */
  515. function devel_form_user_admin_permissions_alter(&$form, FormStateInterface $form_state) {
  516. if (\Drupal::currentUser()->hasPermission('access devel information') && \Drupal::config('devel.settings')->get('raw_names')) {
  517. foreach (Element::children($form['permissions']) as $key) {
  518. if (isset($form['permissions'][$key][0])) {
  519. $form['permissions'][$key][0]['#wrapper_attributes']['title'] = $key;
  520. }
  521. elseif(isset($form['permissions'][$key]['description'])) {
  522. $form['permissions'][$key]['description']['#wrapper_attributes']['title'] = $key;
  523. }
  524. }
  525. }
  526. }
  527. /**
  528. * Implements hook_form_FORM_ID_alter().
  529. *
  530. * Adds mouse-over hints on the Modules page to display module base names.
  531. *
  532. * @see \Drupal\system\Form\ModulesListForm::buildForm()
  533. * @see theme_system_modules_details()
  534. */
  535. function devel_form_system_modules_alter(&$form, FormStateInterface $form_state) {
  536. if (\Drupal::currentUser()->hasPermission('access devel information') && \Drupal::config('devel.settings')->get('raw_names', FALSE) && isset($form['modules']) && is_array($form['modules'])) {
  537. foreach (Element::children($form['modules']) as $group) {
  538. if (is_array($form['modules'][$group])) {
  539. foreach (Element::children($form['modules'][$group]) as $key) {
  540. if (isset($form['modules'][$group][$key]['name']['#markup'])) {
  541. $form['modules'][$group][$key]['name']['#markup'] = '<span title="' . $key . '">' . $form['modules'][$group][$key]['name']['#markup'] . '</span>';
  542. }
  543. }
  544. }
  545. }
  546. }
  547. }
  548. /**
  549. * Implements hook_query_TAG_alter().
  550. *
  551. * Makes debugging entity query much easier.
  552. *
  553. * Example usage:
  554. * @code
  555. * $query = \Drupal::entityQuery('node');
  556. * $query->condition('status', NODE_PUBLISHED);
  557. * $query->addTag('debug');
  558. * $query->execute();
  559. * @endcode
  560. */
  561. function devel_query_debug_alter(AlterableInterface $query) {
  562. if (!$query->hasTag('debug-semaphore')) {
  563. $query->addTag('debug-semaphore');
  564. dpq($query);
  565. }
  566. }