public function buildNfcTagData($students) { $build = function ($nfcTag) { $data = $nfcTag->getSyncObjectData(); $data[Product::getSyncArrayNameRestricted()] = NULL; foreach ($nfcTag->getStudent()->getProducts() as $product) { $data[Product::getSyncArrayNameRestricted()][] = $product->getSyncObjectDataRestricted(); } return $data; }; $data = []; foreach ($students as $student) { if ($student->getNfcTag()) { if (!$student->getNfcTag()->getPseudoDeleted()) { $data[] = $build($student->getNfcTag()); } } } $data = [NfcTag::getSyncArrayName() => $data]; $syncResponse = [self::SYNC_CHECKSUM => $this->_checksum->getDataChecksum($data), self::SYNC_DATA => $data]; return $syncResponse; }
/** * Add products * * @param \AppBundle\Entity\Product\Product $product * @return ProductCategory */ public function addProduct(\AppBundle\Entity\Product\Product $product) { $product->setProductCategory($this); $this->products[] = $product; return $this; }
/** * Add product * * @param \AppBundle\Entity\Product\Product $product * @return Student */ public function addProduct(\AppBundle\Entity\Product\Product $product) { $product->addStudent($this); $this->products[] = $product; return $this; }
/** * Add products * * @param \AppBundle\Entity\Product\Product $product * @return ProductVendingGroup */ public function addProduct(\AppBundle\Entity\Product\Product $product) { $product->addProductVendingGroup($this); $this->products[] = $product; return $this; }
/** * Add products * * @param \AppBundle\Entity\Product\Product $product * @return Supplier */ public function addProduct(\AppBundle\Entity\Product\Product $product) { $product->setSupplier($this); $this->products[] = $product; return $this; }
/** * @Method({"GET", "POST"}) * @Route( * "/product/create", * name="product_create", * host="{domain_dashboard}", * defaults={"_locale" = "%locale%", "domain_dashboard" = "%domain_dashboard%"}, * requirements={"_locale" = "%locale%", "domain_dashboard" = "%domain_dashboard%"} * ) */ public function createAction(Request $request) { if (!$this->_productBoundlessAccess->isGranted(ProductBoundlessAccess::PRODUCT_CREATE)) { throw $this->createAccessDeniedException('Access denied'); } $productType = new ProductType($this->_translator, $this->_productBoundlessAccess->isGranted(ProductBoundlessAccess::PRODUCT_CREATE)); $form = $this->createForm($productType, $product = new Product(), ['action' => $this->generateUrl('product_create')]); $form->handleRequest($request); if (!($form->isValid() && $this->_uploadedProductImageValidator->validate($form))) { $this->_breadcrumbs->add('product_read')->add('product_create'); return $this->render('AppBundle:Entity/Product/CRUD:createItem.html.twig', ['form' => $form->createView()]); } else { // TODO: This large logic does not belong to Controller if (array_filter($form->getData()->getUploadedProductImages())) { foreach ($form->getData()->getUploadedProductImages() as $uploadedProductImage) { $productImage = (new ProductImage())->setImageProductFile($uploadedProductImage)->setUpdatedAt(new DateTime()); $product->addProductImage($productImage); $this->_manager->persist($productImage); } $this->_manager->persist($product); } $this->_manager->persist($product); $this->_manager->flush(); $this->_messages->markCreateSuccess(); if ($form->has('create_and_return') && $form->get('create_and_return')->isClicked()) { return $this->redirectToRoute('product_read'); } else { return $this->redirectToRoute('product_update', ['id' => $product->getId()]); } } }