当前位置: 首页>>代码示例>>PHP>>正文


PHP AttributeRepositoryInterface::find方法代码示例

本文整理汇总了PHP中Pim\Component\Catalog\Repository\AttributeRepositoryInterface::find方法的典型用法代码示例。如果您正苦于以下问题:PHP AttributeRepositoryInterface::find方法的具体用法?PHP AttributeRepositoryInterface::find怎么用?PHP AttributeRepositoryInterface::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Pim\Component\Catalog\Repository\AttributeRepositoryInterface的用法示例。


在下文中一共展示了AttributeRepositoryInterface::find方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: removeAttributeAction

 /**
  * Remove an attribute
  *
  * @param int $familyId
  * @param int $attributeId
  *
  * @AclAncestor("pim_enrich_family_edit_attributes")
  *
  * @throws DeleteException
  *
  * @return \Symfony\Component\HttpFoundation\RedirectResponse
  */
 public function removeAttributeAction($familyId, $attributeId)
 {
     $family = $this->familyRepository->find($familyId);
     if (null === $family) {
         throw new NotFoundHttpException(sprintf('%s entity not found', $this->familyClass));
     }
     $attribute = $this->attributeRepo->find($attributeId);
     if (null === $attribute) {
         throw new NotFoundHttpException(sprintf('%s entity not found', $this->attributeClass));
     }
     if (false === $family->hasAttribute($attribute)) {
         throw new DeleteException($this->translator->trans('flash.family.attribute not found'));
     } elseif (AttributeTypes::IDENTIFIER === $attribute->getAttributeType()) {
         throw new DeleteException($this->translator->trans('flash.family.identifier not removable'));
     } elseif ($attribute === $family->getAttributeAsLabel()) {
         throw new DeleteException($this->translator->trans('flash.family.label attribute not removable'));
     } else {
         $family->removeAttribute($attribute);
         foreach ($family->getAttributeRequirements() as $requirement) {
             if ($requirement->getAttribute() === $attribute) {
                 $family->removeAttributeRequirement($requirement);
                 $this->doctrine->getManagerForClass(ClassUtils::getClass($requirement))->remove($requirement);
             }
         }
         $this->familySaver->save($family);
     }
     if ($this->request->isXmlHttpRequest()) {
         return new Response('', 204);
     } else {
         return new RedirectResponse($this->router->generate('pim_enrich_family_edit', ['id' => $family->getId()]));
     }
 }
开发者ID:userz58,项目名称:pim-community-dev,代码行数:44,代码来源:FamilyController.php

示例2: findAttributeOr404

 /**
  * Find an attribute by its id or return a 404 response
  *
  * @param int $id the attribute id
  *
  * @throws NotFoundHttpException
  *
  * @return AttributeInterface
  */
 protected function findAttributeOr404($id)
 {
     $attribute = $this->attributeRepository->find($id);
     if (!$attribute) {
         throw new NotFoundHttpException(sprintf('Attribute with id %d could not be found.', $id));
     }
     return $attribute;
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:17,代码来源:ProductController.php

示例3: findAttributeOr404

 /**
  * @param int $id
  *
  * @return AttributeInterface
  */
 protected function findAttributeOr404($id)
 {
     $result = $this->attributeRepo->find($id);
     if (!$result) {
         throw new NotFoundHttpException('Attribute not found');
     }
     return $result;
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:13,代码来源:AttributeGroupController.php

示例4: getAttribute

 /**
  * Get an attribute or throw an exception
  *
  * @param int $id
  *
  * @throws EntityNotFoundException
  *
  * @return AttributeInterface
  *
  * @deprecated will be removed in 1.5 please use AttributeRepositoryInterface->find()
  */
 public function getAttribute($id)
 {
     $attribute = $this->repository->find($id);
     if (null === $attribute) {
         throw new EntityNotFoundException();
     }
     return $attribute;
 }
开发者ID:alexisfroger,项目名称:pim-community-dev,代码行数:19,代码来源:AttributeManager.php

示例5: findAttributeOr404

 /**
  * @param int $id
  *
  * @return AttributeInterface
  */
 protected function findAttributeOr404($id)
 {
     $result = $this->attributeRepo->find($id);
     if (!$result) {
         throw $this->createNotFoundException(sprintf('Attribute not found'));
     }
     return $result;
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:13,代码来源:AttributeGroupController.php

示例6: findAttributeOr404

 /**
  * Find an attribute
  *
  * @param int $id
  *
  * @throws NotFoundHttpException
  *
  * @return AttributeInterface
  */
 protected function findAttributeOr404($id)
 {
     $attribute = $this->attributeRepository->find($id);
     if (null === $attribute) {
         throw new NotFoundHttpException(sprintf('%s entity not found', $this->attributeManager->getAttributeClass()));
     }
     return $attribute;
 }
开发者ID:userz58,项目名称:pim-community-dev,代码行数:17,代码来源:AttributeController.php

示例7: findAttributeOr404

 /**
  * Find an attribute
  *
  * @param int $id
  *
  * @throws NotFoundHttpException
  *
  * @return AttributeInterface
  */
 protected function findAttributeOr404($id)
 {
     $attribute = $this->attributeRepository->find($id);
     if (null === $attribute) {
         throw new NotFoundHttpException(sprintf('Attribute %s not found', $id));
     }
     return $attribute;
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:17,代码来源:AttributeController.php

示例8: findAttributeOr404

 /**
  * Find an attribute or throw a 404
  *
  * @param int $id The id of the attribute
  *
  * @throws NotFoundHttpException
  *
  * @return AttributeInterface
  */
 protected function findAttributeOr404($id)
 {
     try {
         $result = $this->attributeRepository->find($id);
     } catch (EntityNotFoundException $e) {
         throw new NotFoundHttpException($e->getMessage());
     }
     return $result;
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:18,代码来源:AttributeOptionController.php

示例9: sortAction

 /**
  * Edit AttributeInterface sort order
  *
  * @param Request $request
  *
  * @AclAncestor("pim_enrich_attribute_sort")
  *
  * @return Response
  */
 public function sortAction(Request $request)
 {
     if (!$request->isXmlHttpRequest()) {
         return $this->redirectToRoute('pim_enrich_attribute_index');
     }
     $data = $request->request->all();
     if (!empty($data)) {
         $attributes = [];
         foreach ($data as $id => $sort) {
             $attribute = $this->attributeRepository->find((int) $id);
             if ($attribute) {
                 $attribute->setSortOrder((int) $sort);
                 $attributes[] = $attribute;
             }
         }
         $this->attributeSaver->saveAll($attributes);
         return new Response(1);
     }
     return new Response(0);
 }
开发者ID:alexisfroger,项目名称:pim-community-dev,代码行数:29,代码来源:AttributeController.php


注:本文中的Pim\Component\Catalog\Repository\AttributeRepositoryInterface::find方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。