Ejemplo n.º 1
0
 public static function getParentIds($id)
 {
     $ret = [];
     $current = Board::findOne(['id' => $id]);
     $parent = Board::findOne(['id' => $current['parent_id']]);
     while ($parent != null) {
         array_unshift($ret, $parent->id);
         $parent = Board::findOne(['id' => $parent['parent_id']]);
     }
     array_unshift($ret, 0);
     return $ret;
 }
 /**
  * Finds the Board model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Board the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Board::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Ejemplo n.º 3
0
 public function getBoard($id, $fromCache = True)
 {
     if ($fromCache) {
         $cahcedBoards = $this->getCachedBoards();
         return $cahcedBoards[$id];
     }
     return Board::findOne(['id' => $id]);
 }