<?php
namespace Products\AdaBundle\Controller\Dashboard;
use Cms\CoreBundle\Util\Controller;
use Cms\TenantBundle\Model\ProductsBitwise;
use Platform\MarketingBundle\Model\ProductControllerInterface;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\HttpFoundation\RedirectResponse;
/**
* Class DefaultController
* @package Products\AdaBundle\Controller\Dashboard
*
* @Route(
* "/ada"
* )
*/
final class DefaultController extends Controller implements ProductControllerInterface
{
const ROUTES__MAIN = 'products.ada.dashboard.default.main';
/**
* {@inheritdoc}
*/
public function productCheck(ProductsBitwise $products): ?Response
{
// if the client has no ada services, push them to the ada screen
if ( ! $products->checkAnyFlag(ProductsBitwise::ACCESSIBILITY__CONTENT | ProductsBitwise::ACCESSIBILITY__PDFS)) {
return $this->redirectToRoute('platform.marketing.dashboard.default.ada');
}
return null;
}
/**
* @return RedirectResponse
*
* @Route(
* "",
* name = DefaultController::ROUTES__MAIN
* )
*/
public function mainAction()
{
// check the products
switch (true) {
case $this->getGlobalContext()->getTenant()->getProducts()->checkFlag(ProductsBitwise::ACCESSIBILITY__CONTENT):
case $this->getGlobalContext()->getTenant()->getProducts()->checkFlag(ProductsBitwise::ACCESSIBILITY__PDFS):
return $this->redirectToRoute('products.ada.dashboard.content.overview');
}
// they have none of the products, jump to the marketing upsell page
return $this->redirectToRoute('platform.marketing.dashboard.default.ada');
}
}