Files
2024-10-25 14:16:28 +02:00

80 lines
1.6 KiB
PHP

<?php
/**
* File from http://PrestaShow.pl
*
* DISCLAIMER
* Do not edit or add to this file if you wish to upgrade this module to newer
* versions in the future.
*
* @authors PrestaShow.pl <kontakt@prestashow.pl>
* @copyright 2015 PrestaShow.pl
* @license http://PrestaShow.pl/license
*/
/**
* Addons Adapter
*/
class PShow_Addon
{
/** @var array of \PShow_Addon */
private static $instance = array();
/** @var \Object */
private $addon_instance;
/**
* Check if addons exists in the module
*
* @param string $name
* @return boolean
*/
public static function exists($name)
{
if ($name == 'Multistore') {
return class_exists('PShow_Import_Object_Multistore');
}
return class_exists('PShow_Addon_' . $name);
}
/**
* Get new instance
*
* @param string $name
* @return PShow_Addon
*/
public static function getInstance($name)
{
if (!self::exists($name)) {
return false;
}
if (!array_key_exists($name, self::$instance)) {
self::$instance[$name] = new self('PShow_Addon_' . $name);
}
return self::$instance[$name];
}
/**
*
* @param string $addon_classname
*/
private function __construct($addon_classname)
{
$this->addon_instance = new $addon_classname();
}
/**
*
* @param string $name
* @param array $arguments
* @return mixed
*/
public function __call($name, $arguments)
{
return call_user_func_array(array($this->addon_instance, $name), $arguments);
}
}