示例#1
0
 /**
  * @return array
  */
 public function getRouteListIndexedByTarget()
 {
     $routes = array();
     foreach ($this->routeDao->findBy(array(), array("oneWay" => "ASC", "id" => "DESC")) as $route) {
         $routes[$route->target->id][$route->id] = $route;
     }
     return $routes;
 }
示例#2
0
 /**
  * @return Nette\Utils\ArrayHash
  */
 public function findAllByKeys()
 {
     $keys = $this->dao->findBy([]);
     $result = [];
     foreach ($keys as $key) {
         $result[$key->key] = is_numeric($key->value) ? (double) $key->value : $key->value;
     }
     return Nette\Utils\ArrayHash::from($result);
 }
示例#3
0
 /**
  * @param string $name
  * @param string $email
  * @param string $password
  * @param Role[]|string[] $roles
  */
 public function create($name, $email, $password, $roles = [])
 {
     $user = new User();
     $user->name = $name;
     $user->email = $email;
     $this->passwordStrategy->setPassword($user, $password);
     $roles = (array) $roles;
     foreach ($roles as $role) {
         if (is_string($role)) {
             if (!($role = $this->rolesRepository->findBy(['name' => $role]))) {
                 throw new \RuntimeException("Unknown role '{$role}'.");
             }
         } elseif (!$role instanceof Role) {
             throw new \UnexpectedValueException("Role must be string or instance of Rixxi\\User\\Entities\\Role");
         }
         $user->roles->add($role);
     }
     $this->repository->save($user);
     return $user;
 }
示例#4
0
 function getStaticPageAbbr($abbr, $useCache = true)
 {
     try {
         if (!$useCache) {
             return $this->pageDao->findBy(["abbr" => $abbr]);
         }
         $cache = $this->getEntityCache();
         $data = $cache->load($abbr);
         if (empty($data)) {
             $data = $this->pageDao->findBy(["abbr" => $abbr])[0];
             // abbr is unique
             $opt = [Cache::TAGS => [$this->getEntityClassName(), self::ENTITY_COLLECTION, self::SELECT_COLLECTION, $abbr, $data->getId()]];
             $cache->save($abbr, $data, $opt);
         }
         return $data;
     } catch (\Exception $ex) {
         $this->logError($ex->getMessage());
         throw new Exceptions\DataErrorException($ex->getMessage(), $ex->getCode(), $ex->getPrevious());
     }
 }
示例#5
0
 public function getUserPositions(User $user, $useCache = true)
 {
     if ($user === null) {
         throw new Exceptions\NullPointerException("Argument User cannot be null");
     }
     try {
         $id = User::getClassName() . "-" . $user->getId();
         $cache = $this->getEntityCache();
         $data = $cache->load($id);
         if (!$useCache) {
             return $this->positionDao->findBy(array("owner" => $user->getId()));
         }
         if ($data == null) {
             $data = $this->positionDao->findBy(array("owner" => $user->getId()));
             $opts = [Cache::TAGS => [self::ENTITY_COLLECTION, $id], Cache::SLIDING => true];
             $cache->save($id, $data, $opts);
         }
         return $data;
     } catch (\Exception $e) {
         $this->logError($e);
         throw new Exceptions\DataErrorException($e->getMessage(), $e->getCode(), $e->getPrevious());
     }
 }
示例#6
0
 /**
  * @return array
  */
 public function findBy(array $criteria, array $orderBy = NULL, $limit = NULL, $offset = NULL)
 {
     return $this->dao->findBy($criteria, $orderBy, $limit, $offset);
 }
示例#7
0
 /**
  * @param $orderBy array
  * @return array
  */
 public function getAll(array $orderBy = null)
 {
     return $this->dao->findBy([], $orderBy);
 }
示例#8
0
 /**
  * @param  array                 $criteria
  * @param  array                 $orderBy
  * @param  int                   $limit
  * @param  int                   $offset
  * @return Entities\BaseEntity[]
  */
 public function getAll(array $criteria = array(), array $orderBy = null, $limit = null, $offset = null)
 {
     return $this->dao->findBy($criteria, $orderBy, $limit, $offset);
 }
示例#9
0
 private function getAllSportTypesHelper($active)
 {
     return $this->sportTypeDao->findBy(is_bool($active) ? ["active" => $active] : [], ["name" => "ASC"]);
 }