main/core/Listener/PlatformListener.php
public function checkAvailability(GetResponseEvent $event)
    {
        if ('prod' === $this->kernel->getEnvironment() && $event->isMasterRequest()) {
            $isAdmin = false;

            $token = $this->tokenStorage->getToken();
            if ($token) {
                foreach ($token->getRoles() as $role) {
                    if ('ROLE_ADMIN' === $role->getRole()) {
                        $isAdmin = true;
                        break;
                    }
                }
            }

            $now = time();
            if (is_int($this->config->getParameter('platform_init_date'))) {
                $minDate = new \DateTime();
                $minDate->setTimestamp($this->config->getParameter('platform_init_date'));
            } else {
                $minDate = new \DateTime($this->config->getParameter('platform_init_date'));
            }

            if (is_int($this->config->getParameter('platform_limit_date'))) {
                $minDate = new \DateTime();
                $minDate->setTimestamp($this->config->getParameter('platform_limit_date'));
            } else {
                $expirationDate = new \DateTime($this->config->getParameter('platform_limit_date'));
            }

            if (!$isAdmin &&
                !in_array($event->getRequest()->get('_route'), static::PUBLIC_ROUTES) &&
                ($minDate->getTimeStamp() > $now || $now > $expirationDate->getTimeStamp())
            ) {
                throw new HttpException(503, 'Platform is not available.');
            }
        }
    }
public function checkAvailability(GetResponseEvent $event)
    {
        if ('prod' === $this->kernel->getEnvironment() && $event->isMasterRequest()) {
            $isAdmin = false;

            $token = $this->tokenStorage->getToken();
            if ($token) {
                foreach ($token->getRoles() as $role) {
                    if ('ROLE_ADMIN' === $role->getRole()) {
                        $isAdmin = true;
                        break;
                    }
                }
            }

            $now = time();
            if (is_int($this->config->getParameter('platform_init_date'))) {
                $minDate = new \DateTime();
                $minDate->setTimestamp($this->config->getParameter('platform_init_date'));
            } else {
                $minDate = new \DateTime($this->config->getParameter('platform_init_date'));
            }

            if (is_int($this->config->getParameter('platform_limit_date'))) {
                $minDate = new \DateTime();
                $minDate->setTimestamp($this->config->getParameter('platform_limit_date'));
            } else {
                $expirationDate = new \DateTime($this->config->getParameter('platform_limit_date'));
            }

            if (!$isAdmin &&
                !in_array($event->getRequest()->get('_route'), static::PUBLIC_ROUTES) &&
                ($minDate->getTimeStamp() > $now || $now > $expirationDate->getTimeStamp())
            ) {
                throw new HttpException(503, 'Platform is not available.');
            }
        }
    }
public function checkAvailability ( GetResponseEvent $ event ) { if ( 'prod' === $ this -> kernel -> getEnvironment ( ) && $ event -> isMasterRequest ( ) ) { $ isAdmin = false ; $ token = $ this -> tokenStorage -> getToken ( ) ; if ( $ token ) { foreach ( $ token -> getRoles ( ) as $ role ) { if ( 'ROLE_ADMIN' === $ role -> getRole ( ) ) { $ isAdmin = true ; break ; } } } $ now = time ( ) ; if ( is_int ( $ this -> config -> getParameter ( 'platform_init_date' ) ) ) { $ minDate = new \ DateTime ( ) ; $ minDate -> setTimestamp ( $ this -> config -> getParameter ( 'platform_init_date' ) ) ; } else { $ minDate = new \ DateTime ( $ this -> config -> getParameter ( 'platform_init_date' ) ) ; } if ( is_int ( $ this -> config -> getParameter ( 'platform_limit_date' ) ) ) { $ minDate = new \ DateTime ( ) ; $ minDate -> setTimestamp ( $ this -> config -> getParameter ( 'platform_limit_date' ) ) ; } else { $ expirationDate = new \ DateTime ( $ this -> config -> getParameter ( 'platform_limit_date' ) ) ; } if ( ! $ isAdmin && ! in_array ( $ event -> getRequest ( ) -> get ( '_route' ) , static :: PUBLIC_ROUTES ) && ( $ minDate -> getTimeStamp ( ) > $ now || $ now > $ expirationDate -> getTimeStamp ( ) ) ) { throw new HttpException ( 503 , 'Platform is not available.' ) ; } } }
Checks the app availability before displaying the platform.
- Checks are enabled only on productions.
- Administrators are always granted.
- Public routes are still accessible.

@DI\Observe("kernel.request")

@param GetResponseEvent $event
Checks the app availability before displaying the platform . - Checks are enabled only on productions . - Administrators are always granted . - Public routes are still accessible .