Beispiel #1
0
 /**
  * prepareCndUserType
  *
  * @param \Doctrine\ORM\QueryBuilder $queryBuilder QueryBuilder instance
  * @param mixed                      $value        Searchable value
  *
  * @return void
  */
 protected function prepareCndUserType(\Doctrine\ORM\QueryBuilder $queryBuilder, $value)
 {
     $roles = array();
     if (!is_array($value)) {
         $value = array($value);
     }
     $condition = $queryBuilder->expr()->orX();
     foreach ($value as $selectedType) {
         if (is_numeric($selectedType)) {
             $roles[] = $selectedType;
         } elseif ('C' == $selectedType) {
             $condition->add($queryBuilder->expr()->andX($queryBuilder->getRegisteredCondition(), $queryBuilder->getCustomerCondition()));
             $queryBuilder->setParameter('anonymous', true)->setParameter('adminAccessLevel', \XLite\Core\Auth::getInstance()->getAdminAccessLevel());
         } elseif ('N' == $selectedType) {
             $condition->add($queryBuilder->expr()->andX($queryBuilder->getAnonymousCondition(), $queryBuilder->getCustomerCondition()));
             $queryBuilder->setParameter('anonymous', true)->setParameter('adminAccessLevel', \XLite\Core\Auth::getInstance()->getAdminAccessLevel());
         }
     }
     if ($roles) {
         $condition->add($queryBuilder->expr()->andX($queryBuilder->getRegisteredCondition(), $queryBuilder->getAdminCondition(), $queryBuilder->getRolesCondition($roles)));
         $queryBuilder->linkLeft('p.roles')->setParameter('anonymous', true)->setParameter('adminAccessLevel', \XLite\Core\Auth::getInstance()->getAdminAccessLevel());
     }
     if ($condition->count()) {
         $queryBuilder->andWhere($condition);
     }
 }