SystemInfoController.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. namespace Drupal\system\Controller;
  3. use Symfony\Component\DependencyInjection\ContainerInterface;
  4. use Symfony\Component\HttpFoundation\Response;
  5. use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
  6. use Drupal\system\SystemManager;
  7. /**
  8. * Returns responses for System Info routes.
  9. */
  10. class SystemInfoController implements ContainerInjectionInterface {
  11. /**
  12. * System Manager Service.
  13. *
  14. * @var \Drupal\system\SystemManager
  15. */
  16. protected $systemManager;
  17. /**
  18. * {@inheritdoc}
  19. */
  20. public static function create(ContainerInterface $container) {
  21. return new static(
  22. $container->get('system.manager')
  23. );
  24. }
  25. /**
  26. * Constructs a SystemInfoController object.
  27. *
  28. * @param \Drupal\system\SystemManager $systemManager
  29. * System manager service.
  30. */
  31. public function __construct(SystemManager $systemManager) {
  32. $this->systemManager = $systemManager;
  33. }
  34. /**
  35. * Displays the site status report.
  36. *
  37. * @return array
  38. * A render array containing a list of system requirements for the Drupal
  39. * installation and whether this installation meets the requirements.
  40. */
  41. public function status() {
  42. $requirements = $this->systemManager->listRequirements();
  43. return ['#type' => 'status_report_page', '#requirements' => $requirements];
  44. }
  45. /**
  46. * Returns the contents of phpinfo().
  47. *
  48. * @return \Symfony\Component\HttpFoundation\Response
  49. * A response object to be sent to the client.
  50. */
  51. public function php() {
  52. if (function_exists('phpinfo')) {
  53. ob_start();
  54. phpinfo();
  55. $output = ob_get_clean();
  56. }
  57. else {
  58. $output = t('The phpinfo() function has been disabled for security reasons. For more information, visit <a href=":phpinfo">Enabling and disabling phpinfo()</a> handbook page.', [':phpinfo' => 'https://www.drupal.org/node/243993']);
  59. }
  60. return new Response($output);
  61. }
  62. }