소스 검색

Refactoring frontend #870

refactoring
Guillaume Bourgeois 1 년 전
부모
커밋
e209225b38
15개의 변경된 파일517개의 추가작업 그리고 403개의 파일을 삭제
  1. +1
    -2
      backend/controllers/SiteController.php
  2. +12
    -0
      common/components/BusinessLogic.php
  3. +19
    -0
      common/containers/ProducerPriceRangeContainer.php
  4. +19
    -0
      common/containers/UserProducerContainer.php
  5. +10
    -2
      common/controllers/CommonController.php
  6. +1
    -1
      common/forms/ContactForm.php
  7. +1
    -1
      common/forms/LoginForm.php
  8. +0
    -11
      common/models/Producer.php
  9. +13
    -0
      common/repositories/ProducerPriceRangeRepository.php
  10. +21
    -2
      common/repositories/ProducerRepository.php
  11. +21
    -0
      common/repositories/UserProducerRepository.php
  12. +12
    -0
      common/services/ProducerPriceRangeService.php
  13. +12
    -0
      common/services/UserProducerService.php
  14. +374
    -384
      frontend/controllers/SiteController.php
  15. +1
    -0
      producer/controllers/SiteController.php

+ 1
- 2
backend/controllers/SiteController.php 파일 보기

@@ -41,8 +41,7 @@ namespace backend\controllers;
use common\helpers\GlobalParam;
use Yii;
use yii\filters\AccessControl;
use yii\web\Controller;
use common\models\LoginForm;
use common\forms\LoginForm;
use common\models\User;
use yii\filters\VerbFilter;
use common\models\Product;

+ 12
- 0
common/components/BusinessLogic.php 파일 보기

@@ -2,8 +2,10 @@

namespace common\components;

use common\containers\ProducerPriceRangeContainer;
use common\containers\UserContainer;
use common\containers\ProducerContainer;
use common\containers\UserProducerContainer;

class BusinessLogic
{
@@ -16,4 +18,14 @@ class BusinessLogic
{
return new ProducerContainer();
}

public function getProducerPriceRangeContainer()
{
return new ProducerPriceRangeContainer();
}

public function getUserProducerContainer()
{
return new UserProducerContainer();
}
}

+ 19
- 0
common/containers/ProducerPriceRangeContainer.php 파일 보기

@@ -0,0 +1,19 @@
<?php

namespace common\containers;

use common\repositories\ProducerPriceRangeRepository;
use common\services\ProducerPriceRangeService;

class ProducerPriceRangeContainer
{
public function getService()
{
return new ProducerPriceRangeService();
}

public function getRepository()
{
return new ProducerPriceRangeRepository();
}
}

+ 19
- 0
common/containers/UserProducerContainer.php 파일 보기

@@ -0,0 +1,19 @@
<?php

namespace common\containers;

use common\repositories\UserProducerRepository;
use common\services\UserProducerService;

class UserProducerContainer
{
public function getService()
{
return new UserProducerService();
}

public function getRepository()
{
return new UserProducerRepository();
}
}

+ 10
- 2
common/controllers/CommonController.php 파일 보기

@@ -42,7 +42,6 @@ use yii;

class CommonController extends \yii\web\Controller
{

public function beforeAction($event)
{
if (!Yii::$app->user->isGuest) {
@@ -51,7 +50,16 @@ class CommonController extends \yii\web\Controller

return parent::beforeAction($event);
}

public function getLogic()
{
return Yii::$app->logic;
}

public function setFlash($key, $value = true, $removeAfterAccess = true)
{
Yii::$app->session->setFlash($key, $value, $removeAfterAccess);
}
}

?>

common/models/ContactForm.php → common/forms/ContactForm.php 파일 보기

@@ -36,7 +36,7 @@ pris connaissance de la licence CeCILL, et que vous en avez accepté les
termes.
*/

namespace common\models;
namespace common\forms;

use Yii;
use yii\base\Model;

common/models/LoginForm.php → common/forms/LoginForm.php 파일 보기

@@ -36,7 +36,7 @@ pris connaissance de la licence CeCILL, et que vous en avez accepté les
termes.
*/

namespace common\models;
namespace common\forms;

use Yii;
use yii\base\Model;

+ 0
- 11
common/models/Producer.php 파일 보기

@@ -830,17 +830,6 @@ class Producer extends ActiveRecordCommon
return $this->getPrivateKeyStripe($this->getFilenamePrivateKeyEndpointStripe());
}

