protected function setFields($arguments)
    {
        $fieldsConfig = SettingsUtility::getMergedSettings('dataFields', $this->settings, $this->getAction());
        $fields = [];

        // Use field list from query parameters or from defaults.
        if (array_key_exists('data-fields', $arguments) && $arguments['data-fields']) {
            $fields = explode(',', $arguments['data-fields']);
        } else {
            if ($fieldsConfig['default']) {
                $fields = array_values($fieldsConfig['default']);
            }
        }

        // If allowed fields are configured, keep only those.
        $allowedFields = $fieldsConfig['allow'];
        if ($allowedFields) {
            $fields = array_intersect($fields, $allowedFields);
        }

        // If disallowed fields are configured, remove those.
        $disallowedFields = $fieldsConfig['disallow'];
        if ($disallowedFields) {
            $fields = array_diff($fields, $disallowedFields);
        }

        // Only set fields of the query if there is a result. Otherwise use the default setting.
        if ($fields) {
            $this->query->setFields($fields);
        }
    }