<?php
/**
 * @package DJ-Catalog2-Yootheme
 * @copyright Copyright (C) DJ-Extensions.com, All rights reserved.
 * @license http://www.gnu.org/licenses GNU/GPL
 * @author url: http://dj-extensions.com
 * @author email contact@dj-extensions.com
 */

namespace DJExtensions\DJCatalog2\YOOtheme\Presets;
defined('_JEXEC') or die;
use function YOOtheme\app;

class PresetSaveTransform
{
    /**
     * Transform callback.
     *
     * @param object $node
     * @param array  $params
     */
    public function __invoke($node, array $params)
    {
        /** @var Presets $presets */
        $presets = app(Presets::class);

        $list = array_merge(
            $presets->retrievePresets($node, $params['type']),
            $presets->retrievePresetsHtml($node, $params['type'])
        );

        if (!empty($list)) {
            $node->djcatalog2Presets = $list;
        }
    }
}
