src/ServiceRuntime/Internal/XmlRoleEnvironmentDataDeserializer.php
private function _translateRoles(
        $environmentInfo,
        RoleInstance $currentInstance,
        $currentRole
    ) {
        $rolesMap = [];

        $rolesInfo = Utilities::tryGetKeysChainValue(
            $environmentInfo,
            'Roles',
            'Role'
        );

        if (!is_null($rolesInfo)) {
            if (array_key_exists('@attributes', $rolesInfo)) {
                $rolesInfo = [0 => $rolesInfo];
            }

            foreach ($rolesInfo as $roleInfo) {
                $roleInstances = $this->_translateRoleInstances($roleInfo);

                if ($roleInfo['@attributes']['name'] == $currentRole) {
                    $roleInstances[$currentInstance->getId()] = $currentInstance;
                }

                $role = new Role($roleInfo['@attributes']['name'], $roleInstances);

                foreach ($roleInstances as $instance) {
                    $instance->setRole($role);
                }

                $rolesMap[$roleInfo['@attributes']['name']] = $role;
            }
        }

        if (!array_key_exists($currentRole, $rolesMap)) {
            $roleInstances = [];
            $roleInstances[$currentInstance->getId()] = $currentInstance;

            $singleRole = new Role($currentRole, $roleInstances);
            $currentInstance->setRole($singleRole);

            $rolesMap[$currentRole] = $singleRole;
        }

        return $rolesMap;
    }
private function _translateRoles(
        $environmentInfo,
        RoleInstance $currentInstance,
        $currentRole
    ) {
        $rolesMap = [];

        $rolesInfo = Utilities::tryGetKeysChainValue(
            $environmentInfo,
            'Roles',
            'Role'
        );

        if (!is_null($rolesInfo)) {
            if (array_key_exists('@attributes', $rolesInfo)) {
                $rolesInfo = [0 => $rolesInfo];
            }

            foreach ($rolesInfo as $roleInfo) {
                $roleInstances = $this->_translateRoleInstances($roleInfo);

                if ($roleInfo['@attributes']['name'] == $currentRole) {
                    $roleInstances[$currentInstance->getId()] = $currentInstance;
                }

                $role = new Role($roleInfo['@attributes']['name'], $roleInstances);

                foreach ($roleInstances as $instance) {
                    $instance->setRole($role);
                }

                $rolesMap[$roleInfo['@attributes']['name']] = $role;
            }
        }

        if (!array_key_exists($currentRole, $rolesMap)) {
            $roleInstances = [];
            $roleInstances[$currentInstance->getId()] = $currentInstance;

            $singleRole = new Role($currentRole, $roleInstances);
            $currentInstance->setRole($singleRole);

            $rolesMap[$currentRole] = $singleRole;
        }

        return $rolesMap;
    }
private function _translateRoles ( $ environmentInfo , RoleInstance $ currentInstance , $ currentRole ) { $ rolesMap = [ ] ; $ rolesInfo = Utilities :: tryGetKeysChainValue ( $ environmentInfo , 'Roles' , 'Role' ) ; if ( ! is_null ( $ rolesInfo ) ) { if ( array_key_exists ( '@attributes' , $ rolesInfo ) ) { $ rolesInfo = [ 0 => $ rolesInfo ] ; } foreach ( $ rolesInfo as $ roleInfo ) { $ roleInstances = $ this -> _translateRoleInstances ( $ roleInfo ) ; if ( $ roleInfo [ '@attributes' ] [ 'name' ] == $ currentRole ) { $ roleInstances [ $ currentInstance -> getId ( ) ] = $ currentInstance ; } $ role = new Role ( $ roleInfo [ '@attributes' ] [ 'name' ] , $ roleInstances ) ; foreach ( $ roleInstances as $ instance ) { $ instance -> setRole ( $ role ) ; } $ rolesMap [ $ roleInfo [ '@attributes' ] [ 'name' ] ] = $ role ; } } if ( ! array_key_exists ( $ currentRole , $ rolesMap ) ) { $ roleInstances = [ ] ; $ roleInstances [ $ currentInstance -> getId ( ) ] = $ currentInstance ; $ singleRole = new Role ( $ currentRole , $ roleInstances ) ; $ currentInstance -> setRole ( $ singleRole ) ; $ rolesMap [ $ currentRole ] = $ singleRole ; } return $ rolesMap ; }
Translates the roles.

@param string       $environmentInfo The role environment info
@param RoleInstance $currentInstance The current instance info
@param string       $currentRole     The current role

@return array
Translates the roles .