migrations/Migration.php
protected function createRule($ruleName, $definition)
    {
        echo "    > create rule $ruleName ...";
        $time = microtime(true);

        if (is_array($definition)) {
            $definition['name'] = $ruleName;
        } else {
            $definition = [
                'class' => $definition,
                'name' => $ruleName,
            ];
        }

        /** @var Rule $rule */
        $rule = \Yii::createObject($definition);

        $this->authManager->add($rule);
        echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n";

        return $rule;
    }
protected function createRule($ruleName, $definition)
    {
        echo "    > create rule $ruleName ...";
        $time = microtime(true);

        if (is_array($definition)) {
            $definition['name'] = $ruleName;
        } else {
            $definition = [
                'class' => $definition,
                'name' => $ruleName,
            ];
        }

        /** @var Rule $rule */
        $rule = \Yii::createObject($definition);

        $this->authManager->add($rule);
        echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n";

        return $rule;
    }
protected function createRule ( $ ruleName , $ definition ) { echo "    > create rule $ruleName ..." ; $ time = microtime ( true ) ; if ( is_array ( $ definition ) ) { $ definition [ 'name' ] = $ ruleName ; } else { $ definition = [ 'class' => $ definition , 'name' => $ ruleName , ] ; } /** @var Rule $rule */ $ rule = \ Yii :: createObject ( $ definition ) ; $ this -> authManager -> add ( $ rule ) ; echo ' done (time: ' . sprintf ( '%.3f' , microtime ( true ) - $ time ) . "s)\n" ; return $ rule ; }
Creates new rule.

@param  string       $ruleName   The name of the rule
@param  string|array $definition The class of the rule
@return Rule
Creates new rule .