Плагины расширения
Плагины расширения используются как на морде, так и в админке. Они должны быть созданы классов, производных от базового класса VmExtendedPlugin:
public function __construct (&$subject, $config=array()) {
parent::__construct($subject, $config);
$this->_path = JPATH_PLUGINS.DS.$this->getName();
JPlugin::loadLanguage('plg_vmextended_'.$this->getName());
}
Ниже приведен список с событиями и описание на какой момент они вызываются.
onVmAdminController () - Это событие генерируется, когда вызываемый вид не был найден в главном контроллере админки. Это позволяет добавлять новые виды для VirtueMart 2.
Возвращает:
Он должен выполнить контроллер в плагине.
Параметры:
(Строка) Имя контроллера.
/**
* Вставка в бэкэнд логики контроллера для вставки пользовательского контроллера в компонент пространства VM
* Это означает, что ссылки могут быть построены как index.php?option=com_virtuemart&view=myaddon и работать
*
* @param string $controller Имя контроллера запроса
* @return Значение true, если этот файл загружен (в противном случае null)
*/
public function onVmAdminController ($controller)
{
if ($controller = 'myplug')
{
require_once($this->_path.DS.'controllers'.DS.'myplug_admin.php');
return true;
}
return null;
}
onVmSiteController () - Это событие генерируется, когда вызываемый вид не был найден в главном контроллере морды. Это позволяет добавлять новые виды для VirtueMart 2.
Возвращает:
Он должен выполнить контроллер в плагине.
Параметры:
(Строка) Имя контроллера.
/**
* Plugs into the frontend controller logic to insert a custom controller into the VM component space
* This means that links can be constructed as index.php?option=com_virtuemart&view=myaddon and work
*
* @param string $controller Name of controller requested
* @return True if this loads a file (null otherwise)
*/
public function onVmSiteController ($controller)
{
if ($controller = 'myplug') {
require_once($this->_path.DS.'controllers'.DS.'myplug.php');
return true;
}
return null;
}
onVmSqlRemove () Подключается к обновляемой модели , чтобы удалить дополнительные данные VM (полезно, если плагин зависит от полей в таблице VM.)Параметры:
(Объект) VirtueMartModelUpdatesMigration объект.
/**
* Plugs into the updater model to remove additional VM data (useful if the plugin depends on fields in a VM table)
*
* @param object $updater VirtueMartModelUpdatesMigration object
*/
public function onVmSqlRemove (&$updater)
{
$filename = $this->_path.DS.'install'.DS.'uninstall_required_data.sql';
$updater->execSQLFile($filename);
return null;
}
onVmSqlRestore () Подключается к обновляемой модели , чтобы переустановить дополнительные данные VM (полезно, если плагин зависит от полей в таблице VM.)
Параметры:
(Объект) VirtueMartModelUpdatesMigration объект.
/**
* Plugs into the updater model to reinstall additional VM data (useful if the plugin depends on fields in a VM table)
*
* @param object $updater VirtueMartModelUpdatesMigration object
*/
public function onVmSqlRestore (&$updater)
{
$filename = $this->_path.DS.'install'.DS.'install_required_data.sql';
$updater->execSQLFile($filename);
return null;
}