<?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;

use YOOtheme\Builder;
use ZOOlanders\YOOessentials\UpdateTransform;

return [
    'routes' => [['post', GlobalQueryController::PRESAVE_QUERY_ENDPOINT, GlobalQueryController::class . '@presave']],

    'events' => [
        'source.init' => [
            Listener\ExpandCoreSources::class => ['@handle', -900],
            Listener\ExpandJoomlaSources::class => ['@handle', -100],
            Listener\ExpandWordpressSources::class => ['@handle', -100],
        ],

        'customizer.init' => [
            Listener\LoadCustomizerData::class => ['@handle', -10],
        ],

        'builder.type' => [
            Listener\ExtendBuilderType::class => ['@handle', -10],
        ],
    ],

    'extend' => [
        Builder::class => function (Builder $builder, $app) {
            $source = $app(SourceTransform::class);

            $builder->addTransform('preload', [$source, 'preload'], 0);
            $builder->addTransform('prerender', [$source, 'prerender'], 5); // after yoo
        },

        UpdateTransform::class => function (UpdateTransform $update) {
            $update->addGlobals(require __DIR__ . '/updates.php');
        },
    ],
];
