<?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\Layouts;
defined('_JEXEC') or die;
use function YOOtheme\app;

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

        $list = array_merge(
            $layouts->retrieveLayouts($node, $params['type']),
            $layouts->retrieveLayoutsHtml($node, $params['type'])
        );

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