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

namespace ZOOlanders\YOOessentials\Dynamic;

class SourceTransform
{
    protected DynamicResolver $resolver;

    protected array $queries;

    public function __construct(DynamicResolver $resolver)
    {
        $this->resolver = $resolver;
    }

    // in YTP 4 preload is run per the whole tree before prerender
    public function preload(object $node, array &$params)
    {
        if (($params['context'] ?? '') !== 'render') {
            return;
        }

        $this->resolver->resolveGlobalQueries($node);
        $this->resolver->resolveQueryArguments($node, $params);
    }

    public function prerender(object $node, array &$params)
    {
        $this->resolver->resolveProps($node, $params);
    }
}
