Browse Source

Indentation + commentaires modèles frontend

refactoring
Guillaume Bourgeois 6 years ago
parent
commit
e0b8519d31
5 changed files with 57 additions and 38 deletions
  1. +8
    -4
      frontend/models/AddEtablissementForm.php
  2. +6
    -3
      frontend/models/PasswordResetRequestForm.php
  3. +6
    -3
      frontend/models/ProducerCodeForm.php
  4. +10
    -5
      frontend/models/ResetPasswordForm.php
  5. +27
    -23
      frontend/models/SignupForm.php

+ 8
- 4
frontend/models/AddEtablissementForm.php View File

/** /**
* ContactForm is the model behind the contact form. * ContactForm is the model behind the contact form.
*/ */
class AddEtablissementForm extends Model {
class AddEtablissementForm extends Model
{


public $id_etablissement; public $id_etablissement;
public $code; public $code;
/** /**
* @inheritdoc * @inheritdoc
*/ */
public function rules() {
public function rules()
{
return [ return [
['id_etablissement', 'integer'], ['id_etablissement', 'integer'],
['id_etablissement', 'required'], ['id_etablissement', 'required'],
/** /**
* @inheritdoc * @inheritdoc
*/ */
public function attributeLabels() {
public function attributeLabels()
{
return [ return [
'id_etablissement' => 'Établissement', 'id_etablissement' => 'Établissement',
'code' => 'Code', 'code' => 'Code',
* @param string $email the target email address * @param string $email the target email address
* @return boolean whether the email was sent * @return boolean whether the email was sent
*/ */
public function add() {
public function add()
{
$etablissement = Etablissement::findOne($this->id_etablissement); $etablissement = Etablissement::findOne($this->id_etablissement);


$user_etablissement_exist = UserEtablissement::find() $user_etablissement_exist = UserEtablissement::find()

+ 6
- 3
frontend/models/PasswordResetRequestForm.php View File

/** /**
* Password reset request form * Password reset request form
*/ */
class PasswordResetRequestForm extends Model {
class PasswordResetRequestForm extends Model
{


public $email; public $email;


/** /**
* @inheritdoc * @inheritdoc
*/ */
public function rules() {
public function rules()
{
return [ return [
['email', 'filter', 'filter' => 'trim'], ['email', 'filter', 'filter' => 'trim'],
['email', 'required'], ['email', 'required'],
* *
* @return boolean whether the email was send * @return boolean whether the email was send
*/ */
public function sendEmail() {
public function sendEmail()
{
/* @var $user User */ /* @var $user User */
$user = User::findOne([ $user = User::findOne([
'email' => $this->email, 'email' => $this->email,

+ 6
- 3
frontend/models/ProducerCodeForm.php View File

/** /**
* Producer Code form * Producer Code form
*/ */
class ProducerCodeForm extends Model {
class ProducerCodeForm extends Model
{


public $id_producer ; public $id_producer ;
public $code; public $code;
/** /**
* @inheritdoc * @inheritdoc
*/ */
public function rules() {
public function rules()
{
return [ return [
['id_producer','required','message' => 'Champs obligatoire'], ['id_producer','required','message' => 'Champs obligatoire'],
['id_producer', 'integer'], ['id_producer', 'integer'],
]; ];
} }


public function attributeLabels() {
public function attributeLabels()
{
return [ return [
'id_producer' => 'Producteur', 'id_producer' => 'Producteur',
'code' => 'Code de l\'établissement', 'code' => 'Code de l\'établissement',

+ 10
- 5
frontend/models/ResetPasswordForm.php View File

/** /**
* Password reset form * Password reset form
*/ */
class ResetPasswordForm extends Model {
class ResetPasswordForm extends Model
{


public $password; public $password;


* @param array $config name-value pairs that will be used to initialize the object properties * @param array $config name-value pairs that will be used to initialize the object properties
* @throws \yii\base\InvalidParamException if token is empty or not valid * @throws \yii\base\InvalidParamException if token is empty or not valid
*/ */
public function __construct($token, $config = []) {
public function __construct($token, $config = [])
{
if (empty($token) || !is_string($token)) { if (empty($token) || !is_string($token)) {
throw new InvalidParamException('Password reset token cannot be blank.'); throw new InvalidParamException('Password reset token cannot be blank.');
} }
/** /**
* @inheritdoc * @inheritdoc
*/ */
public function rules() {
public function rules()
{
return [ return [
['password', 'required'], ['password', 'required'],
['password', 'string', 'min' => 6], ['password', 'string', 'min' => 6],
* *
* @return boolean if password was reset. * @return boolean if password was reset.
*/ */
public function resetPassword() {
public function resetPassword()
{
$user = $this->_user; $user = $this->_user;
$user->setPassword($this->password); $user->setPassword($this->password);
$user->removePasswordResetToken(); $user->removePasswordResetToken();
return $user->save(); return $user->save();
} }


public function attributeLabels() {
public function attributeLabels()
{
return [ return [
'password' => 'Mot de passe', 'password' => 'Mot de passe',
]; ];

+ 27
- 23
frontend/models/SignupForm.php View File

/** /**
* Signup form * Signup form
*/ */
class SignupForm extends Model {
class SignupForm extends Model
{


public $username; public $username;
public $email; public $email;
/** /**
* @inheritdoc * @inheritdoc
*/ */
public function rules() {
public function rules()
{
return [ return [
['email', 'filter', 'filter' => 'trim'], ['email', 'filter', 'filter' => 'trim'],
['email', 'required', 'message' => 'Champs obligatoire'], ['email', 'required', 'message' => 'Champs obligatoire'],
['prix_libre', 'number'], ['prix_libre', 'number'],
]; ];
} }
public function attributeLabels()
{
return [
'id' => 'ID',
'username' => 'Identifiant',
'password' => 'Mot de passe',
'rememberMe' => 'Se souvenir de moi',
'prenom' => 'Prénom',
'telephone' => 'Téléphone',
'is_boulanger' => "Je suis professionnel et souhaite mettre en place un système de réservation dans mon établissement",
'nom_magasin' => 'Nom de l\'établissement',
'siret' => 'Numéro SIRET',
'code_postal' => 'Code postal',
'ville' => 'Commune',
'id_etablissement' => 'Producteur',
'type' => 'Type d\'établissement',
'prix_libre' => 'Prix libre'
];
}


/** /**
* Signs user up. * Signs user up.
* *
* @return User|null the saved model or null if saving fails * @return User|null the saved model or null if saving fails
*/ */
public function signup() {
public function signup()
{
if ($this->validate()) { if ($this->validate()) {
$user = new User(); $user = new User();
$user->username = $this->email; $user->username = $this->email;


return null; return null;
} }

public function attributeLabels() {
return [
'id' => 'ID',
'username' => 'Identifiant',
'password' => 'Mot de passe',
'rememberMe' => 'Se souvenir de moi',
'prenom' => 'Prénom',
'telephone' => 'Téléphone',
'is_boulanger' => "Je suis professionnel et souhaite mettre en place un système de réservation dans mon établissement",
'nom_magasin' => 'Nom de l\'établissement',
'siret' => 'Numéro SIRET',
'code_postal' => 'Code postal',
'ville' => 'Commune',
'id_etablissement' => 'Producteur',
'type' => 'Type d\'établissement',
'prix_libre' => 'Prix libre'
];
}

} }

Loading…
Cancel
Save