Marcelgwerder\ApiHandler\Parser::parseFields PHP Method

parseFields() protected method

Parse the fields parameter and return an array of fields
protected parseFields ( string $fieldsParam ) : void
$fieldsParam string
return void
    protected function parseFields($fieldsParam)
    {
        $fields = [];
        foreach (explode(',', $fieldsParam) as $field) {
            //Only add the fields that are on the base resource
            if (strpos($field, '.') === false) {
                $fields[] = trim($field);
            } else {
                $this->additionalFields[] = trim($field);
            }
        }
        if (count($fields) > 0) {
            $this->query->addSelect($fields);
        }
        if (is_array($this->query->columns)) {
            $this->query->columns = array_diff($this->query->columns, ['*']);
        }
    }