Exemple #1
0
 /**
  * Builds the base query for user search
  *
  * @param string $chunk part of the employee name or email
  * @param mixed $role String or array of role names
  * @return object
  */
 protected function getFindUserBaseQueryBuilder($chunk, $role)
 {
     $role = Utils::arrayValuesToUpper($role);
     $q = $this->createQueryBuilder('u')->leftJoin('u.employee', 'e')->innerJoin('u.groups', 'g')->where('e.employeeName LIKE :employeeName')->orWhere('u.email LIKE :email')->andWhere('g.role IN (:role)')->setParameter('employeeName', "%{$chunk}%")->setParameter('email', "%{$chunk}%")->setParameter('role', $role);
     return $q;
 }
Exemple #2
0
 public function testarrayValuesToUpper()
 {
     $arr = array('role_user', 'role_admin');
     $result = Utils::arrayValuesToUpper($arr);
     $this->assertEquals('ROLE_USER', $result[0], 'Utils::arrayValuesToUpper Array input, result is not uppercase.');
     // Test string to array casting
     $value = 'role_admin';
     $result2 = Utils::arrayValuesToUpper($value);
     $this->assertEquals('ROLE_ADMIN', $result2[0], 'Utils::arrayValuesToUpper String input, result is not uppercase.');
 }