Example #1
0
 public function run($slug)
 {
     /**
      * @var Person $person
      */
     $person = CommandBusList::getPersonCommanBus()->handle(new GetCurrentPersonCommand());
     $studio = StudioRepository::getByPerson($person);
     $personBySlug = PersonRepository::getBySlug($slug);
     $isOwner = $person->equalsTo($personBySlug);
     return $this->controller->render($personBySlug->user()->type()->prefix() . '/index', ['controller' => $this->controller, 'person' => $personBySlug, 'studio' => $studio, 'isOwner' => $isOwner]);
 }
Example #2
0
 public function run($slug)
 {
     /**
      * @var Person  $bride
      * @var Wedding $wedding
      */
     $personBySlug = PersonRepository::getBySlug($slug);
     $bride = CommandBusList::getPersonCommanBus()->handle(new GetCurrentPersonCommand());
     $wedding = WeddingRepository::getByBride($personBySlug);
     $groom = PersonRepository::getById($wedding->groomId());
     $isOwner = $bride->equalsTo($personBySlug);
     return $this->controller->render($bride->user()->type()->prefix() . '/index', ['bride' => $personBySlug, 'wedding' => $wedding, 'groom' => $groom, 'isOwner' => $isOwner]);
 }
Example #3
0
 /**
  * @param $slug
  *
  * @return array
  * @throws NotFoundHttpException
  */
 private function getPersonAndSlug($slug)
 {
     if (!$slug) {
         /**
          * @var Person $person
          */
         $person = CommandBusList::getPersonCommanBus()->handle(new GetCurrentPersonCommand());
         $slug = $person->user()->slug();
         return array($person, $slug);
     } else {
         $person = PersonRepository::getBySlug($slug);
         if (!$person) {
             throw new NotFoundHttpException('Пользователь не найден');
         }
         return array($person, $slug);
     }
 }
 public function actionStep2()
 {
     $this->validateSocialNetwork();
     $this->validateRegistrationStep();
     $site = $this->getSocialNetwork();
     $userSocialID = \Yii::$app->session->get('USER')->socialid;
     $userData = $site->getUser($userSocialID);
     $currentUser = \Yii::$app->session->get('USER');
     $personRepository = new PersonRepository();
     if ($model = $personRepository->getById($currentUser->person_id)) {
         \Yii::$app->response->redirect(URL::toRoute('/userDetails'));
         \Yii::$app->end();
     }
     $model = new PersonForm();
     $model->first_name = $userData->first_name;
     $model->last_name = $userData->last_name;
     if ($model->load(\yii::$app->request->post()) && $model->validate()) {
         $person = (new PersonFactory())->createEmpty();
         $person->setFirstName($model->first_name);
         $person->setLastName($model->last_name);
         $person->setPhone($model->phone);
         $person->setEmail($model->email);
         $personRepository->save($person);
         $currentUser->status = User::STATUS_REGISTERED;
         $currentUser->person_id = $person->id();
         $slug = new Slug();
         $slug->createForPerson($person);
         while (PersonRepository::getBySlug($slug->value())) {
             $slug->setValue($slug->value() . substr(time(), -1, 1));
         }
         $currentUser->slug = $slug->value();
         $currentUser->save();
         \yii::$app->user->login($currentUser);
         \yii::$app->session->remove('USER');
         \yii::$app->response->redirect(URL::toRoute('/userDetails'));
         \Yii::$app->end();
     }
     $viewName = 'form';
     return $this->render($viewName, ['model' => $model]);
 }