Author: Filip Procházka (filip@prochazka.su)
Inheritance: extends Doctrine\Common\Persistence\AbstractManagerRegistry
Exemplo n.º 1
0
 /**
  * @param string $entityName
  * @param array $data
  * @return Screenplay
  */
 public function deserialize($entityName, $data)
 {
     if (!isset($data['id'])) {
         throw new LogicException();
     }
     return $this->registry->getRepository(Screenplay::class)->getReference($data['id']);
 }
Exemplo n.º 2
0
 /**
  * @param Client $client
  * @param MappingCreator $mappingCreator
  * @param Registry $registry
  */
 public function __construct(Client $client, MappingCreator $mappingCreator, Registry $registry)
 {
     $this->client = $client;
     $this->mappingCreator = $mappingCreator;
     $this->indicesRepository = $registry->getRepository(Index::class);
     $this->entityManager = $registry->getManager();
 }
Exemplo n.º 3
0
 /**
  * @param string $email
  * @throws UserAlreadyExistsException
  */
 protected function validateUserDoesNotExists(string $email)
 {
     $userRepository = $this->registry->getRepository(User::class);
     if ($userRepository->findOneBy(['email' => $email]) !== null) {
         throw new UserAlreadyExistsException("User with email '{$email}' already exists.");
     }
 }
Exemplo n.º 4
0
 /**
  * @inheritdoc
  */
 public function authenticate(array $credentials)
 {
     list($email, $password) = $credentials;
     $email = UserTools::sanitizeUserEmail($email);
     /** @var User|null $user */
     $user = $this->registry->getRepository(User::class)->findOneBy(['email' => $email]);
     if ($user === null) {
         throw new AuthenticationException("User '{$email}' not found.");
     }
     if (!Passwords::verify($password, $user->getPassword())) {
         throw new AuthenticationException('Invalid password.');
     }
     return new Identity($user->getId(), $user->getUserRoles(), ['username' => $user->getEmail()]);
 }
 /**
  * @param string $data
  * @return AuthorizationRequest
  */
 public function unserialize(string $data) : AuthorizationRequest
 {
     $manager = $this->registry->getManager();
     /** @var AuthorizationRequest $authorizationRequest */
     $authorizationRequest = unserialize($data);
     if ($client = $authorizationRequest->getClient()) {
         $authorizationRequest->setClient($manager->merge($client));
     }
     $scopes = [];
     foreach ($authorizationRequest->getScopes() as $scope) {
         $scopes[] = $manager->merge($scope);
     }
     $authorizationRequest->setScopes($scopes);
     return $authorizationRequest;
 }
Exemplo n.º 6
0
 /**
  * @param object|string $entity
  * @return \Kdyby\Doctrine\Mapping\ClassMetadata
  */
 public function getMeta($entity)
 {
     $className = is_object($entity) ? get_class($entity) : $entity;
     if (!isset($this->meta[$className])) {
         $this->meta[$className] = $this->doctrine->getClassMetadata($className);
     }
     return $this->meta[$className];
 }
 /**
  * @param string $tokenId
  * @return bool
  * @throws InvalidStateException
  * @throws QueryException
  */
 public function isRefreshTokenRevoked($tokenId)
 {
     /** @var RefreshTokenEntity $refreshTokenEntity */
     $refreshTokenEntity = $this->registry->getManager()->getRepository(RefreshTokenEntity::class)->fetchOne($this->createQuery()->byIdentifier($tokenId));
     return $refreshTokenEntity ? $refreshTokenEntity->isRevoked() : true;
 }
Exemplo n.º 8
0
 /**
  * @param Registry $registry
  */
 public function __construct(Registry $registry)
 {
     $this->charactersRepository = $registry->getRepository(Character::class);
 }
Exemplo n.º 9
0
 /**
  * @param int $id
  * @param Registry $registry
  */
 public function __construct($id, Registry $registry)
 {
     parent::__construct();
     $this->screenplay = $registry->getRepository(Screenplay::class)->getReference($id);
 }
Exemplo n.º 10
0
 /**
  * @return Role[]
  */
 public function getAll() : array
 {
     return $this->registry->getRepository(Role::class)->findAll();
 }
Exemplo n.º 11
0
 /**
  * @param Client $client
  * @param Registry $registry
  */
 public function __construct(Client $client, Registry $registry)
 {
     $this->client = $client;
     $this->indicesRepository = $registry->getRepository(IndexEntity::class);
     $this->entityManager = $registry->getManager();
 }
 /**
  * @param string $identifier
  * @return ScopeEntity|null
  * @throws InvalidStateException
  * @throws QueryException
  */
 public function getScopeEntityByIdentifier($identifier)
 {
     return $this->registry->getManager()->getRepository(ScopeEntity::class)->fetchOne($this->createQuery()->byIdentifier($identifier));
 }
 /**
  * @param string $tokenId
  * @return bool
  * @throws InvalidStateException
  * @throws QueryException
  */
 public function isAccessTokenRevoked($tokenId)
 {
     /** @var AccessTokenEntity|null $accessTokenEntity */
     $accessTokenEntity = $this->registry->getManager()->getRepository(AccessTokenEntity::class)->fetchOne($this->createQuery()->byIdentifier($tokenId));
     return $accessTokenEntity ? $accessTokenEntity->isRevoked() : true;
 }
 /**
  * @param string $clientIdentifier
  * @param string $grantType
  * @param string|null $clientSecret
  * @param bool $mustValidateSecret
  * @return ClientEntity|null
  * @throws InvalidStateException
  * @throws QueryException
  */
 public function getClientEntity($clientIdentifier, $grantType, $clientSecret = null, $mustValidateSecret = true)
 {
     /** @var ClientEntity|null $clientEntity */
     $clientEntity = $this->registry->getManager()->getRepository(ClientEntity::class)->fetchOne($this->createQuery()->byIdentifier($clientIdentifier));
     return $clientEntity && $mustValidateSecret && $clientEntity->getSecret() !== null && !call_user_func($this->secretValidator, $clientEntity->getSecret(), $clientSecret) ? null : $clientEntity;
 }
Exemplo n.º 15
0
 /**
  * @param Registry $registry
  */
 public function __construct(Registry $registry)
 {
     $this->languagesRepository = $registry->getRepository(Language::class);
 }
Exemplo n.º 16
0
 /**
  * @param Role $role
  * @param User $user
  * @return UserRole
  */
 private function assign(Role $role, User $user) : UserRole
 {
     $userRole = new UserRole($user, $role);
     $this->registry->getManager()->persist($userRole)->flush($userRole);
     return $userRole;
 }
Exemplo n.º 17
0
 private function getHydrateQuery()
 {
     return $this->registry->getRepository(Screenplay::class)->createQueryBuilder('s')->andWhere('s.id IN(:ids)');
 }
 /**
  * @param string $codeId
  * @return bool
  * @throws InvalidStateException
  * @throws QueryException
  */
 public function isAuthCodeRevoked($codeId)
 {
     /** @var AuthCodeEntity|null $authCodeEntity */
     $authCodeEntity = $this->registry->getManager()->getRepository(AuthCodeEntity::class)->fetchOne($this->createQuery()->byIdentifier($codeId));
     return $authCodeEntity ? $authCodeEntity->isRevoked() : true;
 }