Author: Adam Piotrowski (adam@wellcommerce.org)
Inheritance: extends WellCommerce\Bundle\CoreBundle\Repository\RepositoryInterface
 /**
  * Returns attribute by id
  *
  * @param int $attributeId
  *
  * @return \WellCommerce\Bundle\AttributeBundle\Entity\AttributeInterface
  */
 protected function findAttribute($attributeId)
 {
     $id = $this->getRequestHelper()->getRequestBagParam('attribute');
     $attribute = $this->attributeRepository->find($id);
     if (null === $attribute) {
         throw new AttributeNotFoundException($attributeId);
     }
     return $attribute;
 }
示例#2
0
 /**
  * Returns all attributes in group
  *
  * @param int $id
  *
  * @return \Doctrine\Common\Collections\Collection
  */
 public function findAttributesByAttributeGroupId($id)
 {
     $attributeGroup = $this->findAttributeGroup($id);
     $criteria = new Criteria();
     $criteria->where($criteria->expr()->eq('attributeGroup', $attributeGroup));
     return $this->repository->matching($criteria);
 }
 /**
  * Creates an attribute or returns the existing one
  *
  * @param int                     $id
  * @param string                  $name
  * @param AttributeGroupInterface $group
  *
  * @return AttributeInterface
  */
 public function getAttribute($id, $name, AttributeGroupInterface $group)
 {
     $attribute = $this->repository->find($id);
     if (null === $attribute) {
         $attribute = $this->createNewAttribute($name, $group);
     }
     return $attribute;
 }