Browse Source

Erreur 500 : Typed property Lc\CaracoleBundle\Controller\Order\CartController::$productFamily must not be accessed before initialization

Erreur 500 : An exception has been thrown during the rendering of a template ("Aucun espace n'a été trouvé").
develop
Guillaume 2 years ago
parent
commit
12ea0f990e
2 changed files with 5 additions and 4 deletions
  1. +1
    -1
      Controller/Order/CartController.php
  2. +4
    -3
      Resolver/SectionResolver.php

+ 1
- 1
Controller/Order/CartController.php View File

*/ */
class CartController extends AbstractController class CartController extends AbstractController
{ {
protected ProductFamilyInterface $productFamily;
protected ?ProductFamilyInterface $productFamily = null;
protected int $quantityOrder = 1; protected int $quantityOrder = 1;
protected array $orderProducts = []; protected array $orderProducts = [];



+ 4
- 3
Resolver/SectionResolver.php View File

$this->urlResolver = $urlResolver; $this->urlResolver = $urlResolver;
} }


public function getCurrent($returnDefaultIfOutOfSections = false, $returnVisitedIfOutOfSection = false)
public function getCurrent($returnDefaultIfOutOfSections = false, $returnVisitedIfOutOfSection = false, $throwExceptionIfSectionNotFound = true)
{ {
$requestAttributesArray = $this->requestStack->getMainRequest()->attributes->all(); $requestAttributesArray = $this->requestStack->getMainRequest()->attributes->all();


$sectionCurrent = $sectionStore $sectionCurrent = $sectionStore
->setMerchant($merchantCurrent) ->setMerchant($merchantCurrent)
->getOneBySlug($requestAttributesArray['section']); ->getOneBySlug($requestAttributesArray['section']);
if($sectionCurrent===null){

if($sectionCurrent === null && $throwExceptionIfSectionNotFound){
throw new NotFoundHttpException('Aucun espace n\'a été trouvé'); throw new NotFoundHttpException('Aucun espace n\'a été trouvé');
} }
} }


public function isOutOfSection(): bool public function isOutOfSection(): bool
{ {
return $this->getCurrent() == null;
return $this->getCurrent(false, false, false) == null;
} }


public function getDefault(): SectionInterface public function getDefault(): SectionInterface

Loading…
Cancel
Save