3 namespace Drupal\devel\Controller;
5 use Drupal\Core\Controller\ControllerBase;
7 use Drupal\devel\DevelDumperManagerInterface;
8 use Drupal\field\Entity\FieldConfig;
9 use Drupal\field\Entity\FieldStorageConfig;
10 use Symfony\Component\DependencyInjection\ContainerInterface;
13 * Returns responses for devel module routes.
15 class DevelController extends ControllerBase {
20 * @var \Drupal\devel\DevelDumperManagerInterface
25 * EntityDebugController constructor.
27 * @param \Drupal\devel\DevelDumperManagerInterface $dumper
30 public function __construct(DevelDumperManagerInterface $dumper) {
31 $this->dumper = $dumper;
37 public static function create(ContainerInterface $container) {
38 return new static($container->get('devel.dumper'));
42 * Clears all caches, then redirects to the previous page.
44 public function cacheClear() {
45 drupal_flush_all_caches();
46 drupal_set_message('Cache cleared.');
47 return $this->redirect('<front>');
50 public function themeRegistry() {
51 $hooks = theme_get_registry();
53 return $this->dumper->exportAsRenderable($hooks);
57 * Builds the fields info overview page.
60 * Array of page elements to render.
62 public function fieldInfoPage() {
63 $fields = FieldStorageConfig::loadMultiple();
65 $output['fields'] = $this->dumper->exportAsRenderable($fields, $this->t('Fields'));
67 $field_instances = FieldConfig::loadMultiple();
68 ksort($field_instances);
69 $output['instances'] = $this->dumper->exportAsRenderable($field_instances, $this->t('Instances'));
71 $bundles = \Drupal::service('entity_type.bundle.info')->getAllBundleInfo();
73 $output['bundles'] = $this->dumper->exportAsRenderable($bundles, $this->t('Bundles'));
75 $field_types = \Drupal::service('plugin.manager.field.field_type')->getUiDefinitions();
77 $output['field_types'] = $this->dumper->exportAsRenderable($field_types, $this->t('Field types'));
79 $formatter_types = \Drupal::service('plugin.manager.field.formatter')->getDefinitions();
80 ksort($formatter_types);
81 $output['formatter_types'] = $this->dumper->exportAsRenderable($formatter_types, $this->t('Formatter types'));
83 $widget_types = \Drupal::service('plugin.manager.field.widget')->getDefinitions();
85 $output['widget_types'] = $this->dumper->exportAsRenderable($widget_types, $this->t('Widget types'));
91 * Builds the state variable overview page.
94 * Array of page elements to render.
96 public function stateSystemPage() {
97 $output['#attached']['library'][] = 'system/drupal.system.modules';
99 $output['filters'] = array(
100 '#type' => 'container',
101 '#attributes' => array(
102 'class' => array('table-filter', 'js-show'),
106 $output['filters']['text'] = array(
108 '#title' => $this->t('Search'),
110 '#placeholder' => $this->t('Enter state name'),
111 '#attributes' => array(
112 'class' => array('table-filter-text'),
113 'data-table' => '.devel-state-list',
114 'autocomplete' => 'off',
115 'title' => $this->t('Enter a part of the state name to filter by.'),
119 $can_edit = $this->currentUser()->hasPermission('administer site configuration');
122 'name' => $this->t('Name'),
123 'value' => $this->t('Value'),
127 $header['edit'] = $this->t('Operations');
131 // State class doesn't have getAll method so we get all states from the
133 foreach ($this->keyValue('state')->getAll() as $state_name => $state) {
134 $rows[$state_name] = array(
136 'data' => $state_name,
137 'class' => 'table-filter-text-source',
140 'data' => $this->dumper->export($state),
145 $operations['edit'] = array(
146 'title' => $this->t('Edit'),
147 'url' => Url::fromRoute('devel.system_state_edit', array('state_name' => $state_name)),
149 $rows[$state_name]['edit'] = array(
150 'data' => array('#type' => 'operations', '#links' => $operations),
155 $output['states'] = array(
157 '#header' => $header,
159 '#empty' => $this->t('No state variables found.'),
160 '#attributes' => array(
161 'class' => array('devel-state-list'),
169 * Builds the session overview page.
172 * Array of page elements to render.
174 public function session() {
175 $output['description'] = array(
176 '#markup' => '<p>' . $this->t('Here are the contents of your $_SESSION variable.') . '</p>',
178 $output['session'] = array(
180 '#header' => array($this->t('Session name'), $this->t('Session ID')),
181 '#rows' => array(array(session_name(), session_id())),
182 '#empty' => $this->t('No session available.'),
184 $output['data'] = $this->dumper->exportAsRenderable($_SESSION);