private function buildRow($item, $fields)
    {
        // Remove position for not pinned items.
        if (empty($item['is_pinned']) || filter_var($item['is_pinned'], FILTER_VALIDATE_BOOLEAN) === false) {
            $item['position'] = null;
        }

        foreach (array_keys($fields) as $field) {
            $useDefault = 'use_default_' . $field;
            if (isset($item[$useDefault]) && (filter_var($item[$useDefault], FILTER_VALIDATE_BOOLEAN) === true)) {
                $item[$field] = null;
            }
        }

        // Remove non-existent columns and sort the other according to fields order.
        return array_replace(array_flip(array_keys($fields)), array_intersect_key($item, $fields));
    }