models/Assignment.php
public function assign($items)
    {
        $manager = Configs::authManager();
        $success = 0;
        foreach ($items as $name) {
            try {
                $item = $manager->getRole($name);
                $item = $item ?: $manager->getPermission($name);
                $manager->assign($item, $this->id);
                $success++;
            } catch (\Exception $exc) {
                Yii::error($exc->getMessage(), __METHOD__);
            }
        }
        Helper::invalidate();
        return $success;
    }
public function assign($items)
    {
        $manager = Configs::authManager();
        $success = 0;
        foreach ($items as $name) {
            try {
                $item = $manager->getRole($name);
                $item = $item ?: $manager->getPermission($name);
                $manager->assign($item, $this->id);
                $success++;
            } catch (\Exception $exc) {
                Yii::error($exc->getMessage(), __METHOD__);
            }
        }
        Helper::invalidate();
        return $success;
    }
public function assign ( $ items ) { $ manager = Configs :: authManager ( ) ; $ success = 0 ; foreach ( $ items as $ name ) { try { $ item = $ manager -> getRole ( $ name ) ; $ item = $ item ? : $ manager -> getPermission ( $ name ) ; $ manager -> assign ( $ item , $ this -> id ) ; $ success ++ ; } catch ( \ Exception $ exc ) { Yii :: error ( $ exc -> getMessage ( ) , __METHOD__ ) ; } } Helper :: invalidate ( ) ; return $ success ; }
Grands a roles from a user.
@param array $items
@return integer number of successful grand
Grands a roles from a user .