Exemplo n.º 1
0
 public function init()
 {
     parent::init();
     Util::setComponent('appUrlManager', ['enablePrettyUrl' => true, 'showScriptName' => true, 'rules' => [["class" => UrlRule::className()]]], true);
 }
Exemplo n.º 2
0
 public function getRuleByPattern($pattern)
 {
     $ruleCache = \Yii::$app->getCache()->get(UrlRule::className());
     if ($ruleCache == null) {
         $ruleCache = [];
     }
     $cacheKey = $pattern;
     if (isset($ruleCache[$cacheKey])) {
         return $ruleCache[$cacheKey];
     }
     $rule = \hass\urlrule\models\UrlRule::getRuleByPattern($pattern);
     if (!$rule) {
         return null;
     }
     $ruleCache[$cacheKey] = $rule;
     \Yii::$app->getCache()->set(UrlRule::className(), $ruleCache);
     return $rule;
 }