public function testExtract()
 {
     $role = (new RoleEntity())->setId(2);
     $data = $this->repository->extract($role);
     $this->assertArrayHasKey('id', $data);
     $this->assertEquals(2, $data['id']);
 }
Пример #2
0
 public function getList($withKeyId = false)
 {
     $result = [];
     foreach ($this->getAll() as $role) {
         $data = $this->roleRepository->extract($role);
         if ($role->getParent() != null) {
             $data['parentId'] = $role->getParent()->getId();
         } else {
             $data['parentId'] = 0;
         }
         unset($data['parent']);
         if ($withKeyId) {
             $result[$data['id']] = $data;
         } else {
             $result[] = $data;
         }
     }
     return $result;
 }