コード例 #1
0
 /**
  * Get the configuration form for the given $operationAlias.
  *
  * @param string                              $operationAlias
  * @param ConfigurableOperationInterface|null $operation
  *
  * @throws \LogicException If operation get from $operationAlias or $operation
  *                         doesn't implements ConfigurableOperationInterface
  *
  * @return \Symfony\Component\Form\Form
  */
 public function getConfigurationForm($operationAlias, $operation = null)
 {
     if (null === $operation) {
         $operation = $this->operationRegistry->get($operationAlias);
     }
     if (!$operation instanceof ConfigurableOperationInterface) {
         throw new \LogicException(sprintf('Operation with alias "%s" is not an instance of ConfigurableOperationInterface', $operationAlias));
     }
     $operation->initialize();
     $form = $this->formFactory->create($this->chooseActionFormType, $operation);
     $form->add('operation', $operation->getFormType(), $operation->getFormOptions());
     return $form;
 }
コード例 #2
0
 /**
  * @param string $operationAlias
  *
  * @AclAncestor("pim_enrich_mass_edit")
  *
  * @throws NotFoundResourceException
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function performAction($operationAlias)
 {
     $gridName = $this->request->get('gridName');
     $operation = $this->operationRegistry->get($operationAlias);
     $itemsName = $operation->getItemsName();
     $productCount = $this->request->get('objectsCount');
     $form = $this->massEditFormResolver->getConfigurationForm($operationAlias);
     $form->remove('operationAlias');
     $form->submit($this->request);
     if ($form->isValid()) {
         $operation = $form->getData();
         $pimFilters = $this->gridFilterAdapter->adapt($this->request);
         $operation->setFilters($pimFilters);
         $jobCode = $operation->getBatchJobCode();
         $jobInstance = $this->doctrine->getRepository('Akeneo\\Component\\Batch\\Model\\JobInstance')->findOneBy(['code' => $jobCode]);
         if (null === $jobInstance) {
             throw new NotFoundResourceException(sprintf('No job found with job code "%s"', $jobCode));
         }
         $operation->finalize();
         $rawConfiguration = $operation->getBatchConfig();
         $this->simpleJobLauncher->launch($jobInstance, $this->tokenStorage->getToken()->getUser(), $rawConfiguration);
     }
     if ($form->isValid()) {
         $this->request->getSession()->getFlashBag()->add('success', new Message(sprintf('pim_enrich.mass_edit_action.%s.launched_flash', $operationAlias)));
         $route = $this->getRouteFromMapping($gridName);
         return new RedirectResponse($this->router->generate($route, ['dataLocale' => $this->getQueryParams()['dataLocale']]));
     }
     return $this->templating->renderResponse(sprintf('PimEnrichBundle:MassEditAction:configure/%s.html.twig', $operationAlias), ['form' => $form->createView(), 'operationAlias' => $operationAlias, 'itemsName' => $itemsName, 'productCount' => $productCount, 'queryParams' => $this->getQueryParams()]);
 }
コード例 #3
0
 /**
  * Display the form to configure the mass edit action to execute
  *
  * @AclAncestor("pim_enrich_mass_edit")
  *
  * @param Request $request
  * @param string  $operationAlias
  *
  * @return Response
  */
 public function configureAction(Request $request, $operationAlias)
 {
     $operation = $this->operationRegistry->get($operationAlias);
     $form = $this->massEditFormResolver->getConfigurationForm($operationAlias);
     $itemsCount = $request->get('itemsCount');
     $configureTemplate = $this->getConfigureOperationTemplate($operationAlias);
     return $this->templating->renderResponse($configureTemplate, ['form' => $form->createView(), 'operationAlias' => $operationAlias, 'operation' => $operation, 'queryParams' => $this->getQueryParams($request), 'itemsCount' => $itemsCount]);
 }