示例#1
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.");
     }
 }
 /**
  * @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']);
 }
示例#3
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()]);
 }
示例#4
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();
 }
示例#5
0
 /**
  * @todo: wtf? fixme! targetClass?
  * @param \Kdyby\Doctrine\Forms\CollectionContainer $container
  * @param array $values
  */
 public function getCollectionEntry(CollectionContainer $container, $values)
 {
     $parentEntity = $container->getParent()->getData();
     if (!($ids = $this->getValuesIds($parentEntity, $values))) {
         return NULL;
     }
     $entity = $this->doctrine->getRepository(get_class($parentEntity))->find($ids);
     return $container->getCollection()->contains($entity) ? $entity : NULL;
 }
示例#6
0
 private function getHydrateQuery()
 {
     return $this->registry->getRepository(Screenplay::class)->createQueryBuilder('s')->andWhere('s.id IN(:ids)');
 }
示例#7
0
 /**
  * @param Registry $registry
  */
 public function __construct(Registry $registry)
 {
     $this->charactersRepository = $registry->getRepository(Character::class);
 }
示例#8
0
 /**
  * @param int $id
  * @param Registry $registry
  */
 public function __construct($id, Registry $registry)
 {
     parent::__construct();
     $this->screenplay = $registry->getRepository(Screenplay::class)->getReference($id);
 }
示例#9
0
 /**
  * @return Role[]
  */
 public function getAll() : array
 {
     return $this->registry->getRepository(Role::class)->findAll();
 }
示例#10
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();
 }
示例#11
0
 /**
  * @param Registry $registry
  */
 public function __construct(Registry $registry)
 {
     $this->languagesRepository = $registry->getRepository(Language::class);
 }