1 | <?php |
||
2 | |||
3 | namespace GGGGino\SkuskuCartBundle\Controller; |
||
4 | |||
5 | use Allyou\ManagementCafBundle\Entity\Product; |
||
0 ignored issues
–
show
|
|||
6 | use GGGGino\SkuskuCartBundle\Form\Type\AddToCartType; |
||
7 | use GGGGino\SkuskuCartBundle\Form\CartFlow; |
||
8 | use GGGGino\SkuskuCartBundle\Model\SkuskuProductInterface; |
||
9 | use GGGGino\SkuskuCartBundle\Service\CartManager; |
||
10 | use GGGGino\SkuskuCartBundle\Service\CRUDCart; |
||
0 ignored issues
–
show
The type
GGGGino\SkuskuCartBundle\Service\CRUDCart was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
11 | use Symfony\Bundle\FrameworkBundle\Controller\Controller; |
||
12 | use Symfony\Component\Form\Form; |
||
13 | use Symfony\Component\HttpFoundation\Request; |
||
14 | use Symfony\Component\Routing\Annotation\Route; |
||
15 | use Symfony\Component\HttpFoundation\Response; |
||
16 | |||
17 | /** |
||
18 | * Class ProductController |
||
19 | * @package GGGGino\SkuskuCartBundle\Controller |
||
20 | */ |
||
21 | class ProductController extends Controller |
||
22 | { |
||
23 | /** |
||
24 | * Cart page |
||
25 | * |
||
26 | * @Route("/products", name="products_page") |
||
27 | * @param Request $request |
||
28 | * @return \Symfony\Component\HttpFoundation\RedirectResponse|Response |
||
29 | */ |
||
30 | public function productsAction(Request $request) |
||
31 | { |
||
32 | /** @var CartManager $cartManager */ |
||
33 | $cartManager = $this->get(CartManager::class); |
||
34 | |||
35 | $productsAndForms = array(); |
||
36 | |||
37 | $products = $this->getDoctrine() |
||
38 | ->getRepository(SkuskuProductInterface::class) |
||
39 | ->findAll(); |
||
40 | |||
41 | /** @var SkuskuProductInterface $product */ |
||
42 | foreach ($products as $product) { |
||
43 | /** @var Form $addToCartForm */ |
||
44 | $addToCartForm = $this->createForm(AddToCartType::class, array( |
||
45 | 'idProduct' => $product->getId() |
||
46 | )); |
||
47 | |||
48 | $cartManager->addProductToCartForm($request, $addToCartForm); |
||
49 | |||
50 | $productsAndForms[] = array( |
||
51 | 'product' => $product, |
||
52 | 'form' => $addToCartForm->createView() |
||
53 | ); |
||
54 | } |
||
55 | |||
56 | return $this->render('GGGGinoSkuskuCartBundle::products.html.twig', array( |
||
57 | 'productsForms' => $productsAndForms |
||
58 | )); |
||
59 | } |
||
60 | |||
61 | /** |
||
62 | * Cart page |
||
63 | * |
||
64 | * @Route("/products/{id}", name="product_page") |
||
65 | * @param Request $request |
||
66 | * @param $id |
||
67 | * @return Response |
||
68 | */ |
||
69 | public function productAction(Request $request, $id) |
||
70 | { |
||
71 | /** @var CartManager $cartManager */ |
||
72 | $cartManager = $this->get(CartManager::class); |
||
73 | |||
74 | $product = $this->getDoctrine() |
||
75 | ->getRepository(Product::class) |
||
76 | ->find($id); |
||
77 | |||
78 | if (!$product) { |
||
79 | $product = $this->getRandomProduct(); |
||
80 | } |
||
81 | |||
82 | $addToCartForm = $this->createForm(AddToCartType::class, array( |
||
83 | 'idProduct' => $id |
||
84 | )); |
||
85 | |||
86 | $cartManager->addProductToCartForm($request, $addToCartForm); |
||
87 | |||
88 | return $this->render('GGGGinoSkuskuCartBundle::product.html.twig', array( |
||
89 | 'product' => $product, |
||
90 | 'addToCartForm' => $addToCartForm->createView() |
||
91 | )); |
||
92 | } |
||
93 | |||
94 | private function getRandomProduct() |
||
95 | { |
||
96 | $ieri = new \DateTime(); |
||
97 | $productItem = new Product(); |
||
98 | $productItem->setDescription(MD5(microtime())); |
||
99 | $productItem->setFullPrice(rand(0, 100)); |
||
100 | $productItem->setAvailableFrom($ieri->sub(new \DateInterval('P1D'))); |
||
101 | $productItem->setAvailableTo($ieri->add(new \DateInterval('P1D'))); |
||
102 | |||
103 | return $productItem; |
||
104 | } |
||
105 | |||
106 | } |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths