I am using Authorization plugin and created Policies and these policies working good in the controller like can index/add/edit/delete but i have issue in the view index.php there i need to hide add button using can() method like below
if($this->request->getAttribute('identity')->can('add')){
echo $this->Html->link("<i class=\"fa fa-plus\"></i> " . __('New User'), ["action" => "add"], ["escape" => false]);
}
There we need second parameter newEmptyEntity object but i am in index function so i don't want to add newEmptyEntity object. when i used above script for hide add button then this error will be appear
(Error: Too few arguments to function Authorization\IdentityDecorator::can(), 1 passed in index.php on line 21 and exactly 2 expected.)
My policy method is this one:
public function canAdd(IdentityInterface $user)
{
if($user->is_supper_admin){
return true;
}
return false;
}
In this case i don't need second parameter so please resolve this issue

Thanks
I am using Authorization plugin and created Policies and these policies working good in the controller like can index/add/edit/delete but i have issue in the view index.php there i need to hide add button using
can()method like belowThere we need second parameter
newEmptyEntityobject but i am in index function so i don't want to addnewEmptyEntityobject. when i used above script for hide add button then this error will be appearMy policy method is this one:
In this case i don't need second parameter so please resolve this issue
Thanks