public function init() { parent::init(); Util::setComponent('appUrlManager', ['enablePrettyUrl' => true, 'showScriptName' => true, 'rules' => [["class" => UrlRule::className()]]], true); }
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; }