public function actionList() { $dataProvider = new ActiveDataProvider(['query' => UrlRule::find(), 'pagination' => ['pageSize' => 10]]); return $this->render('list', ['dataProvider' => $dataProvider, 'model' => $dataProvider->getModels()]); }
public static function getRoute($route, $params = array(), $status = self::STATUS_ACTIVE) { return self::getDb()->cache(function () use($route, $params, $status) { return UrlRule::find()->where('route = :ROUTE AND params = :PARAMS AND status = :STATUS', [':ROUTE' => $route, ':PARAMS' => serialize($params), ':STATUS' => $status])->one(); }); }
/** * @param $_route * @param $_params * @return false|\yii\db\ActiveRecord */ private function getRouteFromCacheOrWriteCacheThenRead($_route, $_params) { unset($_params['/' . $_route]); $dbRoute = Yii::$app->cache->get($_route, $_route); if ($dbRoute == false) { $dbRoute = \UrlAlias\models\UrlRule::getRoute($_route, $_params); Yii::$app->cache->set($this->getCachedRoute($_route, $_params), $dbRoute); } return $dbRoute; }