<?php
/**
 * @package     MefisAssetBridge
 * @subpackage  Joomla_Administrator_Component
 *
 * @copyright   Copyright (C) 2025 Goran Usljebrka. All rights reserved.
 * @license     Proprietary — No resale or incorporation into other projects without explicit written permission. see LICENSE.txt
 */

namespace Mefi\Component\MefisAssetBridge\Administrator\Extension;

defined('_JEXEC') or die;

use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Psr\Container\ContainerInterface;
use Joomla\CMS\Extension\MVCComponent;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Application\SiteApplication;
use Joomla\CMS\HTML\HTMLRegistryAwareTrait;
use Joomla\CMS\Component\Router\RouterServiceTrait;
use Joomla\CMS\Extension\BootableExtensionInterface;
use Joomla\CMS\Component\Router\RouterServiceInterface;

/**
 * Component class for com_mefisassetbridge
 *
 * @since  1.0.0
 */
class MefisAssetBridgeComponent extends MVCComponent implements BootableExtensionInterface, RouterServiceInterface
{
    use RouterServiceTrait;
    use HTMLRegistryAwareTrait;

    /**
     * Boot the component
     *
     * @param   ContainerInterface  $container  The DI container.
     *
     * @return  void
     *
     * @since   1.0.0
     */
    public function boot(ContainerInterface $container)
    {

        // Load the core library
        $this->loadMefisAssetBridgeCore();

    }

    /**
     * Load MefisAssetBridgeCore library
     *
     * @return void
     *
     * @since 1.0.0
     */
    private function loadMefisAssetBridgeCore(): void
    {
        // Path to the core autoloader
        $corePath = JPATH_ADMINISTRATOR . '/components/com_mefisassetbridge/core/MefisAssetBridgeCore.php';

        if (file_exists($corePath)) {
            require_once $corePath;
        } else {
            // Log error if core library is missing
            $app = Factory::getApplication();
            $app->enqueueMessage(Text::_('COM_MEFISASSETBRIDGE_ERROR_CORE_MISSING'), 'error');
        }
    }
}