src/Sulu/Bundle/SecurityBundle/Controller/RoleController.php
protected function convertRole(RoleInterface $role)
    {
        $roleData['id'] = $role->getId();
        $roleData['name'] = $role->getName();
        $roleData['identifier'] = $role->getIdentifier();
        $roleData['system'] = $role->getSystem();
        $roleData['permissions'] = [];

        $permissions = $role->getPermissions();
        if (!empty($permissions)) {
            foreach ($permissions as $permission) {
                /* @var Permission $permission */
                $roleData['permissions'][] = [
                    'id' => $permission->getId(),
                    'context' => $permission->getContext(),
                    'module' => $permission->getModule(),
                    'permissions' => $this->get('sulu_security.mask_converter')
                        ->convertPermissionsToArray($permission->getPermissions()),
                ];
            }
        }

        $securityType = $role->getSecurityType();
        if ($securityType) {
            $roleData['securityType'] = [
                'id' => $securityType->getId(),
                'name' => $securityType->getName(),
            ];
        }

        return $roleData;
    }
protected function convertRole(RoleInterface $role)
    {
        $roleData['id'] = $role->getId();
        $roleData['name'] = $role->getName();
        $roleData['identifier'] = $role->getIdentifier();
        $roleData['system'] = $role->getSystem();
        $roleData['permissions'] = [];

        $permissions = $role->getPermissions();
        if (!empty($permissions)) {
            foreach ($permissions as $permission) {
                /* @var Permission $permission */
                $roleData['permissions'][] = [
                    'id' => $permission->getId(),
                    'context' => $permission->getContext(),
                    'module' => $permission->getModule(),
                    'permissions' => $this->get('sulu_security.mask_converter')
                        ->convertPermissionsToArray($permission->getPermissions()),
                ];
            }
        }

        $securityType = $role->getSecurityType();
        if ($securityType) {
            $roleData['securityType'] = [
                'id' => $securityType->getId(),
                'name' => $securityType->getName(),
            ];
        }

        return $roleData;
    }
protected function convertRole ( RoleInterface $ role ) { $ roleData [ 'id' ] = $ role -> getId ( ) ; $ roleData [ 'name' ] = $ role -> getName ( ) ; $ roleData [ 'identifier' ] = $ role -> getIdentifier ( ) ; $ roleData [ 'system' ] = $ role -> getSystem ( ) ; $ roleData [ 'permissions' ] = [ ] ; $ permissions = $ role -> getPermissions ( ) ; if ( ! empty ( $ permissions ) ) { foreach ( $ permissions as $ permission ) { /* @var Permission $permission */ $ roleData [ 'permissions' ] [ ] = [ 'id' => $ permission -> getId ( ) , 'context' => $ permission -> getContext ( ) , 'module' => $ permission -> getModule ( ) , 'permissions' => $ this -> get ( 'sulu_security.mask_converter' ) -> convertPermissionsToArray ( $ permission -> getPermissions ( ) ) , ] ; } } $ securityType = $ role -> getSecurityType ( ) ; if ( $ securityType ) { $ roleData [ 'securityType' ] = [ 'id' => $ securityType -> getId ( ) , 'name' => $ securityType -> getName ( ) , ] ; } return $ roleData ; }
Converts a role object into an array for the rest service.

@param RoleInterface $role

@return array
Converts a role object into an array for the rest service .