@@ -33,40 +33,40 @@ discard block |
||
| 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,54 +75,54 @@ discard block |
||
| 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, |
|
| 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 | 87 | ?AMQPStreamConnection $amqpConnection = null |
| 88 | - ): JsonResponse { |
|
| 89 | - $status = [ |
|
| 90 | - 'postgres' => 'red', |
|
| 91 | - 'elasticsearch' => '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['elasticsearch'] = '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 |
|
| 119 | - try { |
|
| 120 | - if ($amqpConnection) { |
|
| 121 | - $amqpConnection->channel(); |
|
| 122 | - $status['rabbitmq'] = 'green'; |
|
| 123 | - } |
|
| 124 | - } catch (\Throwable $e) {} |
|
| 125 | - |
|
| 126 | - return new JsonResponse($status); |
|
| 127 | - } |
|
| 88 | + ): JsonResponse { |
|
| 89 | + $status = [ |
|
| 90 | + 'postgres' => 'red', |
|
| 91 | + 'elasticsearch' => '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['elasticsearch'] = '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 |
|
| 119 | + try { |
|
| 120 | + if ($amqpConnection) { |
|
| 121 | + $amqpConnection->channel(); |
|
| 122 | + $status['rabbitmq'] = 'green'; |
|
| 123 | + } |
|
| 124 | + } catch (\Throwable $e) {} |
|
| 125 | + |
|
| 126 | + return new JsonResponse($status); |
|
| 127 | + } |
|
| 128 | 128 | } |
@@ -109,7 +109,7 @@ |
||
| 109 | 109 | |
| 110 | 110 | // Check Memcached (Symfony Cache) |
| 111 | 111 | try { |
| 112 | - $cacheKey = 'health_check_' . uniqid(); |
|
| 112 | + $cacheKey = 'health_check_'.uniqid(); |
|
| 113 | 113 | $cachePool->save($cachePool->getItem($cacheKey)->set('ok')); |
| 114 | 114 | $cachePool->deleteItem($cacheKey); |
| 115 | 115 | $status['memcached'] = 'green'; |