globalParam = $globalParam; parent::__construct($entityManager, $entityManager->getClassMetadata($this->getInterfaceClass())); } public function findByMerchantQuery($merchant) { return $this->createQueryBuilder('e') ->where('e.merchant = :currentMerchant') ->setParameter('currentMerchant', $merchant->getId()) ; } public function findAll() { return $this->findBy(array()); } public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) { $className = $this->getClassMetadata()->getName(); $entity = new $className; if($entity instanceof StatusInterface){ if (!isset($criteria['status'])) $criteria['status'] = 1; if ($criteria['status'] === false) unset($criteria['status']); } if($entity instanceof FilterMerchantInterface){ if (!isset($criteria['merchant'])) $criteria['merchant'] = $this->globalParam->getCurrentMerchant(); if ($criteria['merchant'] === false) unset($criteria['merchant']); } return parent::findBy($criteria, $orderBy, $limit, $offset); } public function findOneBy(array $criteria, array $orderBy = null) { $className = $this->getClassMetadata()->getName(); $entity = new $className; if($entity instanceof StatusInterface){ if (!isset($criteria['status'])) $criteria['status'] = 1; if ($criteria['status'] === false) unset($criteria['status']); } if($entity instanceof FilterMerchantInterface){ if (!isset($criteria['merchant'])) $criteria['merchant'] = $this->globalParam->getCurrentMerchant(); if ($criteria['merchant'] === false) unset($criteria['merchant']); } return parent::findOneBy($criteria, $orderBy); } }