src/Controller/EntityController.php line 122

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Api\SalesforceRest\Controllers\ApiAccountController;
  4. use App\Api\SalesforceRest\Controllers\ApiContactController;
  5. use App\Dto\DtoBrand;
  6. use App\Dto\DtoNavigationContext;
  7. use App\Dto\Enum\EnumHttpCode;
  8. use App\Dto\Request\DtoGetNotViewedPushNotificationsRequest;
  9. use App\Dto\Response\DtoResponse;
  10. use App\Entity\AccountType;
  11. use App\Entity\Article;
  12. use App\Entity\Contact;
  13. use App\Entity\ContactProductPrice;
  14. use App\Entity\ContentOnDemand;
  15. use App\Entity\InstructorRequest;
  16. use App\Entity\Referent;
  17. use App\Entity\SfBrand;
  18. use App\Entity\SfProduct;
  19. use App\Helper\ObjectConversionHelper;
  20. use App\Helper\StringHelper;
  21. use App\Security\ConnectAsAuthenticator;
  22. use App\Service\LanguageManager;
  23. use App\Service\NotificationManager;
  24. use App\Service\NotificationService;
  25. use Doctrine\ORM\EntityManagerInterface;
  26. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  27. use Symfony\Component\HttpFoundation\JsonResponse;
  28. use Symfony\Component\HttpFoundation\Request;
  29. use Symfony\Component\HttpFoundation\RequestStack;
  30. use Symfony\Component\Routing\RouterInterface;
  31. use Symfony\Component\Security\Core\Security;
  32. use Symfony\Component\Security\Guard\GuardAuthenticatorHandler;
  33. class EntityController extends AbstractController
  34. {
  35.     protected EntityManagerInterface $entityManager;
  36.     protected NotificationManager $notificationManager;
  37.     protected string $language;
  38.     protected LanguageManager $languageManager;
  39.     protected array $viewData;
  40.     protected RequestStack $request;
  41.     /**
  42.      * EntityController constructor.
  43.      * @param EntityManagerInterface $entityManager
  44.      * @param NotificationManager $notificationManager
  45.      * @param RequestStack $request
  46.      * @param LanguageManager $languageManager
  47.      */
  48.     public function __construct(EntityManagerInterface $entityManager,
  49.                                 NotificationManager $notificationManager,
  50.                                 RequestStack $requestStack,
  51.                                 LanguageManager $languageManager,
  52.                                 NotificationService $notificationService)
  53. //<<<<<<< HEAD
  54. //                                RequestStack $request,
  55. //                                LanguageManager $languageManager,
  56. //                                SessionInterface $session,
  57. //                                NotificationService $notificationService)
  58. //=======
  59. //                                RequestStack $requestStack,
  60. //                                LanguageManager $languageManager)
  61. //>>>>>>> 92-achat-unique
  62.     {
  63.         $this->entityManager $entityManager;
  64.         $this->notificationManager $notificationManager;
  65.         $this->language $this->getLanguage($requestStack);
  66.         $this->languageManager $languageManager;
  67.         $this->currentSessionStack $requestStack->getSession();
  68.         $this->viewData = [];
  69.         $accounts = [];
  70.         $contactCsrfToken null;
  71.         $lightContact null;
  72.         // Set all accounts in session then whe can get em everywhere
  73.         $currentAccount null;
  74.         if(!is_null($contact $this->currentSessionStack->get('contact'))){
  75.             $accounts $contact->getAccounts();
  76.             foreach($accounts as $account) {
  77.                 if($account->getSalesforceId() == $requestStack->getCurrentRequest()->get('salesforceAccountId')) {
  78.                     $currentAccount $account;
  79.                     $this->viewData["accountId"] = $account->getSalesforceId();
  80.                 }
  81.             }
  82.             if(isset($currentAccount) && $currentAccount->getType()->getName() == AccountType::ACCOUNT_TYPES['PersonAccount']) {
  83.                 $clubsLinkedToCurrentInstructor ApiAccountController::getAccountClubs($currentAccount->getSalesforceId());
  84.                 if(empty($clubsLinkedToCurrentInstructor)) {
  85.                     $instructorIsLinkedToAClub false;
  86.                 } else {
  87.                     $instructorIsLinkedToAClub true;
  88.                 }
  89.                 $this->viewData['instructorIsLinkedToAClub'] = $instructorIsLinkedToAClub;
  90.             }
  91.             $lightContact $contact->cloneLightContact();
  92.         }
  93.         if(!is_null($this->currentSessionStack->get('contactCsrfToken'))){
  94.             $contactCsrfToken $this->currentSessionStack->get('contactCsrfToken');
  95.         }
  96.         $instructorRequests $this->entityManager->getRepository(InstructorRequest::class)->findBy([
  97.             'clubSFId' => $requestStack->getCurrentRequest()->get('salesforceAccountId')
  98.         ]);
  99.         if($instructorRequests) {
  100.             $countNotification 0;
  101.             foreach($instructorRequests as $instructorRequest) {
  102.                 if($instructorRequest->getClubNotification() == true) {
  103.                     $countNotification++;
  104.                 }
  105.             }
  106.             $this->viewData['clubNotification'] = $countNotification;
  107.         }
  108.         if($this->language == 'it') {
  109.             $isItalian 1;
  110.         } else {
  111.             $isItalian 0;
  112.         }
  113.         $isHbx false;
  114.         if($this->currentSessionStack->get('contact') != null) {
  115. //            get account access rights (for blog)
  116.             $accessLesMills $this->currentSessionStack->get('accessLesMills');
  117.             $accessAqua $this->currentSessionStack->get('accessAqua');
  118.             $accessHBXTT $this->currentSessionStack->get('accessHBXTT');
  119.             $accessHBX $this->currentSessionStack->get('accessHBX');
  120. //            set account access rights for HBX
  121.             $accessLesMills == true $isLesmills true $isLesmills false;
  122.             $accessAqua == true $isAqua true $isAqua false;
  123.             if($accessHBX == true || $accessHBXTT == true) {
  124.                 $isHbx true;
  125.             } else {
  126.                 $isHbx false;
  127.             }
  128. //          get articles not viewed by current contact for each article's access rights
  129.             $articlesNotViewed $this->entityManager->getRepository(Article::class)->findArticlesNotViewed($this->entityManager$this->currentSessionStack->get('contact')->getId(), $isItalian);
  130.             $articlesNotViewedLesmills $this->entityManager->getRepository(Article::class)->findArticlesNotViewedLesmills($this->entityManager$this->currentSessionStack->get('contact')->getId(), $isItalian$isLesmills);
  131.             $articlesNotViewedHBX $this->entityManager->getRepository(Article::class)->findArticlesNotViewedHBX($this->entityManager$this->currentSessionStack->get('contact')->getId(), $isItalian$isHbx);
  132.             $articlesNotViewedAqua $this->entityManager->getRepository(Article::class)->findArticlesNotViewedAqua($this->entityManager$this->currentSessionStack->get('contact')->getId(), $isItalian$isAqua);
  133. //            array of array with all the article and the 3 access rights articles
  134.             $allArticles = [];
  135. //            we'll fill this array with all articles that current account can read (can contain duplicated articles)
  136.             $articlesArray = [];
  137. //            set every articles into an array
  138.             array_push($allArticles$articlesNotViewed);
  139.             array_push($allArticles$articlesNotViewedLesmills);
  140.             array_push($allArticles$articlesNotViewedHBX);
  141.             array_push($allArticles$articlesNotViewedAqua);
  142.             if(!empty($allArticles)) {
  143.                 foreach ($allArticles as $articles) {
  144.                     foreach($articles as $article) {
  145. //                        for all articles check if account as right on them
  146.                         if(($isLesmills == false && $article->getIsLesmills() == true) ||
  147.                             ($isAqua == false && $article->getIsAqua() == true) ||
  148.                             ($isHbx == false && $article->getIsHbx() == true)
  149.                         ) {
  150.                         } else {
  151. //                            if currentAccount can read an article, put it in an array
  152.                             $articlesArray[] = $article;
  153.                         }
  154.                     }
  155.                 }
  156.             }
  157.             // Récupération des alertes
  158.             $dtoGetNotViewedPushNotifications = new DtoGetNotViewedPushNotificationsRequest();
  159.             $dtoGetNotViewedPushNotifications->contactId $contact->getId();
  160.             if ($currentAccount != null)
  161.             {
  162.                 $dtoGetNotViewedPushNotifications->salesforceAccountId $currentAccount->getSalesforceId();
  163.             }
  164.             $dtoGetNotViewedPushNotifications->isAqua $isAqua;
  165.             $dtoGetNotViewedPushNotifications->isLesmills $isLesmills;
  166.             $dtoGetNotViewedPushNotifications->isHbx $isHbx;
  167.             $dtoGetNotViewedPushNotifications->languageCode = isset($this->language) ? strtoupper($this->language) : "FR";
  168.             $dtoPusNotificationResponse $notificationService->getNotViewedPushNotifications($dtoGetNotViewedPushNotifications);
  169.             $this->viewData['notViewedPushNotifications'] = $dtoPusNotificationResponse->dtoPushNotifications;
  170. //            array of all articles that current account can read (without duplicate articles)
  171.             $allArticlesNotViewed array_unique($articlesArray);
  172.             $this->viewData['articlesNotViewed'] = count($allArticlesNotViewed);
  173.             $this->viewData['notViewedPushNotifications'] = $dtoPusNotificationResponse->dtoPushNotifications;
  174.             $this->viewData['isHbx'] = $isHbx;
  175.             $this->viewData['isAqua'] = $isAqua;
  176.             $this->viewData['isLesmills'] = $isLesmills;
  177.             $this->viewData['isGenfit'] = $this->currentSessionStack->get('accessGenfit');
  178.             if(!is_null($requestStack->getCurrentRequest()->get('salesforceAccountId'))) {
  179.                 $isHbxHub false;
  180.                 $isAquaHub false;
  181.                 $concepts ApiContactController::getConceptsByAccount($requestStack->getCurrentRequest()->get('salesforceAccountId'));
  182.                 foreach($concepts as $concept) {
  183.                     if($concept->program_id == $_ENV['HBX_COACH']
  184.                         ||$concept->program_id == $_ENV['HBX_COACH_PRO']
  185.                         ||$concept->program_id == $_ENV['HBX_COACH_CLUB']
  186.                         ||$concept->program_id == $_ENV['HBX_COACH_CLUB_PRO']
  187.                         ||$concept->program_id == $_ENV['HBX_CLUB']
  188.                         || $concept->program_id == $_ENV['HBX_CLUB_PREMIUM']
  189.                         || $concept->program_id == $_ENV['HBX_CLUB_PREMIUM_PLUS']
  190.                         || $concept->program_id == in_array($concept->program_idexplode("|"$_ENV['HBX_HUB_PROGRAMS_FOR_MENU'] ))
  191.                     )
  192.                     {
  193.                         $isHbxHub true;
  194.                     }
  195.                     if($concept->program_id == $_ENV['AQUA_COACH']
  196.                         ||$concept->program_id == $_ENV['AQUA_COACH_PRO']
  197.                         ||$concept->program_id == $_ENV['AQUA_CLUB']
  198.                         || $concept->program_id == $_ENV['AQUA_CLUB_PREMIUM']
  199.                         || $concept->program_id == $_ENV['AQUA_PISCINE_PUBLIQUE']
  200.                         || $concept->program_id == $_ENV['AQUA_PISCINE_PUBLIQUE_PREMIUM']
  201.                         || $concept->program_id == in_array($concept->program_idexplode("|"$_ENV['AQUA_HUB_PROGRAMS_FOR_MENU'] ))
  202.                     )
  203.                     {
  204.                         $isAquaHub true;
  205.                     }
  206.                 }
  207.                 if(!empty(ApiAccountController::getClubsWhereInstructorIsHbx($requestStack->getCurrentRequest()->get('salesforceAccountId')))) {
  208.                     if(ApiAccountController::getClubsWhereInstructorIsHbx($requestStack->getCurrentRequest()->get('salesforceAccountId'))[0]->Instructeur_HBX_HUB__c == true) {
  209.                         $isHbxHub true;
  210.                     }
  211.                 }
  212.                 if(!empty(ApiAccountController::getClubsWhereInstructorIsAqua($requestStack->getCurrentRequest()->get('salesforceAccountId')))) {
  213.                     if(ApiAccountController::getClubsWhereInstructorIsAqua($requestStack->getCurrentRequest()->get('salesforceAccountId'))[0]->Instructeur_AQUA_HUB__c == true) {
  214.                         $isAquaHub true;
  215.                     }
  216.                 }
  217.                 $contactId $this->currentSessionStack->get('contact')->getId();
  218.                 if($this->currentSessionStack->get('contact')->isHubAccess()) {
  219.                     $contact $this->entityManager->getRepository(Contact::class)->findBy([
  220.                         'id' => $contactId
  221.                     ]);
  222.                     $contactProductPrices $this->entityManager->getRepository(ContactProductPrice::class)->findBy([
  223.                         'contact' => $contact
  224.                     ]);
  225.                     if($contactProductPrices) {
  226.                         foreach($contactProductPrices as $contactProductPrice) {
  227.                             if(!is_null($contactProductPrice->getContentOnDemand())) {
  228.                                 if($contactProductPrice->getContentOnDemand()->getSfProduct()->getBrand() &&
  229.                                     $contactProductPrice->getContentOnDemand()->getSfProduct()->getBrand()->getCode() == $_ENV['CODE_BRAND_HUB_HBX']) {
  230.                                     $isHbxHub true;
  231.                                 } else if($contactProductPrice->getContentOnDemand()->getSfProduct()->getBrand() &&
  232.                                     $contactProductPrice->getContentOnDemand()->getSfProduct()->getBrand()->getCode() == $_ENV['CODE_BRAND_HUB_AQUA']) {
  233.                                     $isAquaHub true;
  234.                                 }
  235.                             }
  236.                         }
  237.                     }
  238.                 }
  239.                 $this->viewData['isHbxHub'] = $isHbxHub;
  240.                 $this->viewData['isAquaHub'] = $isAquaHub;
  241.             }
  242.         }
  243. //        $contentOnDemand = $this->entityManager->getRepository(ContentOnDemand::class)->findOneBy([
  244. //            'shopProductId' => '17443'
  245. //        ]);
  246. //        dump($contentOnDemand);
  247. //        $sfProduct = $this->entityManager->getRepository(SfProduct::class)->findOneBy([
  248. //            'code' => 'FORCHBX22',
  249. //        ]);
  250. //        dump($sfProduct);
  251. //        dd($contentOnDemand->getContentOnDemandRequirements()->getValues());
  252. //        foreach($contentOnDemand->getContentOnDemandRequirements()->getValues() as $contentOnDemandRequirement) {
  253. //            if($contentOnDemandRequirement->getSfProduct() == $sfProduct) {
  254. //                dump('oui');
  255. //            }
  256. //        }
  257. //        dd('stop');
  258.         $this->viewData['isHbx'] = $isHbx;
  259.         $this->viewData['language'] = $this->language;
  260.         $this->viewData['accounts'] = $accounts;
  261.         $this->viewData['contactCsrfToken'] = $contactCsrfToken;
  262.         $this->viewData['contact'] = $lightContact;
  263.         $this->viewData['env'] = $_ENV['APP_ENV'];
  264.         $this->viewData['previousAdminUsername'] = $_SESSION["_sf2_attributes"]["previousAdminUsername"] ?? null;
  265.     }
  266.     public function getNavigationContext(Request $requestRouterInterface $router): DtoNavigationContext
  267.     {
  268. //        dump($request);
  269. //        dd($router);
  270.         $expectedUrl$request->getPathInfo();
  271.         $dtoNavigationContext = new DtoNavigationContext();
  272.         if ($request->getSession()->get('_security.default.target_path') != null)
  273.         {
  274.             $expectedUrl str_replace(["https://""http://"], ""str_replace($request->getHttpHost(), ""$request->getSession()->get('_security.default.target_path')));
  275.         }
  276.         $explodeExpectedUrl explode('/'$expectedUrl);
  277.         $explodeExpectedUrlEnd end($explodeExpectedUrl);
  278.         $matched = [];
  279.         try {
  280.             $matched $router->match($expectedUrl);
  281.         } catch (\Exception $e){}
  282.         if (empty($matched) == false)
  283.         {
  284.             $productCodeRaw array_key_exists("productCode"$matched) ? $matched['productCode'] : $request->get("productCode");
  285.             //S'il y a des paramètres après le productCode, on prend le string avant le '?'
  286.             $productCode strtok($productCodeRaw'?');
  287.             $dbBrand null;
  288.             if (StringHelper::isNullOrEmptyWithSpace($productCode) == false) {
  289.                 $dbProduct $this->entityManager->getRepository(SfProduct::class)->findOneBy(['code' => $productCode]);
  290.                 if(!is_null($dbProduct)) {
  291.                     $dbBrand $dbProduct->getBrand();
  292.                 }
  293.             }
  294.             else if ($request->get("brandCode") != null)
  295.             {
  296.                 $dbBrand $this->entityManager->getRepository(SfBrand::class)->findOneBy(['code' => $request->get("brandCode")]);
  297.             }
  298.             else if (isset($matched['brandCode']) && $matched['brandCode'] != null) {
  299.                 $dbBrand $this->entityManager->getRepository(SfBrand::class)->findOneBy(['code' => $matched['brandCode']]);
  300.             }
  301.             else if (!is_null($explodeExpectedUrlEnd)) {
  302.                 $dbBrand $this->entityManager->getRepository(SfBrand::class)->findOneBy(['code' => $explodeExpectedUrlEnd]);
  303.             }
  304.             if ($dbBrand != null) {
  305.                 $dtoBrand ObjectConversionHelper::convert($dbBrandDtoBrand::class);
  306.                 $dtoNavigationContext->dtoBrand $dtoBrand;
  307.             }
  308.         }
  309.         return $this->viewData['context'] = $dtoNavigationContext;
  310.     }
  311.     public function refreshViewLightContactFromSession() : void
  312.     {
  313.         if(!is_null($contact $this->session->get('contact'))){
  314.             $lightContact $contact->cloneLightContact();
  315.             $this->viewData['contact'] = $lightContact;
  316.         }
  317.     }
  318.     /**
  319.      * @return array
  320.      */
  321.     public function getMessages() : array
  322.     {
  323.         return $this->notificationManager::getMessages();
  324.     }
  325.     /**
  326.      * Parse all errors and messages to create flash messages
  327.      */
  328.     protected function createFlashs() : void{
  329.         $messages $this->getMessages();
  330.         foreach ($messages['error'] as $error){
  331.             $this->addFlash('danger'$this->languageManager->translate($error$this->language));
  332.         }
  333.         foreach ($messages['info'] as $message){
  334.             $this->addFlash('success'$this->languageManager->translate($message$this->language));
  335.         }
  336.         $this->notificationManager::eraseMessages();
  337.     }
  338.     /**
  339.      * Méthode permettant de convertir un DtoResponse en messages flash
  340.      * @param DtoResponse $dtoResponse
  341.      * @return void
  342.      */
  343.     protected function createFlashsFromDtoResponse(DtoResponse $dtoResponse)
  344.     {
  345.         if ($dtoResponse->isSuccess())
  346.         {
  347.             if (empty($dtoResponse->successMessages) == false)
  348.             {
  349.                 foreach ($dtoResponse->successMessages as $message){
  350.                     $this->addFlash('success'$this->languageManager->translate($message$this->language));
  351.                 }
  352.             }
  353.         }
  354.         else if ($dtoResponse->isBadRequest())
  355.         {
  356.             // Création du message pour les champs obligatoires
  357.             if (empty($dtoResponse->requiredFields) == false)
  358.             {
  359.                 // Gestion de la phrase d'accroche
  360.                 $message $this->languageManager->translate('REQUIRED_FIELDS_DEFAULT_MESSAGE'$this->language) . "<ul>";
  361.                 // Gestion du détail des champs en erreur
  362.                 foreach($dtoResponse->requiredFields as $requiredField)
  363.                 {
  364.                     $message .= "<li>" $this->languageManager->translate($requiredField$this->language) . "</li>";
  365.                 }
  366.                 $this->addFlash('danger'$message "</ul>");
  367.             } // Création du message pour les champs invalides
  368.             else if (empty($dtoResponse->invalidRules) == false)
  369.             {
  370.                 // Gestion de la phrase d'accroche
  371.                 $message $this->languageManager->translate('INVALID_RULES_DEFAULT_MESSAGE'$this->language) . "<ul>";
  372.                 // Gestion du détail des champs en erreur
  373.                 foreach($dtoResponse->invalidRules as $invalidRule)
  374.                 {
  375.                     $message .= "<li>" $this->languageManager->translate($invalidRule$this->language) . "</li>";
  376.                 }
  377.                 $this->addFlash('danger'$message"</ul>");
  378.             }
  379.         }
  380.         else // Gestion des autres erreurs
  381.         {
  382.             if (empty($dtoResponse->errorMessages) == false)
  383.             {
  384.                 foreach($dtoResponse->errorMessages as $errorMessage)
  385.                 {
  386.                     $this->addFlash('danger'$this->languageManager->translate($errorMessage$this->language));
  387.                 }
  388.             }
  389.             else // Erreur générique
  390.             {
  391.                 $this->addFlash('danger'$this->languageManager->translate("Un problème est survenu"$this->language));
  392.             }
  393.         }
  394.     }
  395.     public function createJsonResponseFromDtoResponse(DtoResponse $dtoResponsestring $language) : JsonResponse
  396.     {
  397.         $response null;
  398.         if($dtoResponse->isSuccess()) {
  399.             $response = new JsonResponse($dtoResponse$dtoResponse->getHttpCode());
  400.         } else {
  401.             $messagesErrorKey 'error';
  402.             $messages = [$messagesErrorKey => []];
  403.             // Création du message pour les champs obligatoires
  404.             if (empty($dtoResponse->requiredFields) == false) {
  405.                 // Gestion de la phrase d'accroche
  406.                 $message $this->languageManager->translate('REQUIRED_FIELDS_DEFAULT_MESSAGE'$language) . "<ul>";
  407.                 // Gestion du détail des champs en erreur
  408.                 foreach ($dtoResponse->requiredFields as $requiredField) {
  409.                     $message .= "<li>" $this->languageManager->translate($requiredField$language) . "</li>";
  410.                 }
  411.                 $messages[$messagesErrorKey][] = $message '</ul>';
  412.             } // Création du message pour les champs invalides
  413.             else if (empty($dtoResponse->invalidRules) == false) {
  414.                 // Gestion de la phrase d'accroche
  415.                 $message $this->languageManager->translate('INVALID_RULES_DEFAULT_MESSAGE'$language) . "<ul>";
  416.                 // Gestion du détail des champs en erreur
  417.                 foreach ($dtoResponse->invalidRules as $invalidRule) {
  418.                     $message .= "<li>" $this->languageManager->translate($invalidRule$language) . "</li>";
  419.                 }
  420.                 $messages[$messagesErrorKey][] = $message '</ul>';
  421.             }
  422.             else // Gestion des autres erreurs
  423.             {
  424.                 if (empty($dtoResponse->errorMessages) == false) {
  425.                     foreach ($dtoResponse->errorMessages as $errorMessage) {
  426.                         $messages[$messagesErrorKey][] = $this->languageManager->translate($errorMessage$language);
  427.                     }
  428.                 }
  429.                 else if (empty($dtoResponse->errorMessage) == false)
  430.                 {
  431.                     $messages[$messagesErrorKey][] = $this->languageManager->translate($dtoResponse->errorMessage$language);
  432.                 }
  433.                 else // Erreur générique
  434.                 {
  435.                     $messages[$messagesErrorKey][] = $this->languageManager->translate('Un problème est survenu.'$language);
  436.                 }
  437.             }
  438.             $dtoResponse->errorSummaryMessages $messages;
  439.             $response = new JsonResponse($dtoResponse);
  440.             $response->setStatusCode($dtoResponse->getHttpCode());
  441.         }
  442.         return $response;
  443.     }
  444.     protected function getLanguage(RequestStack $requestStack) : string{
  445.         return $requestStack->getCurrentRequest()->getLocale();
  446.     }
  447.     /**
  448.      * @param RequestStack $request
  449.      * @return Referent|null
  450.      */
  451.     protected function getReferentFromSession(RequestStack $requestStack) : ?Referent
  452.     {
  453.         $referent $requestStack->getSession()->get('contact'null);
  454.         if(!($referent instanceof Referent)){
  455.             $referent null;
  456.         }
  457.         return $referent;
  458.     }
  459.     /**
  460.      * add array data in the data array
  461.      * @param string $key
  462.      * @param array $dataArray
  463.      * @return EntityController
  464.      */
  465.     public function addViewDataArray(string $key, array $dataArray) : self
  466.     {
  467.         $this->viewData[$key] = $dataArray;
  468.         return $this;
  469.     }
  470.     /**
  471.      * add int data in the data array
  472.      * @param string $key
  473.      * @param int $dataInt
  474.      * @return EntityController
  475.      */
  476.     public function addViewDataInt(string $keyint $dataInt) : self
  477.     {
  478.         $this->viewData[$key] = $dataInt;
  479.         return $this;
  480.     }
  481.     /**
  482.      * add string data in the data array
  483.      * @param string $key
  484.      * @param string $dataString
  485.      * @return EntityController
  486.      */
  487.     public function addViewDataString(string $keystring $dataString) : self
  488.     {
  489.         $this->viewData[$key] = $dataString;
  490.         return $this;
  491.     }
  492.     /**
  493.      * add object data in the data array
  494.      * @param string $key
  495.      * @param object|null $dataObject
  496.      * @return EntityController
  497.      */
  498.     public function addViewDataObject(string $key, ?object $dataObject) : self
  499.     {
  500.         $this->viewData[$key] = $dataObject;
  501.         return $this;
  502.     }
  503.     /**
  504.      * add object data in the data array
  505.      * @param string $key
  506.      * @param bool $dataBool
  507.      * @return EntityController
  508.      */
  509.     public function addViewDataBool(string $keybool $dataBool) : self
  510.     {
  511.         $this->viewData[$key] = $dataBool;
  512.         return $this;
  513.     }
  514. }