Ejemplo n.º 1
0
 /**
  * @param UserEntityInterface $user
  * @param null $limit
  * @param null $offset
  * @return mixed
  */
 public function getChapterByUser(UserEntityInterface $user, $limit = null, $offset = null)
 {
     $qb = $this->createQueryBuilder('ch')->where('ch.author = :author_id')->setParameter('author_id', $user->getId(), TYPE::INTEGER);
     if (is_int($limit)) {
         $qb->setMaxResults($limit);
     }
     if (is_int($offset)) {
         $qb->setFirstResult($offset);
     }
     return $qb->getQuery()->getResult();
 }
Ejemplo n.º 2
0
 public function transform(array $data, UserEntityInterface $user)
 {
     $data['id'] = $user->getId();
     $data['username'] = $user->getUsername();
     $data['userRoles'] = $user->getUserRoles();
     $data['avatar'] = $user->getAvatar();
     if ($user instanceof LecturerInterface) {
         $data['settings'] = $user->getSettings();
     }
     return $data;
 }
Ejemplo n.º 3
0
 /**
  * Checks to see if a publisher has permission to perform an action
  *
  * @param CourseInterface $entity
  * @param UserEntityInterface $user
  * @param $action
  * @return bool
  */
 protected function isPublisherActionAllowed($entity, UserEntityInterface $user, $action)
 {
     return $user->getId() === $entity->getAuthor()->getId();
 }
Ejemplo n.º 4
0
 /**
  * @param UserEntityInterface $user
  * @param $hash
  * @return mixed
  */
 public function getByUserAndHash(UserEntityInterface $user, $hash)
 {
     $qb = $this->createQueryBuilder('t')->where('t.author = :author_id')->andWhere('t.hashTag = :hash')->setParameter('hash', $hash, TYPE::STRING)->setParameter('author_id', $user->getId(), TYPE::INTEGER);
     return $qb->getQuery()->getOneOrNullResult();
 }