/**
* Retourne le compte producteur de démonstration.
*
* @return Producer
*/
public static function getDemoAccount()
{
$producer = Producer::find()->where('name LIKE \'Démo\'')->one();
return $producer;
}

/**
* Retourne true si le compte est un compte de démo.
*

+ 13
- 0
common/repositories/ProducerPriceRangeRepository.php 파일 보기

@@ -0,0 +1,13 @@
<?php

namespace common\repositories;

use common\models\ProducerPriceRange;

class ProducerPriceRangeRepository
{
public function query()
{
return ProducerPriceRange::find()->orderBy('range_begin ASC');
}
}

+ 21
- 2
common/repositories/ProducerRepository.php 파일 보기

@@ -8,11 +8,30 @@ class ProducerRepository
{
public function getOneById($id)
{
return Producer::find()->where(['id' => $id])->one();;
return Producer::searchOne(['id' => $id]);
}

public function getOneBySlug($slug)
{
return Producer::findOne($slug);
return Producer::searchOne(['slug' => $slug]);
}

public function queryActive()
{
return Producer::find()
->where([
'active' => true,
])
->orderBy('name ASC');
}

/**
* Retourne le compte producteur de démonstration.
*
* @return Producer
*/
public function getDemoAccount()
{
return Producer::find()->where('name LIKE \'Démo\'')->one();
}
}

+ 21
- 0
common/repositories/UserProducerRepository.php 파일 보기

@@ -0,0 +1,21 @@
<?php

namespace common\repositories;

use common\models\User;
use common\models\UserProducer;

class UserProducerRepository
{
public function getBy($idUser, $active = 1, $bookmark = 1)
{
return UserProducer::find()
->with(['producer'])
->where([
'id_user' => $idUser,
'active' => $active,
'bookmark' => $bookmark
])
->all();
}
}

+ 12
- 0
common/services/ProducerPriceRangeService.php 파일 보기

@@ -0,0 +1,12 @@
<?php

namespace common\services;

use common\helpers\Password;
use common\models\Producer;
use common\models\UserProducer;

class ProducerPriceRangeService
{

}

+ 12
- 0
common/services/UserProducerService.php 파일 보기

@@ -0,0 +1,12 @@
<?php

namespace common\services;

use common\helpers\Password;
use common\models\Producer;
use common\models\UserProducer;

class UserProducerService
{

}

+ 374
- 384
frontend/controllers/SiteController.php 파일 보기

@@ -38,438 +38,428 @@

namespace frontend\controllers;

use common\models\ProducerPriceRange;
use common\models\User;
use Yii;
use common\models\Product;
use common\models\LoginForm;
use common\models\Producer;
use frontend\models\PasswordResetRequestForm;
use frontend\models\ResetPasswordForm;
use frontend\models\SignupForm;
use common\models\ContactForm;
use common\forms\ContactForm;
use yii\base\InvalidParamException;
use yii\data\ActiveDataProvider;
use yii\web\BadRequestHttpException;
use yii\web\Controller;
use yii\filters\VerbFilter;
use yii\filters\AccessControl;
use yii\helpers\Html;
use frontend\controllers\FrontendController;
use common\models\UserProducer;
use dosamigos\leaflet\types\LatLng;
use dosamigos\leaflet\layers\Marker;
use dosamigos\leaflet\layers\TileLayer;
use dosamigos\leaflet\LeafLet;
use dosamigos\leaflet\widgets\Map;
use common\forms\LoginForm;

