示例#1
0
 /**
  * FileTerms function.
  *
  * @access public
  * @static
  * @param int $id (default: 0)
  * @return array
  */
 public static function FileTerms($id = 0)
 {
     $file = Files::findOne($id);
     $terms = [];
     if (!empty($file->fileTerms)) {
         foreach ($file->fileTerms as $v) {
             $terms[$v->type] = $v->value;
         }
     }
     return $terms;
 }
 /**
  * Finds the Files model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Files the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Files::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }