Ejemplo n.º 1
0
 public function __construct(EntityManager $em)
 {
     parent::__construct($em, User::getClassName());
     $this->userDao = $em->getDao(User::getClassName());
     $this->addressDao = $em->getDao(Address::getClassName());
     $this->contactDao = $em->getDao(Contact::getClassName());
     $this->webProfileDao = $em->getDao(WebProfile::getClassName());
 }
Ejemplo n.º 2
0
 public function getUserRoles(User $user, $useCache = true)
 {
     if ($user === null) {
         throw new NullPointerException("Argument User cannot be null");
     }
     try {
         if (!$useCache) {
             return $this->positionDao->findBy(array("owner" => $user->getId()));
         }
         $id = User::getClassName() . "-" . $user->getId();
         $cache = $this->getEntityCache();
         $data = $cache->load($id);
         if ($data === null) {
             $coll = $this->positionDao->findBy(array("owner" => $user->getId()));
             foreach ($coll as $p) {
                 $data[] = $p->getRole()->getName();
             }
             $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());
     }
 }
Ejemplo n.º 3
0
 public function getPositionsWithinGroup(SportGroup $g, $useCache = true)
 {
     try {
         $qb = $this->positionDao->createQueryBuilder();
         $qb->select("p")->from("App\\Model\\Entities\\Position", "p")->where("p.group = :group")->setParameter("group", $g);
         $q = $qb->getQuery();
         if (!$useCache) {
             return $q->getResult();
         }
         $id = User::getClassName() . "in" . SportGroup::getClassName() . "-" . $g->getId();
         $cache = $this->getEntityCache();
         $data = $cache->load($id);
         if ($data == null) {
             $data = $q->getResult();
             $opts = [Cache::TAGS => [self::ENTITY_COLLECTION, self::STRANGER_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());
     }
 }