|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- <?php
-
-
- namespace yii\web;
-
- use Yii;
- use yii\base\Object;
-
-
- abstract class CompositeUrlRule extends Object implements UrlRuleInterface
- {
-
-
- protected $rules = [];
-
-
-
-
- abstract protected function createRules();
-
-
-
- public function init()
- {
- parent::init();
- $this->rules = $this->createRules();
- }
-
-
-
- public function parseRequest($manager, $request)
- {
- foreach ($this->rules as $rule) {
-
- if (($result = $rule->parseRequest($manager, $request)) !== false) {
- Yii::trace("Request parsed with URL rule: {$rule->name}", __METHOD__);
-
- return $result;
- }
- }
-
- return false;
- }
-
-
-
- public function createUrl($manager, $route, $params)
- {
- foreach ($this->rules as $rule) {
-
- if (($url = $rule->createUrl($manager, $route, $params)) !== false) {
- return $url;
- }
- }
-
- return false;
- }
- }
|