예제 #1
0
 /**
  * Find line item with the same product and unit
  *
  * @param LineItem $lineItem
  *
  * @return LineItem
  */
 public function findDuplicate(LineItem $lineItem)
 {
     $qb = $this->createQueryBuilder('li')->where('li.product = :product')->andWhere('li.unit = :unit')->andWhere('li.shoppingList = :shoppingList')->setParameter('product', $lineItem->getProduct())->setParameter('unit', $lineItem->getUnit())->setParameter('shoppingList', $lineItem->getShoppingList());
     if ($lineItem->getId()) {
         $qb->andWhere('li.id != :currentId')->setParameter('currentId', $lineItem->getId());
     }
     return $qb->getQuery()->getOneOrNullResult();
 }
 /**
  * @param LineItem $data
  * @param ExecutionContextInterface $context
  */
 public function checkShoppingListLabel($data, ExecutionContextInterface $context)
 {
     if (!$data->getShoppingList()) {
         $context->buildViolation('orob2b.shoppinglist.not_empty')->atPath('shoppingListLabel')->addViolation();
     }
 }