<?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\Config;
defined('_JEXEC') or die;

class FormTransform
{
	/**
	 * Transform callback.
	 *
	 * @param object $node
	 * @param array $params
	 */
	public function __invoke($node, array $params)
	{
		$sections = $node->children;

		foreach ($sections as $section) {
			if ($section->type !== 'column') continue;

			if (!isset($section->props->djc2filters->state) || !$section->props->djc2filters->state) {
				continue;
			}

			$app = \Joomla\CMS\Factory::getApplication();
			$doc = \Joomla\CMS\Factory::getDocument();
			$doc->addScript(\JUri::root() . '/plugins/system/djc2yootheme/modules/config/assets/search.js');
			$doc->addScript(\JUri::root() . '/plugins/system/djc2yootheme/modules/config/assets/script.js');

			$formUniqId = $app->input->get('Itemid');
			$section->type = 'djc2filtersform';

			$section->props->djc2filters_unique_id = $formUniqId;
			$section->props->djc2filters_method = ((isset($section->props->djc2filters->method)) ? $section->props->djc2filters->method : '');
			$categoryId = ((isset($section->props->djc2filters->category)) ? $section->props->djc2filters->category : 0);

			

		}

	}
}