public function getTrackFields($requests)
    {
        $token   = $this->token;
        $results = [];

        // Read fieldcodes and convert to uppercase since requests are uppercase too
        $respondentTrack = $token->getRespondentTrack();
        $fieldCodes      = $respondentTrack->getCodeFields();
        $rawFieldData    = $respondentTrack->getFieldData();    // Date (time) fields are unprocessed here
        $keysMixed       = array_keys($fieldCodes);
        $keysUpper       = array_change_key_case($fieldCodes, CASE_UPPER);
        $fieldCodesMap   = array_combine(array_keys($keysUpper), $keysMixed);

        foreach ($requests as $original => $upperField) {
            if (array_key_exists($upperField, $fieldCodesMap)) {
                $trackField         = $fieldCodesMap[$upperField];
                $value              = $fieldCodes[$trackField];
                // If it is a date(/time) field export it in ISO format
                if (array_key_exists($trackField, $rawFieldData) && $rawFieldData[$trackField] instanceof \MUtil_Date) {
                    $value = $rawFieldData[$trackField]->get('yyyy-MM-dd HH:mm:ss');
                }
                $results[$original] = $value;
            }
        }

        return $results;
    }
public function getTrackFields($requests)
    {
        $token   = $this->token;
        $results = [];

        // Read fieldcodes and convert to uppercase since requests are uppercase too
        $respondentTrack = $token->getRespondentTrack();
        $fieldCodes      = $respondentTrack->getCodeFields();
        $rawFieldData    = $respondentTrack->getFieldData();    // Date (time) fields are unprocessed here
        $keysMixed       = array_keys($fieldCodes);
        $keysUpper       = array_change_key_case($fieldCodes, CASE_UPPER);
        $fieldCodesMap   = array_combine(array_keys($keysUpper), $keysMixed);

        foreach ($requests as $original => $upperField) {
            if (array_key_exists($upperField, $fieldCodesMap)) {
                $trackField         = $fieldCodesMap[$upperField];
                $value              = $fieldCodes[$trackField];
                // If it is a date(/time) field export it in ISO format
                if (array_key_exists($trackField, $rawFieldData) && $rawFieldData[$trackField] instanceof \MUtil_Date) {
                    $value = $rawFieldData[$trackField]->get('yyyy-MM-dd HH:mm:ss');
                }
                $results[$original] = $value;
            }
        }

        return $results;
    }
public function getTrackFields ( $ requests ) { $ token = $ this -> token ; $ results = [ ] ; // Read fieldcodes and convert to uppercase since requests are uppercase too $ respondentTrack = $ token -> getRespondentTrack ( ) ; $ fieldCodes = $ respondentTrack -> getCodeFields ( ) ; $ rawFieldData = $ respondentTrack -> getFieldData ( ) ; // Date (time) fields are unprocessed here $ keysMixed = array_keys ( $ fieldCodes ) ; $ keysUpper = array_change_key_case ( $ fieldCodes , CASE_UPPER ) ; $ fieldCodesMap = array_combine ( array_keys ( $ keysUpper ) , $ keysMixed ) ; foreach ( $ requests as $ original => $ upperField ) { if ( array_key_exists ( $ upperField , $ fieldCodesMap ) ) { $ trackField = $ fieldCodesMap [ $ upperField ] ; $ value = $ fieldCodes [ $ trackField ] ; // If it is a date(/time) field export it in ISO format if ( array_key_exists ( $ trackField , $ rawFieldData ) && $ rawFieldData [ $ trackField ] instanceof \ MUtil_Date ) { $ value = $ rawFieldData [ $ trackField ] -> get ( 'yyyy-MM-dd HH:mm:ss' ) ; } $ results [ $ original ] = $ value ; } } return $ results ; }
Tries to fulfill request to track fields

@param array $requests
@return array
Tries to fulfill request to track fields