/** * Action for product sequential edition * @param Request $request * * @AclAncestor("pim_enrich_product_edit_attributes") * @return RedirectResponse */ public function sequentialEditAction(Request $request) { $sequentialEdit = $this->seqEditManager->createEntity($this->getObjects($request), $this->userContext->getUser()); if ($this->seqEditManager->findByUser($this->userContext->getUser())) { return new RedirectResponse($this->router->generate('pim_enrich_product_index', ['dataLocale' => $request->get('dataLocale')])); } $this->seqEditManager->save($sequentialEdit); return new RedirectResponse($this->router->generate('pim_enrich_product_edit', ['dataLocale' => $request->get('dataLocale'), 'id' => current($sequentialEdit->getObjectSet())])); }
/** * Get the product edit template parameters * * @param FormInterface $form * @param ProductInterface $product * @param array $channels * @param array $trees * * @return array */ protected function getProductEditTemplateParams(FormInterface $form, ProductInterface $product, array $channels, array $trees) { $sequentialEdit = $this->seqEditManager->findByUser($this->getUser()); if ($sequentialEdit) { $this->seqEditManager->findWrap($sequentialEdit, $product); } $defaultParameters = ['form' => $form->createView(), 'dataLocale' => $this->getDataLocaleCode(), 'comparisonLocale' => $this->getComparisonLocale(), 'channels' => $channels, 'attributesForm' => $this->getAvailableAttributesForm($product->getAttributes())->createView(), 'product' => $product, 'trees' => $trees, 'created' => $this->versionManager->getOldestLogEntry($product), 'updated' => $this->versionManager->getNewestLogEntry($product), 'locales' => $this->getUserLocales(), 'createPopin' => $this->getRequest()->get('create_popin'), 'sequentialEdit' => $sequentialEdit]; $event = new GenericEvent($this, ['parameters' => $defaultParameters]); $this->dispatch(ProductEvents::PRE_RENDER_EDIT, $event); return $event->getArgument('parameters'); }
/** * @param Request $request * * @return JsonResponse */ public function getAction(Request $request) { $sequentialEdit = $this->seqEditManager->findByUser($this->userContext->getUser()); return new JsonResponse($this->normalizer->normalize($sequentialEdit, 'internal_api')); }