class DevelController in Devel 8.3
Same name and namespace in other branches
- 8 src/Controller/DevelController.php \Drupal\devel\Controller\DevelController
- 8.2 src/Controller/DevelController.php \Drupal\devel\Controller\DevelController
- 4.x src/Controller/DevelController.php \Drupal\devel\Controller\DevelController
Returns responses for devel module routes.
Hierarchy
- class \Drupal\Core\Controller\ControllerBase implements ContainerInjectionInterface uses LoggerChannelTrait, MessengerTrait, LinkGeneratorTrait, RedirectDestinationTrait, UrlGeneratorTrait, StringTranslationTrait
- class \Drupal\devel\Controller\DevelController
Expanded class hierarchy of DevelController
File
- src/
Controller/ DevelController.php, line 19
Namespace
Drupal\devel\ControllerView source
class DevelController extends ControllerBase {
/**
* The dumper service.
*
* @var \Drupal\devel\DevelDumperManagerInterface
*/
protected $dumper;
/**
* The entity type bundle info service.
*
* @var \Drupal\Core\Entity\EntityTypeBundleInfoInterface
*/
protected $entityTypeBundleInfo;
/**
* The field type plugin manager service.
*
* @var \Drupal\Core\Field\FieldTypePluginManagerInterface
*/
protected $fieldTypeManager;
/**
* The field formatter plugin manager.
*
* @var \Drupal\Core\Field\FormatterPluginManager
*/
protected $formatterPluginManager;
/**
* The field widget plugin manager.
*
* @var \Drupal\Core\Field\WidgetPluginManager
*/
protected $widgetPluginManager;
/**
* EntityDebugController constructor.
*
* @param \Drupal\devel\DevelDumperManagerInterface $dumper
* The dumper service.
* @param \Drupal\Core\Entity\EntityTypeBundleInfoInterface $entity_type_bundle_info
* The entity type bundle info service.
* @param \Drupal\Core\Field\FieldTypePluginManagerInterface $field_type_manager
* The field type manager service.
* @param \Drupal\Core\Field\FormatterPluginManager $formatter_plugin_manager
* The field formatter plugin manager.
* @param \Drupal\Core\Field\WidgetPluginManager $widget_plugin_manager
* The field widget plugin manager.
*/
public function __construct(DevelDumperManagerInterface $dumper, EntityTypeBundleInfoInterface $entity_type_bundle_info, FieldTypePluginManagerInterface $field_type_manager, FormatterPluginManager $formatter_plugin_manager, WidgetPluginManager $widget_plugin_manager) {
$this->dumper = $dumper;
$this->entityTypeBundleInfo = $entity_type_bundle_info;
$this->fieldTypeManager = $field_type_manager;
$this->formatterPluginManager = $formatter_plugin_manager;
$this->widgetPluginManager = $widget_plugin_manager;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static($container
->get('devel.dumper'), $container
->get('entity_type.bundle.info'), $container
->get('plugin.manager.field.field_type'), $container
->get('plugin.manager.field.formatter'), $container
->get('plugin.manager.field.widget'));
}
/**
* Clears all caches, then redirects to the previous page.
*/
public function cacheClear() {
drupal_flush_all_caches();
$this
->messenger()
->addMessage($this
->t('Cache cleared.'));
return $this
->redirect('<front>');
}
/**
* Theme registry.
*
* @return array
* The complete theme registry as renderable.
*/
public function themeRegistry() {
$hooks = theme_get_registry();
ksort($hooks);
return $this->dumper
->exportAsRenderable($hooks);
}
/**
* Builds the fields info overview page.
*
* @return array
* Array of page elements to render.
*/
public function fieldInfoPage() {
$fields = FieldStorageConfig::loadMultiple();
ksort($fields);
$output['fields'] = $this->dumper
->exportAsRenderable($fields, $this
->t('Fields'));
$field_instances = FieldConfig::loadMultiple();
ksort($field_instances);
$output['instances'] = $this->dumper
->exportAsRenderable($field_instances, $this
->t('Instances'));
$bundles = $this->entityTypeBundleInfo
->getAllBundleInfo();
ksort($bundles);
$output['bundles'] = $this->dumper
->exportAsRenderable($bundles, $this
->t('Bundles'));
$field_types = $this->fieldTypeManager
->getUiDefinitions();
ksort($field_types);
$output['field_types'] = $this->dumper
->exportAsRenderable($field_types, $this
->t('Field types'));
$formatter_types = $this->formatterPluginManager
->getDefinitions();
ksort($formatter_types);
$output['formatter_types'] = $this->dumper
->exportAsRenderable($formatter_types, $this
->t('Formatter types'));
$widget_types = $this->widgetPluginManager
->getDefinitions();
ksort($widget_types);
$output['widget_types'] = $this->dumper
->exportAsRenderable($widget_types, $this
->t('Widget types'));
return $output;
}
/**
* Builds the state variable overview page.
*
* @return array
* Array of page elements to render.
*/
public function stateSystemPage() {
$can_edit = $this
->currentUser()
->hasPermission('administer site configuration');
$header = [
'name' => $this
->t('Name'),
'value' => $this
->t('Value'),
];
if ($can_edit) {
$header['edit'] = $this
->t('Operations');
}
$rows = [];
// State class doesn't have getAll method so we get all states from the
// KeyValueStorage.
foreach ($this
->keyValue('state')
->getAll() as $state_name => $state) {
$rows[$state_name] = [
'name' => [
'data' => $state_name,
'class' => 'table-filter-text-source',
],
'value' => [
'data' => $this->dumper
->export($state),
],
];
if ($can_edit) {
$operations['edit'] = [
'title' => $this
->t('Edit'),
'url' => Url::fromRoute('devel.system_state_edit', [
'state_name' => $state_name,
]),
];
$rows[$state_name]['edit'] = [
'data' => [
'#type' => 'operations',
'#links' => $operations,
],
];
}
}
$output['states'] = [
'#type' => 'devel_table_filter',
'#filter_label' => $this
->t('Search'),
'#filter_placeholder' => $this
->t('Enter state name'),
'#filter_title' => $this
->t('Enter a part of the state name to filter by.'),
'#header' => $header,
'#rows' => $rows,
'#empty' => $this
->t('No state variables found.'),
'#attributes' => [
'class' => [
'devel-state-list',
],
],
];
return $output;
}
/**
* Builds the session overview page.
*
* @return array
* Array of page elements to render.
*/
public function session() {
$output['description'] = [
'#markup' => '<p>' . $this
->t('Here are the contents of your $_SESSION variable.') . '</p>',
];
$output['session'] = [
'#type' => 'table',
'#header' => [
$this
->t('Session name'),
$this
->t('Session ID'),
],
'#rows' => [
[
session_name(),
session_id(),
],
],
'#empty' => $this
->t('No session available.'),
];
$output['data'] = $this->dumper
->exportAsRenderable($_SESSION);
return $output;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ControllerBase:: |
protected | property | The configuration factory. | |
ControllerBase:: |
protected | property | The current user service. | 1 |
ControllerBase:: |
protected | property | The entity form builder. | |
ControllerBase:: |
protected | property | The entity manager. | |
ControllerBase:: |
protected | property | The entity type manager. | |
ControllerBase:: |
protected | property | The form builder. | 2 |
ControllerBase:: |
protected | property | The key-value storage. | 1 |
ControllerBase:: |
protected | property | The language manager. | 1 |
ControllerBase:: |
protected | property | The module handler. | 2 |
ControllerBase:: |
protected | property | The state service. | |
ControllerBase:: |
protected | function | Returns the requested cache bin. | |
ControllerBase:: |
protected | function | Retrieves a configuration object. | |
ControllerBase:: |
private | function | Returns the service container. | |
ControllerBase:: |
protected | function | Returns the current user. | 1 |
ControllerBase:: |
protected | function | Retrieves the entity form builder. | |
ControllerBase:: |
protected | function | Retrieves the entity manager service. | |
ControllerBase:: |
protected | function | Retrieves the entity type manager. | |
ControllerBase:: |
protected | function | Returns the form builder service. | 2 |
ControllerBase:: |
protected | function | Returns a key/value storage collection. | 1 |
ControllerBase:: |
protected | function | Returns the language manager service. | 1 |
ControllerBase:: |
protected | function | Returns the module handler. | 2 |
ControllerBase:: |
protected | function |
Returns a redirect response object for the specified route. Overrides UrlGeneratorTrait:: |
|
ControllerBase:: |
protected | function | Returns the state storage service. | |
DevelController:: |
protected | property | The dumper service. | |
DevelController:: |
protected | property | The entity type bundle info service. | |
DevelController:: |
protected | property | The field type plugin manager service. | |
DevelController:: |
protected | property | The field formatter plugin manager. | |
DevelController:: |
protected | property | The field widget plugin manager. | |
DevelController:: |
public | function | Clears all caches, then redirects to the previous page. | |
DevelController:: |
public static | function |
Instantiates a new instance of this class. Overrides ControllerBase:: |
|
DevelController:: |
public | function | Builds the fields info overview page. | |
DevelController:: |
public | function | Builds the session overview page. | |
DevelController:: |
public | function | Builds the state variable overview page. | |
DevelController:: |
public | function | Theme registry. | |
DevelController:: |
public | function | EntityDebugController constructor. | |
LinkGeneratorTrait:: |
protected | property | The link generator. | 1 |
LinkGeneratorTrait:: |
protected | function | Returns the link generator. | |
LinkGeneratorTrait:: |
protected | function | Renders a link to a route given a route name and its parameters. | |
LinkGeneratorTrait:: |
public | function | Sets the link generator service. | |
LoggerChannelTrait:: |
protected | property | The logger channel factory service. | |
LoggerChannelTrait:: |
protected | function | Gets the logger for a specific channel. | |
LoggerChannelTrait:: |
public | function | Injects the logger channel factory. | |
MessengerTrait:: |
protected | property | The messenger. | 29 |
MessengerTrait:: |
public | function | Gets the messenger. | 29 |
MessengerTrait:: |
public | function | Sets the messenger. | |
RedirectDestinationTrait:: |
protected | property | The redirect destination service. | 1 |
RedirectDestinationTrait:: |
protected | function | Prepares a 'destination' URL query parameter for use with \Drupal\Core\Url. | |
RedirectDestinationTrait:: |
protected | function | Returns the redirect destination service. | |
RedirectDestinationTrait:: |
public | function | Sets the redirect destination service. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. | |
UrlGeneratorTrait:: |
protected | property | The url generator. | |
UrlGeneratorTrait:: |
protected | function | Returns the URL generator service. | |
UrlGeneratorTrait:: |
public | function | Sets the URL generator service. | |
UrlGeneratorTrait:: |
protected | function | Generates a URL or path for a specific route based on the given parameters. |