yii\rest\UrlRule::init PHP Method

init() public method

public init ( )
    public function init()
    {
        if (empty($this->controller)) {
            throw new InvalidConfigException('"controller" must be set.');
        }
        $controllers = [];
        foreach ((array) $this->controller as $urlName => $controller) {
            if (is_int($urlName)) {
                $urlName = $this->pluralize ? Inflector::pluralize($controller) : $controller;
            }
            $controllers[$urlName] = $controller;
        }
        $this->controller = $controllers;
        $this->prefix = trim($this->prefix, '/');
        parent::init();
    }

Usage Example

Beispiel #1
0
 public function init()
 {
     $map = Yii::$app->getModule('admin')->controllerMap;
     if (count($map) > 0) {
         foreach ($map as $alias => $className) {
             $class = sprintf('%s/%s', 'admin', $alias);
             $this->controller[] = $class;
         }
         parent::init();
     } else {
         $this->controller = [];
     }
 }
All Usage Examples Of yii\rest\UrlRule::init