/**
* Site controller
*/
class SiteController extends FrontendController
{

/**
* @inheritdoc
*/
public function behaviors()
{
return [
'access' => [
'class' => AccessControl::className(),
'only' => ['logout', 'signup'],
'rules' => [
[
'actions' => ['signup'],
'allow' => true,
'roles' => ['?'],
],
[
'actions' => ['logout'],
'allow' => true,
'roles' => ['@'],
],
],
],
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'logout' => ['get'],
],
],
];
/**
* @inheritdoc
*/
public function behaviors()
{
return [
'access' => [
'class' => AccessControl::className(),
'only' => ['logout', 'signup'],
'rules' => [
[
'actions' => ['signup'],
'allow' => true,
'roles' => ['?'],
],
[
'actions' => ['logout'],
'allow' => true,
'roles' => ['@'],
],
],
],
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'logout' => ['get'],
],
],
];
}

/**
* @inheritdoc
*/
public function actions()
{
return [
'captcha' => [
'class' => 'yii\captcha\CaptchaAction',
'fixedVerifyCode' => YII_ENV_TEST ? 'testme' : null,
],
];
}

/**
* Affiche la page d'erreur.
*
* @return mixed
*/
public function actionError()
{
$exception = Yii::$app->errorHandler->exception;

if ($exception->getMessage() == 'Producteur introuvable'
|| Yii::$app->getRequest()->getQueryParam('producer_not_found')) {
return $this->render('error-404-producer', ['exception' => $exception]);
}

/**
* @inheritdoc
*/
public function actions()
{
return [
'captcha' => [
'class' => 'yii\captcha\CaptchaAction',
'fixedVerifyCode' => YII_ENV_TEST ? 'testme' : null,
],
];
if ($exception !== null) {
return $this->render('error', ['exception' => $exception]);
}

/**
* Affiche la page d'erreur.
*
* @return mixed
*/
public function actionError()
{
$exception = Yii::$app->errorHandler->exception;

if ($exception->getMessage() == 'Producteur introuvable' || Yii::$app->getRequest()->getQueryParam('producer_not_found')) {
return $this->render('error-404-producer', ['exception' => $exception]);
}

if ($exception !== null) {
return $this->render('error', ['exception' => $exception]);
}
}

/**
* Affiche la page d'accueil.
*
* @return mixed
*/
public function actionIndex()
{
return $this->render('index', [
'producerDemoAccount' => Producer::getDemoAccount(),
'dataProviderPrices' => $this->getDataProviderPrices()
]);
}

/**
* Affiche la page d'accueil.
*
* @return mixed
*/
public function actionIndex()
{
$producerRepository = $this->getLogic()->getProducerContainer()->getRepository();

return $this->render('index', [
'producerDemoAccount' => $producerRepository->getDemoAccount(),
'dataProviderPrices' => $this->getDataProviderPrices()
]);
}

/**
* Page de présentation des tarifs
*
* @return mixed
*/
public function actionPrices()
{
return $this->render('prices', [
'dataProviderPrices' => $this->getDataProviderPrices()
]);
}

public function getDataProviderPrices()
{
$producerPriceRangeRepository = $this->getLogic()->getProducerPriceRangeContainer()->getRepository();

return new ActiveDataProvider([
'query' => $producerPriceRangeRepository->query(),
'pagination' => [
'pageSize' => 100,
],
]);
}

/**
* Liste les producteurs utilisant la plateforme.
*
* @return mixed
*/
public function actionProducers()
{
$producerRepository = $this->getLogic()->getProducerContainer()->getRepository();

$dataProviderProducers = new ActiveDataProvider([
'query' => $producerRepository->queryActive(),
'pagination' => [
'pageSize' => 100,
],
]);

return $this->render('producers', [
'dataProviderProducers' => $dataProviderProducers
]);
}

/**
* Affiche les mentions légales.
*
* @return mixed
*/
public function actionMentions()
{
return $this->render('mentions');
}

/**
* Affiche la page de connexion et traite le formulaire de connexion.
*
* @return mixed
*/
public function actionLogin()
{
if (!\Yii::$app->user->isGuest) {
return Yii::$app->getResponse()->redirect(['site/index']);
}

/**
* Page de présentation des tarifs
*
* @return mixed
*/
public function actionPrices()
{
return $this->render('prices', [
'dataProviderPrices' => $this->getDataProviderPrices()
$model = new LoginForm();
if ($model->load(Yii::$app->request->post()) && $model->login()) {
$returnUrl = Yii::$app->request->get('return_url');
if ($returnUrl) {
return $this->redirect($returnUrl);
}
else {
$userProducerArray = $this->getLogic()->getUserProducerContainer()->getBy(User::getCurrentId());

if ($userProducerArray && is_array($userProducerArray) && count($userProducerArray) == 1) {
return $this->redirect(Yii::$app->urlManagerProducer->createAbsoluteUrl(['site/index', 'slug_producer' => $userProducerArray[0]->producer->slug]));
} else {
return $this->goBack();
}
}
} else {
return $this->render('@frontend/views/site/login', [
'model' => $model,
]);
}

public function getDataProviderPrices(){
return new ActiveDataProvider([
'query' => ProducerPriceRange::find()
->orderBy('id ASC'),
'pagination' => [
'pageSize' => 100,
],
]);
}

/**
* Liste les producteurs utilisant la plateforme.
*
* @return mixed
*/
public function actionProducers()
{
$dataProviderProducers = new ActiveDataProvider([
'query' => Producer::find()
->where([
'active' => true,
])
->orderBy('name ASC'),
'pagination' => [
'pageSize' => 100,
],
]);

return $this->render('producers', [
'dataProviderProducers' => $dataProviderProducers
]);
}

/**
* Déconnecte l'utilisateur.
*
* @return mixed
*/
public function actionLogout()
{
Yii::$app->user->logout();
return $this->goHome();
}

/**
* Affiche la page de contact et traite le formulaire s'il est soumis.
*
* @return mixed
*/
public function actionContact()
{
$model = new ContactForm();

if ($model->load(Yii::$app->request->post()) && $model->validate()) {
if ($model->sendEmail(Yii::$app->params['adminEmail'])) {
$this->setFlash('success', 'Votre message a bien été envoyé. Nous vous répondrons dès que possible.');
}
else {
$this->setFlash('error', 'Il y a eu une erreur lors de l\'envoi de votre message.');
}

return $this->refresh();
}

/**
* Affiche les mentions légales.
*
* @return mixed
*/
public function actionMentions()
{
return $this->render('mentions');
else {
return $this->render('contact', [
'model' => $model,
]);
}

/**
* Affiche la page de connexion et traite le formulaire de connexion.
*
* @return mixed
*/
public function actionLogin()
{
if (!\Yii::$app->user->isGuest) {
return Yii::$app->getResponse()->redirect(['site/index']);
}

$model = new LoginForm();
if ($model->load(Yii::$app->request->post()) && $model->login()) {
$returnUrl = Yii::$app->request->get('return_url');
if ($returnUrl) {
return $this->redirect($returnUrl);
}

/**
* Affiche la page d'inscription et traite son formulaire.
*
* @return mixed
*/
public function actionSignup()
{
$model = new SignupForm();
if ($model->load(Yii::$app->request->post())) {
$user = $model->signup();

if ($user) {
if (Yii::$app->getUser()->login($user)) {
if ($model->option_user_producer == 'producer') {
$this->redirect(Yii::$app->urlManagerBackend->createAbsoluteUrl(['site/index']));
} else {
$producer = Producer::findOne($model->id_producer);
if ($producer) {
$this->redirect(Yii::$app->urlManagerProducer->createAbsoluteUrl(['site/index', 'slug_producer' => $producer->slug]));
} else {
$userProducerArray = UserProducer::find()
->with(['producer'])
->where(['id_user' => User::getCurrentId(), 'active' => 1, 'bookmark' => 1])
->all();

if ($userProducerArray && is_array($userProducerArray) && count($userProducerArray) == 1) {
return $this->redirect(Yii::$app->urlManagerProducer->createAbsoluteUrl(['site/index', 'slug_producer' => $userProducerArray[0]->producer->slug]));
} else {
return $this->goBack();
}
$this->redirect(['site/index']);
}
} else {
return $this->render('@frontend/views/site/login', [
'model' => $model,
]);
}
}
}
}

/**
* Déconnecte l'utilisateur.
*
* @return mixed
*/
public function actionLogout()
{
Yii::$app->user->logout();
return $this->goHome();
}
/**
* Affiche la page de contact et traite le formulaire s'il est soumis.
*
* @return mixed
*/
public function actionContact()
{
$model = new ContactForm();
if ($model->load(Yii::$app->request->post()) && $model->validate()) {
if ($model->sendEmail(Yii::$app->params['adminEmail'])) {
Yii::$app->session->setFlash('success', 'Votre message a bien été envoyé. Nous vous répondrons dès que possible.');
} else {
Yii::$app->session->setFlash('error', 'Il y a eu une erreur lors de l\'envoi de votre message.');
}
// liste des producteurs disponibles
$producersArray = Producer::getProducerPopulateDropdown();
$dataProducers = $producersArray['data'];
$optionsProducers = $producersArray['options'];
return $this->render('signup', [
'model' => $model,
'dataProducers' => $dataProducers,
'dataProviderPrices' => $this->getDataProviderPrices(),
'optionsProducers' => $optionsProducers,
]);
}
/**
* Affiche la page de demande de nouveau mot de passe.
* Traitement du formulaire.
*
* @return mixed
*/
public function actionRequestPasswordReset()
{
$model = new PasswordResetRequestForm();
if ($model->load(Yii::$app->request->post()) && $model->validate()) {
if ($model->sendEmail()) {
Yii::$app->getSession()->setFlash('success', 'Un lien vous permettant de réinitialiser votre mot de passe vient d\'être envoyé sur votre boîte mail.');

return $this->refresh();
} else {
return $this->render('contact', [
'model' => $model,
]);
}
return $this->goHome();
} else {
Yii::$app->getSession()->setFlash('error', 'Sorry, we are unable to reset password for email provided.');
}
}

/**
* Affiche la page d'inscription et traite son formulaire.
*
* @return mixed
*/
public function actionSignup()
{
$model = new SignupForm();
if ($model->load(Yii::$app->request->post())) {
$user = $model->signup();

if ($user) {
if (Yii::$app->getUser()->login($user)) {
if ($model->option_user_producer == 'producer') {
$this->redirect(Yii::$app->urlManagerBackend->createAbsoluteUrl(['site/index']));
} else {
$producer = Producer::findOne($model->id_producer);
if ($producer) {
$this->redirect(Yii::$app->urlManagerProducer->createAbsoluteUrl(['site/index', 'slug_producer' => $producer->slug]));
} else {
$this->redirect(['site/index']);
}
}
}
}
}

// liste des établissements disponibles
$producersArray = Producer::getProducerPopulateDropdown();
$dataProducers = $producersArray['data'];
$optionsProducers = $producersArray['options'];

return $this->render('signup', [
'model' => $model,
'dataProducers' => $dataProducers,
'dataProviderPrices' => $this->getDataProviderPrices(),
'optionsProducers' => $optionsProducers,
]);
return $this->render('requestPasswordResetToken', [
'model' => $model,
]);
}

/**
* Met à jour le mot de passe de l'utilisateur.
*
* @param string $token
* @return mixed
* @throws BadRequestHttpException
*/
public function actionResetPassword($token)
{
try {
$model = new ResetPasswordForm($token);
} catch (InvalidParamException $e) {
throw new BadRequestHttpException($e->getMessage());
}

/**
* Affiche la page de demande de nouveau mot de passe.
* Traitement du formulaire.
*
* @return mixed
*/
public function actionRequestPasswordReset()
{
$model = new PasswordResetRequestForm();
if ($model->load(Yii::$app->request->post()) && $model->validate()) {
if ($model->sendEmail()) {
Yii::$app->getSession()->setFlash('success', 'Un lien vous permettant de réinitialiser votre mot de passe vient d\'être envoyé sur votre boîte mail.');

return $this->goHome();
} else {
Yii::$app->getSession()->setFlash('error', 'Sorry, we are unable to reset password for email provided.');
}
}
if ($model->load(Yii::$app->request->post()) && $model->validate() && $model->resetPassword()) {
Yii::$app->getSession()->setFlash('success', 'Votre nouveau mot de passe vient d\'être sauvegardé.');

return $this->render('requestPasswordResetToken', [
'model' => $model,
]);
return $this->goHome();
}

/**
* Met à jour le mot de passe de l'utilisateur.
*
* @param string $token
* @return mixed
* @throws BadRequestHttpException
*/
public function actionResetPassword($token)
{
try {
$model = new ResetPasswordForm($token);
} catch (InvalidParamException $e) {
throw new BadRequestHttpException($e->getMessage());
}

if ($model->load(Yii::$app->request->post()) && $model->validate() && $model->resetPassword()) {
Yii::$app->getSession()->setFlash('success', 'Votre nouveau mot de passe vient d\'être sauvegardé.');

return $this->goHome();
}

return $this->render('resetPassword', [
'model' => $model,
]);
return $this->render('resetPassword', [
'model' => $model,
]);
}

/**
* Affiche les conditions générale de service.
*
* @return mixed
*/
public function actionCgv()
{
return $this->render('cgv');
}

/**
* Affiche les précisions concernant l'utilisation du crédit.
*
* @return string
*/
public function actionCredit()
{
return $this->render('credit');
}

/**
* Affiche le formulaire de demande de code pour accéder à certains
* producteurs.
*
* @param integer $id
* @return mixed
* @throws \yii\web\HttpException
*/
public function actionProducerCode($id)
{
$producer = Producer::findOne($id);

if (!$producer) {
throw new \yii\web\HttpException(404, 'Producteur introuvable');
}

/**
* Affiche les conditions générale de service.
*
* @return mixed
*/
public function actionCgv()
{
return $this->render('cgv');
}
$producerCodeForm = new ProducerCodeForm;
$producerCodeForm->id_producer = $id;

/**
* Affiche les précisions concernant l'utilisation du crédit.
*
* @return string
*/
public function actionCredit()
{
return $this->render('credit');
if ($producerCodeForm->load(Yii::$app->request->post()) && $producerCodeForm->validate()) {
Producer::addUser(User::getCurrentId(), $id);
$this->redirect(Yii::$app->urlManagerProducer->createAbsoluteUrl(['site/index', 'slug_producer' => $producer->slug]));
}

/**
* Affiche le formulaire de demande de code pour accéder à certains
* producteurs.
*
* @param integer $id
* @return mixed
* @throws \yii\web\HttpException
*/
public function actionProducerCode($id)
{
$producer = Producer::findOne($id);

if (!$producer) {
throw new \yii\web\HttpException(404, 'Producteur introuvable');
}

$producerCodeForm = new ProducerCodeForm;
$producerCodeForm->id_producer = $id;

if ($producerCodeForm->load(Yii::$app->request->post()) && $producerCodeForm->validate()) {
Producer::addUser(User::getCurrentId(), $id);
$this->redirect(Yii::$app->urlManagerProducer->createAbsoluteUrl(['site/index', 'slug_producer' => $producer->slug]));
return $this->render('producer_code', [
'producer' => $producer,
'producerCodeForm' => $producerCodeForm,
]);
}

/**
* Affiche la page de connexion / inscription pour accéder notamment au
* formulaire de commande des producteurs.
*
* @param integer $id
* @return mixed
*/
public function actionProducer($id)
{
$loginForm = new LoginForm();
$signupForm = new SignupForm();

$producer = Producer::searchOne([
'id' => $id
]);

$loginForm->id_producer = $id;
$signupForm->id_producer = $id;
$signupForm->option_user_producer = 'user';

$returnUrl = Yii::$app->request->get('returnUrl', Yii::$app->urlManagerProducer->createAbsoluteUrl(['site/index', 'slug_producer' => $producer->slug]));

if (Yii::$app->user->isGuest) {
if ($loginForm->load(Yii::$app->request->post()) && $loginForm->login()) {
if (!strlen($producer->code)) {
Producer::addUser(User::getCurrentId(), $id);
}
$this->redirect($returnUrl);
}

return $this->render('producer_code', [
'producer' => $producer,
'producerCodeForm' => $producerCodeForm,
]);
}

/**
* Affiche la page de connexion / inscription pour accéder notamment au
* formulaire de commande des producteirs.
*
* @param integer $id
* @return mixed
*/
public function actionProducer($id)
{
$loginForm = new LoginForm();
$signupForm = new SignupForm();

$producer = Producer::searchOne([
'id' => $id
]);

$loginForm->id_producer = $id;
$signupForm->id_producer = $id;
$signupForm->option_user_producer = 'user';

$returnUrl = Yii::$app->request->get('returnUrl', Yii::$app->urlManagerProducer->createAbsoluteUrl(['site/index', 'slug_producer' => $producer->slug]));

if (Yii::$app->user->isGuest) {
if ($loginForm->load(Yii::$app->request->post()) && $loginForm->login()) {
if (!strlen($producer->code)) {
Producer::addUser(User::getCurrentId(), $id);
}
$this->redirect($returnUrl);
}

if ($signupForm->load(Yii::$app->request->post())) {
if ($user = $signupForm->signup()) {
if (Yii::$app->getUser()->login($user)) {
$this->redirect($returnUrl);
}
}
}
} else {
if ($signupForm->load(Yii::$app->request->post())) {
if ($user = $signupForm->signup()) {
if (Yii::$app->getUser()->login($user)) {
$this->redirect($returnUrl);
}
}

return $this->render('producer', [
'loginForm' => $loginForm,
'signupForm' => $signupForm,
'producer' => $producer,
]);
}
} else {
$this->redirect($returnUrl);
}

/**
* Indique à l'utilisateur que l'espace d'un producteur est hors ligne
*
* @param integer $id
* @return mixed
*/
public function actionProducerOffline($id)
{
$producer = Producer::searchOne([
'id' => $id
]);

return $this->render('producer_offline', [
'producer' => $producer,
]);
}
return $this->render('producer', [
'loginForm' => $loginForm,
'signupForm' => $signupForm,
'producer' => $producer,
]);
}

/**
* Indique à l'utilisateur que l'espace d'un producteur est hors ligne
*
* @param integer $id
* @return mixed
*/
public function actionProducerOffline($id)
{
$producerRepository = $this->getLogic()->getProducerContainer()->getRepository();
return $this->render('producer_offline', [
'producer' => $producerRepository->getOneById($id),
]);
}

}

+ 1
- 0
producer/controllers/SiteController.php 파일 보기

@@ -38,6 +38,7 @@

namespace producer\controllers;

use common\forms\ContactForm;
use common\helpers\GlobalParam;
use common\models\Producer;
use common\models\ProductCategory;

Loading…
취소
저장