public function execute() { if (strlen($this->login) < self::MinLength) { throw new InvalidArgumentException('Search key too small'); } $condition = new Request(); $condition->likeFields = ['login' => $this->login]; $condition->limit = self::Limit; $found = $this->repository->find($condition); return $found; }
protected function validateEmail() { if (empty($this->user->email->getValue())) { return; } $searchRequest = new Request(); $searchRequest->fields = ['email' => $this->user->email->getValue()]; $found = $this->repositoryInterface->findOne($searchRequest); if (!empty($found)) { throw new UserAlreadyExistsException('Email already registered'); } }
/** * @return \Extasy\Users\User */ protected function getUser() { if (empty($this->confirmationCode)) { throw new InvalidArgumentException('Confirmation code couldn`t be empty'); } $request = new Request(); $request->fields = ['confirmation_code' => $this->confirmationCode]; $found = $this->repository->findOne($request); if (empty($found)) { throw new NotFoundException('User not found'); } return $found; }
protected function fixtureUsers($data) { foreach ($data as $user) { $this->repository->insert($user); } }
protected function action() { $this->repository->delete($this->user); }