Same name and namespace in other branches
  1. 8.9.x core/modules/system/src/Controller/SystemInfoController.php \Drupal\system\Controller\SystemInfoController
  2. 9 core/modules/system/src/Controller/SystemInfoController.php \Drupal\system\Controller\SystemInfoController

Returns responses for System Info routes.

Hierarchy

Expanded class hierarchy of SystemInfoController

File

core/modules/system/src/Controller/SystemInfoController.php, line 15

Namespace

Drupal\system\Controller
View source
class SystemInfoController implements ContainerInjectionInterface {
  use StringTranslationTrait;

  /**
   * System Manager Service.
   *
   * @var \Drupal\system\SystemManager
   */
  protected $systemManager;

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

  /**
   * Constructs a SystemInfoController object.
   *
   * @param \Drupal\system\SystemManager $systemManager
   *   System manager service.
   */
  public function __construct(SystemManager $systemManager) {
    $this->systemManager = $systemManager;
  }

  /**
   * Displays the site status report.
   *
   * @return array
   *   A render array containing a list of system requirements for the Drupal
   *   installation and whether this installation meets the requirements.
   */
  public function status() {
    $requirements = $this->systemManager
      ->listRequirements();
    return [
      '#type' => 'status_report_page',
      '#requirements' => $requirements,
    ];
  }

  /**
   * Returns the contents of phpinfo().
   *
   * @return \Symfony\Component\HttpFoundation\Response
   *   A response object to be sent to the client.
   */
  public function php() {
    if (function_exists('phpinfo')) {
      ob_start();
      $phpinfo_flags = Settings::get('sa_core_2023_004_phpinfo_flags', ~(INFO_VARIABLES | INFO_ENVIRONMENT));
      phpinfo($phpinfo_flags);
      $output = ob_get_clean();
    }
    else {
      $output = $this
        ->t('The phpinfo() function is disabled. For more information, visit the <a href=":phpinfo">Enabling and disabling phpinfo()</a> handbook page.', [
        ':phpinfo' => 'https://www.drupal.org/node/243993',
      ]);
    }
    return new Response($output);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
StringTranslationTrait::$stringTranslation protected property The string translation service. 3
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. 1
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.
SystemInfoController::$systemManager protected property System Manager Service.
SystemInfoController::create public static function Instantiates a new instance of this class. Overrides ContainerInjectionInterface::create
SystemInfoController::php public function Returns the contents of phpinfo().
SystemInfoController::status public function Displays the site status report.
SystemInfoController::__construct public function Constructs a SystemInfoController object.