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

namespace ZOOlanders\YOOessentials;

use function YOOtheme\app;
use YOOtheme\Path;
use YOOtheme\Config;
use YOOtheme\Builder;
use ZOOlanders\YOOessentials\Vendor\Symfony\Component\Cache\Adapter\FilesystemAdapter;
use ZOOlanders\YOOessentials\Vendor\Symfony\Contracts\Cache\CacheInterface;

return [
    'config' => [
        'yooessentials' => [
            'version' => '2.3.4',
            'build' => '0217.0955',
        ]
    ],

    'routes' => [
        ['get', CoreController::GET_CHANGELOG_URL, CoreController::class . '@getChangelog'],
    ],

    'events' => [
        'customizer.init' => [
            Listener\LoadCustomizerData::class => [
                ['@loadScript'], // before core assets
                ['@loadAssets', 15] // before other addons
            ],
        ],

        'metadata.load' => [
            Listener\LoadVersion::class => ['@handle', -10]
        ],
    ],

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

            $builder->addTransform('preload', $update);
        },
    ],

    'loaders' => [
        'yooessentials-bootstrap' => new BootstrapsLoader(),
    ],

    'services' => [
        UpdateTransform::class => function (Config $config) {
            return new UpdateTransform($config('yooessentials.version'));
        },

        CacheInterface::class => function () {
            return new FilesystemAdapter('yooessentials', 0, Path::resolve('~theme/cache/'));
        },

        Encrypter::class => function (Config $config) {
            return new Encryption\Encrypter($config('session.token', ''), $config('app.secret', ''));
        },
    ],
];
