コード例 #1
0
 /**
  * Edit an association type
  *
  * @param Request $request
  * @param int     $id
  *
  * @Template
  * @AclAncestor("pim_enrich_associationtype_edit")
  *
  * @return array
  */
 public function editAction(Request $request, $id)
 {
     $associationType = $this->findOr404('PimCatalogBundle:AssociationType', $id);
     if ($this->assocTypeHandler->process($associationType)) {
         $this->addFlash('success', 'flash.association type.updated');
         return $this->redirectToRoute('pim_enrich_associationtype_edit', ['id' => $id]);
     }
     $usageCount = $this->assocRepository->countForAssociationType($associationType);
     return ['form' => $this->assocTypeForm->createView(), 'usageCount' => $usageCount];
 }
コード例 #2
0
 /**
  * Edit an association type
  *
  * @param int     $id
  *
  * @Template
  * @AclAncestor("pim_enrich_associationtype_edit")
  *
  * @return array
  */
 public function editAction($id)
 {
     $associationType = $this->assocTypeRepo->find($id);
     if (!$associationType) {
         throw new NotFoundHttpException(sprintf('%s entity not found', 'PimCatalogBundle:AssociationType'));
     }
     if ($this->assocTypeHandler->process($associationType)) {
         $this->request->getSession()->getFlashBag()->add('success', new Message('flash.association type.updated'));
         return new RedirectResponse($this->router->generate('pim_enrich_associationtype_edit', ['id' => $id]));
     }
     $usageCount = $this->assocRepository->countForAssociationType($associationType);
     return ['form' => $this->assocTypeForm->createView(), 'usageCount' => $usageCount];
 }
コード例 #3
0
 /**
  * Get association count by association type
  *
  * @param AssociationTypeInterface $type
  *
  * @return int
  */
 public function countForAssociationType(AssociationTypeInterface $type)
 {
     return $this->repository->countForAssociationType($type);
 }