<?php
/**
 * @package   Essentials YOOtheme Pro 2.3.4 build 0217.0955
 * @author    ZOOlanders https://www.zoolanders.com
 * @copyright Copyright (C) Joolanders, SL
 * @license   http://www.gnu.org/licenses/gpl.html GNU/GPL
 */

use ZOOlanders\YOOessentials\Dynamic\Update230Helper;

return [
    'nodes' => [
        '2.3.0' => function ($node) {
            // migrate multi-option fields
            Update230Helper::iterateNodeSources($node, function ($source) {
                $isFormQuery = fn ($src) => ($src->query->name ?? '') === 'yooessentials_form_query';
                $isMultiOptionField = fn ($src) => isset($src->name, $src->implode);

                if ($isFormQuery($source) && $isMultiOptionField($source)) {
                    $source->query->field = clone (object) [
                        'name' => $source->name
                    ];

                    $source->name = 'value';
                }
            });
        },
    ],
];
