I was trying to create a console command for yii 2 rbac I'm getting exception:
'yii\base\UnknownMethodException' with message 'Calling unknown method: yii\rbac\DbManager::getItem()'
protected function createItem($name,$type,$description='',$data=null)
{
$item=$this->_authManager->getItem($name);
if($item===null)
{
$item = new Item;
$item->name = $name;
$item->type = $type;
$item->description = $description;
self::$newCount++;
echo "creating new item $name \n";
$item=$this->_authManager->addItem($item);
}
return $item;
}
Yii2 DbManager Docs - getItem()
method is protected.
PHP: Visibility - check out here for visibility in PHP.