elFinder::getPluginInstance PHP Метод

getPluginInstance() защищенный Метод

Get plugin instance & set to $this->plugins
Автор: Naoki Sawada
protected getPluginInstance ( string $name, array $opts = [] ) : object | boolean
$name string Plugin name (dirctory name)
$opts array Plugin options (optional)
Результат object | boolean | bool Plugin object instance Or false
    protected function getPluginInstance($name, $opts = array())
    {
        $key = strtolower($name);
        if (!isset($this->plugins[$key])) {
            $class = 'elFinderPlugin' . $name;
            // to try auto load
            if (!class_exists($class)) {
                $p_file = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . $name . DIRECTORY_SEPARATOR . 'plugin.php';
                if (is_file($p_file)) {
                    include_once $p_file;
                }
            }
            if (class_exists($class, false)) {
                $this->plugins[$key] = new $class($opts);
            } else {
                $this->plugins[$key] = false;
            }
        }
        return $this->plugins[$key];
    }