Class yii\debug\models\router\RouterRules

Inheritanceyii\debug\models\router\RouterRules » yii\base\Model
Available since extension's version2.1.14
Source Code https://github.com/yiisoft/yii2-debug/blob/master/src/models/router/RouterRules.php

RouterRules model

Public Properties

Hide inherited properties

Property Type Description Defined By
$prettyUrl boolean Whether pretty URL option has been enabled in UrlManager yii\debug\models\router\RouterRules
$rules array Logged rules. yii\debug\models\router\RouterRules
$strictParsing boolean Whether strict parsing option has been enabled in UrlManager yii\debug\models\router\RouterRules
$suffix string Global suffix set in UrlManager yii\debug\models\router\RouterRules

Public Methods

Hide inherited methods

Method Description Defined By
init() yii\debug\models\router\RouterRules

Protected Methods

Hide inherited methods

Method Description Defined By
scanGroupRule() Scans group rule's rules for basic data. yii\debug\models\router\RouterRules
scanRestRule() Scans REST rule's rules for basic data. yii\debug\models\router\RouterRules
scanRule() Scans rule for basic data. yii\debug\models\router\RouterRules

Property Details

Hide inherited properties

$prettyUrl public property

Whether pretty URL option has been enabled in UrlManager

public boolean $prettyUrl false
$rules public property

Logged rules. `php [ [

 'name' => rule name or its class (string),
 'route' => (string),
 'verb' => (array),
 'suffix' => (string),
 'mode' => 'parsing only', 'creation only', or null,
 'type' => 'REST', 'GROUP', or null,

] ] `

public array $rules = []
$strictParsing public property

Whether strict parsing option has been enabled in UrlManager

public boolean $strictParsing false
$suffix public property

Global suffix set in UrlManager

public string $suffix null

Method Details

Hide inherited methods

init() public method

public void init ( )

                public function init()
{
    parent::init();
    if (Yii::$app->urlManager instanceof UrlManager) {
        $this->prettyUrl = Yii::$app->urlManager->enablePrettyUrl;
        $this->suffix = Yii::$app->urlManager->suffix;
        $this->strictParsing = Yii::$app->urlManager->enableStrictParsing;
        if ($this->prettyUrl) {
            foreach (Yii::$app->urlManager->rules as $rule) {
                $this->scanRule($rule);
            }
        }
    }
}

            
scanGroupRule() protected method

Scans group rule's rules for basic data.

protected void scanGroupRule ( $groupRule )
$groupRule \yii\web\GroupUrlRule
throws ReflectionException

                protected function scanGroupRule($groupRule)
{
    foreach ($groupRule->rules as $rule) {
        $this->scanRule($rule, 'GROUP');
    }
}

            
scanRestRule() protected method

Scans REST rule's rules for basic data.

protected void scanRestRule ( $restRule )
$restRule \yii\rest\UrlRule
throws ReflectionException

                protected function scanRestRule($restRule)
{
    $reflectionClass = new \ReflectionClass($restRule);
    $reflectionProperty = $reflectionClass->getProperty('rules');
    $reflectionProperty->setAccessible(true);
    $rulesGroups = $reflectionProperty->getValue($restRule);
    foreach ($rulesGroups as $rules) {
        foreach ($rules as $rule) {
            $this->scanRule($rule, 'REST');
        }
    }
}

            
scanRule() protected method

Scans rule for basic data.

protected void scanRule ( $rule, $type null )
$rule
$type null
throws ReflectionException

                protected function scanRule($rule, $type = null)
{
    $route = $verb = $suffix = $mode = null;
    if ($rule instanceof GroupUrlRule) {
        $this->scanGroupRule($rule);
    } elseif ($rule instanceof RestUrlRule) {
        $this->scanRestRule($rule);
    } else {
        if ($rule instanceof WebUrlRule) {
            switch ($rule->mode) {
                case WebUrlRule::PARSING_ONLY:
                    $mode = 'parsing only';
                    break;
                case WebUrlRule::CREATION_ONLY:
                    $mode = 'creation only';
                    break;
                case null;
                    $mode = null;
                    break;
                default:
                    $mode = 'unknown';
            }
            $name = $rule->name;
            $route = $rule->route;
            $verb = $rule->verb;
            $suffix = $rule->suffix;
        } else {
            $name = get_class($rule);
        }
        $this->rules[] = [
            'name' => $name,
            'route' => $route,
            'verb' => $verb,
            'suffix' => $suffix,
            'mode' => $mode,
            'type' => $type
        ];
    }
}