Browse Source

Suppression attribut 'class' inutile dans la méthode "defaultOptionsSearch"

dev
Guillaume Bourgeois 6 years ago
parent
commit
a88d04f14b
6 changed files with 14 additions and 9 deletions
  1. +12
    -5
      common/components/ActiveRecordCommon.php
  2. +0
    -1
      common/models/CreditHistory.php
  3. +0
    -1
      common/models/Invoice.php
  4. +0
    -1
      common/models/Order.php
  5. +2
    -0
      common/models/PointSale.php
  6. +0
    -1
      common/models/Subscription.php

+ 12
- 5
common/components/ActiveRecordCommon.php View File

@@ -40,9 +40,9 @@ namespace common\components ;

class ActiveRecordCommon extends \yii\db\ActiveRecord
{
const SEARCH_ALL = 'all' ;
const SEARCH_ONE = 'one' ;
const SEARCH_COUNT = 'count' ;
const SEARCH_ALL = 'all' ;
const SEARCH_ONE = 'one' ;
const SEARCH_COUNT = 'count' ;
/**
* Méthode générique de recherche utilisée pour tous les modèles. Elle a
@@ -57,7 +57,14 @@ class ActiveRecordCommon extends \yii\db\ActiveRecord
{
$class = get_called_class() ;
$default_options = $class::defaultOptionsSearch() ;
if(is_callable([$class, 'defaultOptionsSearch'])) {
$default_options = $class::defaultOptionsSearch() ;
}
else {
throw new \ErrorException('La méthode "defaultOptionsSearch" n\'est '
. 'pas définie dans la classe "'.$class.'"');
}
$options = array_merge($default_options, $options) ;
$pk = $class::primaryKey() ;
@@ -71,7 +78,7 @@ class ActiveRecordCommon extends \yii\db\ActiveRecord
$options['type_search'] = self::SEARCH_ALL ;
}
$records = $options['class']::find() ;
$records = $class::find() ;
// With
if(is_array($options['with']) && count($options['with'])) {

+ 0
- 1
common/models/CreditHistory.php View File

@@ -139,7 +139,6 @@ class CreditHistory extends ActiveRecord
*/
public static function defaultOptionsSearch() {
return [
'class' => 'CreditHistory',
'with' => [],
'join_with' => [],
'orderby' => self::tableName().'.date ASc',

+ 0
- 1
common/models/Invoice.php View File

@@ -116,7 +116,6 @@ class Invoice extends \yii\db\ActiveRecord
public static function defaultOptionsSearch()
{
return [
'class' => 'Invoice',
'with' => [],
'join_with' => [],
'orderby' => self::tableName().'.date ASc',

+ 0
- 1
common/models/Order.php View File

@@ -152,7 +152,6 @@ class Order extends ActiveRecordCommon
*/
public static function defaultOptionsSearch() {
return [
'class' => 'Order',
'with' => ['productOrder', 'creditHistory', 'pointSale'],
'join_with' => ['production', 'user', 'user.userProducer'],
'orderby' => 'order.date ASC',

+ 2
- 0
common/models/PointSale.php View File

@@ -141,6 +141,8 @@ class PointSale extends \yii\db\ActiveRecord
);
}

/**
* Initialise les commandes liées au point de vente.
*

+ 0
- 1
common/models/Subscription.php View File

@@ -153,7 +153,6 @@ class Subscription extends ActiveRecordCommon
*/
public static function defaultOptionsSearch() {
return [
'class' => 'Subscription',
'with' => ['producer', 'pointSale', 'productSubscription'],
'join_with' => ['user'],
'orderby' => 'user.name ASC',

Loading…
Cancel
Save