mambax7/extgallery

View on GitHub
class/PluginHandler.php

Summary

Maintainability
A
35 mins
Test Coverage
<?php

namespace XoopsModules\Extgallery;

/**
 * ExtGallery Class Manager
 *
 * You may not change or alter any portion of this comment or credits
 * of supporting developers from this source code or any supporting source code
 * which is considered copyrighted (c) material of the original comment or credit authors.
 * This program 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.
 *
 * @copyright   {@link https://xoops.org/ XOOPS Project}
 * @license     GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
 * @author      Zoullou (http://www.zoullou.net)
 * @package     ExtGallery
 */

use XoopsDatabase;
use XoopsModules\Extgallery;


/**
 * Class Extgallery\PluginHandler
 */
class PluginHandler
{
    /**
     * Extgallery\PluginHandler constructor.
     * @param \XoopsDatabase|null $db
     */
    public function __construct(XoopsDatabase $db = null)
    {
    }

    /**
     * @param $event
     * @param $param
     */
    public function triggerEvent($event, &$param)
    {
        require XOOPS_ROOT_PATH . '/modules/extgallery/plugin/plugin.php';
        if (is_iterable($extgalleryPlugin)) {
            foreach ($extgalleryPlugin as $plugin => $status) {
                if (!$status) {
                    continue;
                }

                //            require_once XOOPS_ROOT_PATH . "/modules/extgallery/plugin/$plugin/$plugin.php";

                $class = 'Extgallery' . \ucfirst($plugin);

                $pluginObj = new $class();
                $pluginObj->$event($param);
            }
        }
    }

    public function includeLangFile()
    {
        require_once XOOPS_ROOT_PATH . '/modules/extgallery/plugin/plugin.php';

        foreach ($extgalleryPlugin as $plugin => $status) {
            if (!$status) {
                continue;
            }

            require_once XOOPS_ROOT_PATH . "/modules/extgallery/plugin/$plugin/language/english/main.php";
        }
    }
}