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