<?php
/**
 * @package DJ-SectionsAnywhere
 * @copyright Copyright (C) 2017  DJ-Extensions.com LTD, All rights reserved.
 * @license http://www.gnu.org/licenses GNU/GPL
 * @author url: http://dj-extensions.com
 * @author email contact@dj-extensions.com
 *
 * DJContentFilters is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * DJContentFilters is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with DJContentFilters. If not, see <http://www.gnu.org/licenses/>.
 *
 */

defined('_JEXEC') or die;

use Joomla\CMS\Plugin\CMSPlugin;
use Joomla\CMS\Uri\Uri;
use YOOtheme\Application;
use YOOtheme\Path;

class plgSystemDJSectionsAnywhere extends CMSPlugin
{
    public function __construct(&$subject, $config = array())
    {
        parent::__construct($subject, $config);
        $this->loadLanguage();

    }

    public function onBeforeRender() {

    }

    public function onAfterInitialise()
    {
        if (class_exists(Application::class, false)) {
            $app = Application::getInstance();

            $root = __DIR__;
            $rootUrl = Uri::root(true);


            Path::setAlias('~djsectionsanywhere', $root);
            Path::setAlias('~djsectionsanywhere_url', $rootUrl . '/plugins/system/djsectionsanywhere');

            require_once __DIR__ . '/modules/vendor/autoload.php';

            // bootstrap modules
            $app->load('~djsectionsanywhere/modules/builder/bootstrap.php');
        }
    }
}
