Version 1
[yaffs-website] / web / core / modules / system / src / Controller / SystemInfoController.php
1 <?php
2
3 namespace Drupal\system\Controller;
4
5 use Symfony\Component\DependencyInjection\ContainerInterface;
6 use Symfony\Component\HttpFoundation\Response;
7 use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
8 use Drupal\system\SystemManager;
9
10 /**
11  * Returns responses for System Info routes.
12  */
13 class SystemInfoController implements ContainerInjectionInterface {
14
15   /**
16    * System Manager Service.
17    *
18    * @var \Drupal\system\SystemManager
19    */
20   protected $systemManager;
21
22   /**
23    * {@inheritdoc}
24    */
25   public static function create(ContainerInterface $container) {
26     return new static(
27       $container->get('system.manager')
28     );
29   }
30
31   /**
32    * Constructs a SystemInfoController object.
33    *
34    * @param \Drupal\system\SystemManager $systemManager
35    *   System manager service.
36    */
37   public function __construct(SystemManager $systemManager) {
38     $this->systemManager = $systemManager;
39   }
40
41   /**
42    * Displays the site status report.
43    *
44    * @return array
45    *   A render array containing a list of system requirements for the Drupal
46    *   installation and whether this installation meets the requirements.
47    */
48   public function status() {
49     $requirements = $this->systemManager->listRequirements();
50     return ['#type' => 'status_report_page', '#requirements' => $requirements];
51   }
52
53   /**
54    * Returns the contents of phpinfo().
55    *
56    * @return \Symfony\Component\HttpFoundation\Response
57    *   A response object to be sent to the client.
58    */
59   public function php() {
60     if (function_exists('phpinfo')) {
61       ob_start();
62       phpinfo();
63       $output = ob_get_clean();
64     }
65     else {
66       $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']);
67     }
68     return new Response($output);
69   }
70
71 }