You are here

class DevelController in Devel 8

Same name and namespace in other branches
  1. 8.3 src/Controller/DevelController.php \Drupal\devel\Controller\DevelController
  2. 8.2 src/Controller/DevelController.php \Drupal\devel\Controller\DevelController
  3. 4.x src/Controller/DevelController.php \Drupal\devel\Controller\DevelController

Returns responses for devel module routes.

Hierarchy

Expanded class hierarchy of DevelController

File

src/Controller/DevelController.php, line 15

Namespace

Drupal\devel\Controller
View source
class DevelController extends ControllerBase {

  /**
   * The dumper service.
   *
   * @var \Drupal\devel\DevelDumperManagerInterface
   */
  protected $dumper;

  /**
   * EntityDebugController constructor.
   *
   * @param \Drupal\devel\DevelDumperManagerInterface $dumper
   *   The dumper service.
   */
  public function __construct(DevelDumperManagerInterface $dumper) {
    $this->dumper = $dumper;
  }

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container) {
    return new static($container
      ->get('devel.dumper'));
  }

  /**
   * Clears all caches, then redirects to the previous page.
   */
  public function cacheClear() {
    drupal_flush_all_caches();
    drupal_set_message('Cache cleared.');
    return $this
      ->redirect('<front>');
  }
  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 = \Drupal::service('entity_type.bundle.info')
      ->getAllBundleInfo();
    ksort($bundles);
    $output['bundles'] = $this->dumper
      ->exportAsRenderable($bundles, $this
      ->t('Bundles'));
    $field_types = \Drupal::service('plugin.manager.field.field_type')
      ->getUiDefinitions();
    ksort($field_types);
    $output['field_types'] = $this->dumper
      ->exportAsRenderable($field_types, $this
      ->t('Field types'));
    $formatter_types = \Drupal::service('plugin.manager.field.formatter')
      ->getDefinitions();
    ksort($formatter_types);
    $output['formatter_types'] = $this->dumper
      ->exportAsRenderable($formatter_types, $this
      ->t('Formatter types'));
    $widget_types = \Drupal::service('plugin.manager.field.widget')
      ->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() {
    $output['#attached']['library'][] = 'system/drupal.system.modules';
    $output['filters'] = array(
      '#type' => 'container',
      '#attributes' => array(
        'class' => array(
          'table-filter',
          'js-show',
        ),
      ),
    );
    $output['filters']['text'] = array(
      '#type' => 'search',
      '#title' => $this
        ->t('Search'),
      '#size' => 30,
      '#placeholder' => $this
        ->t('Enter state name'),
      '#attributes' => array(
        'class' => array(
          'table-filter-text',
        ),
        'data-table' => '.devel-state-list',
        'autocomplete' => 'off',
        'title' => $this
          ->t('Enter a part of the state name to filter by.'),
      ),
    );
    $can_edit = $this
      ->currentUser()
      ->hasPermission('administer site configuration');
    $header = array(
      'name' => $this
        ->t('Name'),
      'value' => $this
        ->t('Value'),
    );
    if ($can_edit) {
      $header['edit'] = $this
        ->t('Operations');
    }
    $rows = array();

    // 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] = array(
        'name' => array(
          'data' => $state_name,
          'class' => 'table-filter-text-source',
        ),
        'value' => array(
          'data' => $this->dumper
            ->export($state),
        ),
      );
      if ($can_edit) {
        $operations['edit'] = array(
          'title' => $this
            ->t('Edit'),
          'url' => Url::fromRoute('devel.system_state_edit', array(
            'state_name' => $state_name,
          )),
        );
        $rows[$state_name]['edit'] = array(
          'data' => array(
            '#type' => 'operations',
            '#links' => $operations,
          ),
        );
      }
    }
    $output['states'] = array(
      '#type' => 'table',
      '#header' => $header,
      '#rows' => $rows,
      '#empty' => $this
        ->t('No state variables found.'),
      '#attributes' => array(
        'class' => array(
          'devel-state-list',
        ),
      ),
    );
    return $output;
  }

  /**
   * Builds the session overview page.
   *
   * @return array
   *   Array of page elements to render.
   */
  public function session() {
    $output['description'] = array(
      '#markup' => '<p>' . $this
        ->t('Here are the contents of your $_SESSION variable.') . '</p>',
    );
    $output['session'] = array(
      '#type' => 'table',
      '#header' => array(
        $this
          ->t('Session name'),
        $this
          ->t('Session ID'),
      ),
      '#rows' => array(
        array(
          session_name(),
          session_id(),
        ),
      ),
      '#empty' => $this
        ->t('No session available.'),
    );
    $output['data'] = $this->dumper
      ->exportAsRenderable($_SESSION);
    return $output;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ControllerBase::$configFactory protected property The configuration factory.
ControllerBase::$currentUser protected property The current user service. 1
ControllerBase::$entityFormBuilder protected property The entity form builder.
ControllerBase::$entityManager protected property The entity manager.
ControllerBase::$entityTypeManager protected property The entity type manager.
ControllerBase::$formBuilder protected property The form builder. 2
ControllerBase::$keyValue protected property The key-value storage. 1
ControllerBase::$languageManager protected property The language manager. 1
ControllerBase::$moduleHandler protected property The module handler. 2
ControllerBase::$stateService protected property The state service.
ControllerBase::cache protected function Returns the requested cache bin.
ControllerBase::config protected function Retrieves a configuration object.
ControllerBase::container private function Returns the service container.
ControllerBase::currentUser protected function Returns the current user. 1
ControllerBase::entityFormBuilder protected function Retrieves the entity form builder.
ControllerBase::entityManager Deprecated protected function Retrieves the entity manager service.
ControllerBase::entityTypeManager protected function Retrieves the entity type manager.
ControllerBase::formBuilder protected function Returns the form builder service. 2
ControllerBase::keyValue protected function Returns a key/value storage collection. 1
ControllerBase::languageManager protected function Returns the language manager service. 1
ControllerBase::moduleHandler protected function Returns the module handler. 2
ControllerBase::redirect protected function Returns a redirect response object for the specified route. Overrides UrlGeneratorTrait::redirect
ControllerBase::state protected function Returns the state storage service.
DevelController::$dumper protected property The dumper service.
DevelController::cacheClear public function Clears all caches, then redirects to the previous page.
DevelController::create public static function Instantiates a new instance of this class. Overrides ControllerBase::create
DevelController::fieldInfoPage public function Builds the fields info overview page.
DevelController::session public function Builds the session overview page.
DevelController::stateSystemPage public function Builds the state variable overview page.
DevelController::themeRegistry public function
DevelController::__construct public function EntityDebugController constructor.
LinkGeneratorTrait::$linkGenerator protected property The link generator. 1
LinkGeneratorTrait::getLinkGenerator Deprecated protected function Returns the link generator.
LinkGeneratorTrait::l Deprecated protected function Renders a link to a route given a route name and its parameters.
LinkGeneratorTrait::setLinkGenerator Deprecated public function Sets the link generator service.
LoggerChannelTrait::$loggerFactory protected property The logger channel factory service.
LoggerChannelTrait::getLogger protected function Gets the logger for a specific channel.
LoggerChannelTrait::setLoggerFactory public function Injects the logger channel factory.
MessengerTrait::$messenger protected property The messenger. 29
MessengerTrait::messenger public function Gets the messenger. 29
MessengerTrait::setMessenger public function Sets the messenger.
RedirectDestinationTrait::$redirectDestination protected property The redirect destination service. 1
RedirectDestinationTrait::getDestinationArray protected function Prepares a 'destination' URL query parameter for use with \Drupal\Core\Url.
RedirectDestinationTrait::getRedirectDestination protected function Returns the redirect destination service.
RedirectDestinationTrait::setRedirectDestination public function Sets the redirect destination service.
StringTranslationTrait::$stringTranslation protected property The string translation service. 1
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.
UrlGeneratorTrait::$urlGenerator protected property The url generator.
UrlGeneratorTrait::getUrlGenerator Deprecated protected function Returns the URL generator service.
UrlGeneratorTrait::setUrlGenerator Deprecated public function Sets the URL generator service.
UrlGeneratorTrait::url Deprecated protected function Generates a URL or path for a specific route based on the given parameters.