RisteDimitrievski
Active member
I want to extend the UserGroup class and to implement group permission and defining relationship on column user_group_id and entity XF:User, so here is my entity:
Class extended in acp:<?php
namespace usergrouplegend\Entity;
use \XF\Mvc\Entity\Structure;
class UserGroup extends XFCP_UserGroup {
public static function getStructure(Structure $structure){
$structure->table = 'xf_user_group';
$structure->getters = [
'PermissionSet' => [
'getter' => true,
'cache' => true
],
];
$structure->relations = [
'User' => [
'entity' => 'XF:User',
'type' => self::TO_MANY,
'conditions' => 'user_group_id',
'primary' => false
]
];
}
public function hasPermission($group,$permission){
return $this->PermissionSet->hasGlobalPermission($group,$permission);
}
}
And in my controller i'm using:http://prntscr.com/z3d308 - screenshot
I've tried also like:$finder = \XF::finder('XF:UserGroup')->with('XF:User')->fetch()->toArray();
which i'm getting this error:$finder = \XF::finder('usergrouplegend:Usergroup')->with('XF:User')->fetch()->toArray();
i wonder why this is caused. Tried also with extend \XF\Entity\UserGroup but the problem is the same.ErrorException: [E_WARNING] Creating default object from empty value in src\XF\Mvc\Entity\Manager.php at line 71