Symfony Exception

TypeError

HTTP 500 Internal Server Error

Argument 1 passed to AWEcommerceBundle\Manager\OrderManager::addProductVariantToUser() must be an instance of AWEcommerceBundle\Entity\User, null given, called in /var/www/vendor/simpledot/ecommerce-bundle/AWEcommerceBundle/Controller/Front/OrderController.php on line 70

Exception

TypeError

  1.      * @param ProductVariant $productVariant
  2.      * @param int $quantity
  3.      * @return OrderItem
  4.      * @throws \AWEcommerceBundle\Exception\OutOfStockException
  5.      */
  6.     public function addProductVariantToUser(User $userProductVariant $productVariant$quantity 1$customText null)
  7.     {
  8.         /** @var Order $order */
  9.         $order $this->getOrCreateCartOrder($user);
  10.         $this->eventDispatcher->dispatch(new OrderEvent($order), OrderEvent::POST_CREATED_EVENT);
  11.         $this->eventDispatcher->dispatch( new OrderEvent($order), OrderEvent::PRE_UPDATED_EVENT);
  1.         int $quantity)
  2.     {
  3.         $user $currentUserProvider->get();
  4.         
  5.         try{
  6.             $orderManager->addProductVariantToUser($user$variant$quantity$request->get('customText'));
  7.         }catch (OutOfStockException $exception) {
  8.             return new Response($translator->trans('api.ecommerce.order_item.error.out_of_stock'), Response::HTTP_BAD_REQUEST);
  9.         }
  10.         
  11.         return $this->redirectToRoute('aw_ec_cart_index');
in vendor/symfony/http-kernel/HttpKernel.php->initOrderAction (line 159)
  1.         $this->dispatcher->dispatch($eventKernelEvents::CONTROLLER_ARGUMENTS);
  2.         $controller $event->getController();
  3.         $arguments $event->getArguments();
  4.         // call controller
  5.         $response $controller(...$arguments);
  6.         // view
  7.         if (!$response instanceof Response) {
  8.             $event = new ViewEvent($this$request$type$response);
  9.             $this->dispatcher->dispatch($eventKernelEvents::VIEW);
  1.     {
  2.         $request->headers->set('X-Php-Ob-Level', (string) ob_get_level());
  3.         $this->requestStack->push($request);
  4.         try {
  5.             return $this->handleRaw($request$type);
  6.         } catch (\Exception $e) {
  7.             if ($e instanceof RequestExceptionInterface) {
  8.                 $e = new BadRequestHttpException($e->getMessage(), $e);
  9.             }
  10.             if (false === $catch) {
  1.         $this->boot();
  2.         ++$this->requestStackSize;
  3.         $this->resetServices true;
  4.         try {
  5.             return $this->getHttpKernel()->handle($request$type$catch);
  6.         } finally {
  7.             --$this->requestStackSize;
  8.         }
  9.     }
Kernel->handle() in public/index.php (line 33)
  1.     exit;
  2. }
  3. $kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
  4. $response $kernel->handle($request);
  5. $response->send();
  6. $kernel->terminate($request$response);

Logs

No log messages

Stack Trace

TypeError

TypeError:
Argument 1 passed to AWEcommerceBundle\Manager\OrderManager::addProductVariantToUser() must be an instance of AWEcommerceBundle\Entity\User, null given, called in /var/www/vendor/simpledot/ecommerce-bundle/AWEcommerceBundle/Controller/Front/OrderController.php on line 70

  at vendor/simpledot/ecommerce-bundle/AWEcommerceBundle/Manager/OrderManager.php:193
  at AWEcommerceBundle\Manager\OrderManager->addProductVariantToUser()
     (vendor/simpledot/ecommerce-bundle/AWEcommerceBundle/Controller/Front/OrderController.php:70)
  at AWEcommerceBundle\Controller\Front\OrderController->initOrderAction()
     (vendor/symfony/http-kernel/HttpKernel.php:159)
  at Symfony\Component\HttpKernel\HttpKernel->handleRaw()
     (vendor/symfony/http-kernel/HttpKernel.php:81)
  at Symfony\Component\HttpKernel\HttpKernel->handle()
     (vendor/symfony/http-kernel/Kernel.php:201)
  at Symfony\Component\HttpKernel\Kernel->handle()
     (public/index.php:33)