-1

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;
}
Sargis
  • 1,196
  • 1
  • 18
  • 31
Vampire
  • 3
  • 4

1 Answers1

0

Yii2 DbManager Docs - getItem() method is protected.

PHP: Visibility - check out here for visibility in PHP.

Yupik
  • 4,932
  • 1
  • 12
  • 26
  • do you have any Idea why it was set as protected. in Yii 1.1 this was public public function createAuthItem($name,$type,$description='',$bizRule=null,$data=null); – Vampire May 17 '17 at 15:28