src/Products/AdaBundle/Controller/Dashboard/DefaultController.php line 45

Open in your IDE?
  1. <?php
  2. namespace Products\AdaBundle\Controller\Dashboard;
  3. use Cms\CoreBundle\Util\Controller;
  4. use Cms\TenantBundle\Model\ProductsBitwise;
  5. use Platform\MarketingBundle\Model\ProductControllerInterface;
  6. use Symfony\Component\HttpFoundation\Response;
  7. use Symfony\Component\Routing\Annotation\Route;
  8. use Symfony\Component\HttpFoundation\RedirectResponse;
  9. /**
  10.  * Class DefaultController
  11.  * @package Products\AdaBundle\Controller\Dashboard
  12.  *
  13.  * @Route(
  14.  *     "/ada"
  15.  * )
  16.  */
  17. final class DefaultController extends Controller implements ProductControllerInterface
  18. {
  19.     const ROUTES__MAIN 'products.ada.dashboard.default.main';
  20.     /**
  21.      * {@inheritdoc}
  22.      */
  23.     public function productCheck(ProductsBitwise $products): ?Response
  24.     {
  25.         // if the client has no ada services, push them to the ada screen
  26.         if ( ! $products->checkAnyFlag(ProductsBitwise::ACCESSIBILITY__CONTENT ProductsBitwise::ACCESSIBILITY__PDFS)) {
  27.             return $this->redirectToRoute('platform.marketing.dashboard.default.ada');
  28.         }
  29.         return null;
  30.     }
  31.     /**
  32.      * @return RedirectResponse
  33.      *
  34.      * @Route(
  35.      *     "",
  36.      *     name = DefaultController::ROUTES__MAIN
  37.      * )
  38.      */
  39.     public function mainAction()
  40.     {
  41.         // check the products
  42.         switch (true) {
  43.             case $this->getGlobalContext()->getTenant()->getProducts()->checkFlag(ProductsBitwise::ACCESSIBILITY__CONTENT):
  44.             case $this->getGlobalContext()->getTenant()->getProducts()->checkFlag(ProductsBitwise::ACCESSIBILITY__PDFS):
  45.                 return $this->redirectToRoute('products.ada.dashboard.content.overview');
  46.         }
  47.         // they have none of the products, jump to the marketing upsell page
  48.         return $this->redirectToRoute('platform.marketing.dashboard.default.ada');
  49.     }
  50. }