Sfoglia il codice sorgente

Indentation + commentaires modèles frontend

refactoring
parent
commit
e0b8519d31
5 ha cambiato i file con 57 aggiunte e 38 eliminazioni
  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 Vedi File

@@ -47,7 +47,8 @@ use yii\helpers\Html;
/**
* ContactForm is the model behind the contact form.
*/
class AddEtablissementForm extends Model {
class AddEtablissementForm extends Model
{

public $id_etablissement;
public $code;
@@ -55,7 +56,8 @@ class AddEtablissementForm extends Model {
/**
* @inheritdoc
*/
public function rules() {
public function rules()
{
return [
['id_etablissement', 'integer'],
['id_etablissement', 'required'],
@@ -100,7 +102,8 @@ class AddEtablissementForm extends Model {
/**
* @inheritdoc
*/
public function attributeLabels() {
public function attributeLabels()
{
return [
'id_etablissement' => 'Établissement',
'code' => 'Code',
@@ -113,7 +116,8 @@ class AddEtablissementForm extends Model {
* @param string $email the target email address
* @return boolean whether the email was sent
*/
public function add() {
public function add()
{
$etablissement = Etablissement::findOne($this->id_etablissement);

$user_etablissement_exist = UserEtablissement::find()

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

@@ -45,14 +45,16 @@ use yii;
/**
* Password reset request form
*/
class PasswordResetRequestForm extends Model {
class PasswordResetRequestForm extends Model
{

public $email;

/**
* @inheritdoc
*/
public function rules() {
public function rules()
{
return [
['email', 'filter', 'filter' => 'trim'],
['email', 'required'],
@@ -69,7 +71,8 @@ class PasswordResetRequestForm extends Model {
*
* @return boolean whether the email was send
*/
public function sendEmail() {
public function sendEmail()
{
/* @var $user User */
$user = User::findOne([
'email' => $this->email,

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

@@ -44,7 +44,8 @@ use yii\base\Model;
/**
* Producer Code form
*/
class ProducerCodeForm extends Model {
class ProducerCodeForm extends Model
{

public $id_producer ;
public $code;
@@ -52,7 +53,8 @@ class ProducerCodeForm extends Model {
/**
* @inheritdoc
*/
public function rules() {
public function rules()
{
return [
['id_producer','required','message' => 'Champs obligatoire'],
['id_producer', 'integer'],
@@ -83,7 +85,8 @@ class ProducerCodeForm extends Model {
];
}

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

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

@@ -46,7 +46,8 @@ use Yii;
/**
* Password reset form
*/
class ResetPasswordForm extends Model {
class ResetPasswordForm extends Model
{

public $password;

@@ -62,7 +63,8 @@ class ResetPasswordForm extends Model {
* @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
*/
public function __construct($token, $config = []) {
public function __construct($token, $config = [])
{
if (empty($token) || !is_string($token)) {
throw new InvalidParamException('Password reset token cannot be blank.');
}
@@ -76,7 +78,8 @@ class ResetPasswordForm extends Model {
/**
* @inheritdoc
*/
public function rules() {
public function rules()
{
return [
['password', 'required'],
['password', 'string', 'min' => 6],
@@ -88,7 +91,8 @@ class ResetPasswordForm extends Model {
*
* @return boolean if password was reset.
*/
public function resetPassword() {
public function resetPassword()
{
$user = $this->_user;
$user->setPassword($this->password);
$user->removePasswordResetToken();
@@ -96,7 +100,8 @@ class ResetPasswordForm extends Model {
return $user->save();
}

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

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

@@ -48,7 +48,8 @@ use common\helpers\Password;
/**
* Signup form
*/
class SignupForm extends Model {
class SignupForm extends Model
{

public $username;
public $email;
@@ -71,7 +72,8 @@ class SignupForm extends Model {
/**
* @inheritdoc
*/
public function rules() {
public function rules()
{
return [
['email', 'filter', 'filter' => 'trim'],
['email', 'required', 'message' => 'Champs obligatoire'],
@@ -180,13 +182,34 @@ class SignupForm extends Model {
['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.
*
* @return User|null the saved model or null if saving fails
*/
public function signup() {
public function signup()
{
if ($this->validate()) {
$user = new User();
$user->username = $this->email;
@@ -280,24 +303,5 @@ class SignupForm extends Model {

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…
Annulla
Salva