예제 #1
0
 public function behaviors()
 {
     return array_merge(parent::behaviors(), ['labels' => ['class' => 'netis\\crud\\db\\LabelsBehavior', 'attributes' => ['ProductName'], 'crudLabels' => ['default' => Yii::t('app', 'Product'), 'relation' => Yii::t('app', 'Products'), 'index' => Yii::t('app', 'Browse Products'), 'create' => Yii::t('app', 'Create Product'), 'read' => Yii::t('app', 'View Product'), 'update' => Yii::t('app', 'Update Product'), 'delete' => Yii::t('app', 'Delete Product')]]]);
 }
예제 #2
0
 /**
  * Returns all special behavior attributes as two arrays: all attributes and only blameable attributes.
  * @param ActiveRecord $model
  * @return array two arrays: all behavior attributes and blameable attributes
  */
 public static function getModelBehaviorAttributes($model)
 {
     $behaviorAttributes = [];
     $blameableAttributes = [];
     foreach ($model->behaviors() as $behaviorName => $behaviorOptions) {
         if (!is_array($behaviorOptions)) {
             continue;
         }
         switch ($behaviorOptions['class']) {
             case \netis\crud\db\SortableBehavior::className():
                 $behaviorAttributes[] = $behaviorOptions['attribute'];
                 break;
             case \netis\crud\db\ToggableBehavior::className():
                 if (isset($behaviorOptions['disabledAttribute'])) {
                     $behaviorAttributes[] = $behaviorOptions['disabledAttribute'];
                 }
                 if (isset($behaviorOptions['enabledAttribute'])) {
                     $behaviorAttributes[] = $behaviorOptions['enabledAttribute'];
                 }
                 break;
             case \netis\crud\db\BlameableBehavior::className():
                 if (isset($behaviorOptions['createdByAttribute'])) {
                     $behaviorAttributes[] = $behaviorOptions['createdByAttribute'];
                     $blameableAttributes[] = $behaviorOptions['createdByAttribute'];
                 }
                 if (isset($behaviorOptions['updatedByAttribute'])) {
                     $behaviorAttributes[] = $behaviorOptions['updatedByAttribute'];
                     $blameableAttributes[] = $behaviorOptions['updatedByAttribute'];
                 }
                 break;
             case \netis\crud\db\TimestampBehavior::className():
                 if (isset($behaviorOptions['createdAtAttribute'])) {
                     $behaviorAttributes[] = $behaviorOptions['createdAtAttribute'];
                 }
                 if (isset($behaviorOptions['updatedAtAttribute'])) {
                     $behaviorAttributes[] = $behaviorOptions['updatedAtAttribute'];
                 }
                 break;
         }
     }
     return [$behaviorAttributes, $blameableAttributes];
 }
 public function behaviors()
 {
     return array_merge(parent::behaviors(), ['labels' => ['class' => 'netis\\crud\\db\\LabelsBehavior', 'attributes' => ['CustomerTypeID'], 'crudLabels' => ['default' => Yii::t('app', 'Customer Demographic'), 'relation' => Yii::t('app', 'Customer Demographics'), 'index' => Yii::t('app', 'Browse Customer Demographics'), 'create' => Yii::t('app', 'Create Customer Demographic'), 'read' => Yii::t('app', 'View Customer Demographic'), 'update' => Yii::t('app', 'Update Customer Demographic'), 'delete' => Yii::t('app', 'Delete Customer Demographic')]]]);
 }
예제 #4
0
 public function behaviors()
 {
     return array_merge(parent::behaviors(), ['labels' => ['class' => 'netis\\crud\\db\\LabelsBehavior', 'attributes' => ['TerritoryID'], 'crudLabels' => ['default' => Yii::t('app', 'Employee Territory'), 'relation' => Yii::t('app', 'Employee Territories'), 'index' => Yii::t('app', 'Browse Employee Territories'), 'create' => Yii::t('app', 'Create Employee Territory'), 'read' => Yii::t('app', 'View Employee Territory'), 'update' => Yii::t('app', 'Update Employee Territory'), 'delete' => Yii::t('app', 'Delete Employee Territory')]]]);
 }