Completed
Push — health ( c6daf1...c68fc0 )
by
unknown
42s
created
src/SWP/Bundle/CoreBundle/Controller/DefaultController.php 1 patch
Indentation   +81 added lines, -81 removed lines patch added patch discarded remove patch
@@ -33,40 +33,40 @@  discard block
 block discarded – undo
33 33
 
34 34
 class DefaultController extends AbstractController {
35 35
 
36
-  private CachedTenantContextInterface $tenantContext;
37
-  private MetaFactoryInterface $metaFactory;
38
-  private Context $templateEngineContext;
39
-  private RouteFactoryInterface $routeFactory;
40
-
41
-  public function __construct(
42
-      CachedTenantContextInterface $tenantContext,
43
-      MetaFactoryInterface         $metaFactory,
44
-      Context                      $templateEngineContext,
45
-      RouteFactoryInterface        $routeFactory
46
-  ) {
36
+    private CachedTenantContextInterface $tenantContext;
37
+    private MetaFactoryInterface $metaFactory;
38
+    private Context $templateEngineContext;
39
+    private RouteFactoryInterface $routeFactory;
40
+
41
+    public function __construct(
42
+        CachedTenantContextInterface $tenantContext,
43
+        MetaFactoryInterface         $metaFactory,
44
+        Context                      $templateEngineContext,
45
+        RouteFactoryInterface        $routeFactory
46
+    ) {
47 47
     $this->tenantContext = $tenantContext;
48 48
     $this->metaFactory = $metaFactory;
49 49
     $this->templateEngineContext = $templateEngineContext;
50 50
     $this->routeFactory = $routeFactory;
51
-  }
51
+    }
52 52
 
53
-  /**
54
-   * @Route("/", methods={"GET","POST"}, name="homepage")
55
-   */
56
-  public function indexAction(Request $request): Response {
53
+    /**
54
+     * @Route("/", methods={"GET","POST"}, name="homepage")
55
+     */
56
+    public function indexAction(Request $request): Response {
57 57
     /** @var TenantInterface $currentTenant */
58 58
     $currentTenant = $this->tenantContext->getTenant();
59 59
     $route = $currentTenant->getHomepage();
60 60
 
61 61
     if (null === $route) {
62
-      /** @var RouteInterface $route */
63
-      $route = $this->routeFactory->create();
64
-      $route->setStaticPrefix('/');
65
-      $route->setName('Homepage');
66
-      $route->setType('content');
67
-      $route->setTemplateName('index.html.twig');
68
-      $route->setCacheTimeInSeconds(360);
69
-      $request->attributes->set(DynamicRouter::ROUTE_KEY, $route);
62
+        /** @var RouteInterface $route */
63
+        $route = $this->routeFactory->create();
64
+        $route->setStaticPrefix('/');
65
+        $route->setName('Homepage');
66
+        $route->setType('content');
67
+        $route->setTemplateName('index.html.twig');
68
+        $route->setCacheTimeInSeconds(360);
69
+        $request->attributes->set(DynamicRouter::ROUTE_KEY, $route);
70 70
     }
71 71
 
72 72
     $this->templateEngineContext->setCurrentPage($this->metaFactory->create($route));
@@ -75,61 +75,61 @@  discard block
 block discarded – undo
75 75
     $response->headers->set('Content-Type', 'text/html; charset=UTF-8');
76 76
 
77 77
     return $this->render('index.html.twig', [], $response);
78
-  }
79
-
80
-  /**
81
-   * @Route("/api/system/health", methods={"GET"}, name="system_health")
82
-   */
83
-  public function healthCheck(
84
-      Connection $connection,
85
-      ElasticaClient $elasticaClient,
86
-      AdapterInterface $cachePool
87
-  ): JsonResponse {
88
-      $status = [
89
-          'application_name' => 'Publisher',
90
-          'postgres' => 'red',
91
-          'elastic' => 'red',
92
-          'memcached' => 'red',
93
-          'rabbitmq' => 'red',
94
-      ];
95
-
96
-      // Check Postgres
97
-      try {
98
-          $connection->connect();
99
-          if ($connection->isConnected()) {
100
-              $status['postgres'] = 'green';
101
-          }
102
-      } catch (\Throwable $e) {}
103
-
104
-      // Check Elasticsearch
105
-      try {
106
-          $elasticaClient->getStatus();
107
-          $status['elastic'] = 'green';
108
-      } catch (\Throwable $e) {}
109
-
110
-      // Check Memcached (Symfony Cache)
111
-      try {
112
-          $cacheKey = 'health_check_' . uniqid();
113
-          $cachePool->save($cachePool->getItem($cacheKey)->set('ok'));
114
-          $cachePool->deleteItem($cacheKey);
115
-          $status['memcached'] = 'green';
116
-      } catch (\Throwable $e) {}
117
-
118
-      // Check RabbitMQ using php-amqp extension
119
-      try {
120
-          $amqp = new \AMQPConnection([
121
-              'host'     => $_ENV['RABBIT_MQ_HOST'] ?? 'localhost',
122
-              'port'     => $_ENV['RABBIT_MQ_PORT'] ?? 5672,
123
-              'login'    => $_ENV['RABBIT_MQ_USER'] ?? 'guest',
124
-              'password' => $_ENV['RABBIT_MQ_PASSWORD'] ?? 'guest',
125
-              'vhost'    => $_ENV['RABBIT_MQ_VHOST'] ?? '/',
126
-          ]);
127
-          $amqp->connect();
128
-          if ($amqp->isConnected()) {
129
-              $status['rabbitmq'] = 'green';
130
-          }
131
-      } catch (\Throwable $e) {}
132
-
133
-      return new JsonResponse($status);
134
-  }
78
+    }
79
+
80
+    /**
81
+     * @Route("/api/system/health", methods={"GET"}, name="system_health")
82
+     */
83
+    public function healthCheck(
84
+        Connection $connection,
85
+        ElasticaClient $elasticaClient,
86
+        AdapterInterface $cachePool
87
+    ): JsonResponse {
88
+        $status = [
89
+            'application_name' => 'Publisher',
90
+            'postgres' => 'red',
91
+            'elastic' => 'red',
92
+            'memcached' => 'red',
93
+            'rabbitmq' => 'red',
94
+        ];
95
+
96
+        // Check Postgres
97
+        try {
98
+            $connection->connect();
99
+            if ($connection->isConnected()) {
100
+                $status['postgres'] = 'green';
101
+            }
102
+        } catch (\Throwable $e) {}
103
+
104
+        // Check Elasticsearch
105
+        try {
106
+            $elasticaClient->getStatus();
107
+            $status['elastic'] = 'green';
108
+        } catch (\Throwable $e) {}
109
+
110
+        // Check Memcached (Symfony Cache)
111
+        try {
112
+            $cacheKey = 'health_check_' . uniqid();
113
+            $cachePool->save($cachePool->getItem($cacheKey)->set('ok'));
114
+            $cachePool->deleteItem($cacheKey);
115
+            $status['memcached'] = 'green';
116
+        } catch (\Throwable $e) {}
117
+
118
+        // Check RabbitMQ using php-amqp extension
119
+        try {
120
+            $amqp = new \AMQPConnection([
121
+                'host'     => $_ENV['RABBIT_MQ_HOST'] ?? 'localhost',
122
+                'port'     => $_ENV['RABBIT_MQ_PORT'] ?? 5672,
123
+                'login'    => $_ENV['RABBIT_MQ_USER'] ?? 'guest',
124
+                'password' => $_ENV['RABBIT_MQ_PASSWORD'] ?? 'guest',
125
+                'vhost'    => $_ENV['RABBIT_MQ_VHOST'] ?? '/',
126
+            ]);
127
+            $amqp->connect();
128
+            if ($amqp->isConnected()) {
129
+                $status['rabbitmq'] = 'green';
130
+            }
131
+        } catch (\Throwable $e) {}
132
+
133
+        return new JsonResponse($status);
134
+    }
135 135
 }
Please login to merge, or discard this patch.