コード例 #1
0
ファイル: EavTrait.php プロジェクト: manyoubaby123/imshop
 /**
  * @inheritdoc
  */
 public function getAttributeLabel($attribute)
 {
     $labels = $this->attributeLabels();
     if (isset($labels[$attribute])) {
         return $labels[$attribute];
     } elseif ($this->isEAttribute($attribute)) {
         $attribute = $this->normalizeEAttributeName($attribute);
         if (isset($this->_eAttributeLabels[$attribute])) {
             return $this->_eAttributeLabels[$attribute];
         }
         /** @var AttributeInterface $attribute */
         $model = Attribute::findOne(['name' => $attribute]);
         if ($model !== null) {
             return $this->_eAttributeLabels[$attribute] = $model->getPresentation();
         } else {
             return $this->generateAttributeLabel($attribute);
         }
     } else {
         return $this->generateAttributeLabel($attribute);
     }
 }
コード例 #2
0
 /**
  * Finds the Attribute model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Attribute the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Attribute::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }