Files
MokoSuiteClient/src/script.php
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

73 lines
1.7 KiB
PHP
Raw Normal View History

<?php
/**
* @package MokoWaaS
* @subpackage pkg_mokowaas
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
* @license GNU General Public License version 3 or later; see LICENSE
*/
defined('_JEXEC') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\Installer\InstallerAdapter;
use Joomla\CMS\Log\Log;
/**
* Package installation script for MokoWaaS.
*
* Auto-enables the system plugin and webservices plugin after install.
*
* @since 2.2.0
*/
class Pkg_MokowaasInstallerScript
{
/**
* Runs after package installation/update.
*
* @param string $type Installation type
* @param InstallerAdapter $parent Parent installer
*
* @return void
*
* @since 2.2.0
*/
public function postflight($type, $parent)
{
if ($type === 'install' || $type === 'discover_install')
{
$this->enablePlugin('system', 'mokowaas');
$this->enablePlugin('webservices', 'mokowaas');
}
}
/**
* Enable a plugin by group and element.
*
* @param string $group Plugin group
* @param string $element Plugin element name
*
* @return void
*
* @since 2.2.0
*/
private function enablePlugin(string $group, string $element): void
{
try
{
$db = Factory::getDbo();
$query = $db->getQuery(true)
->update($db->quoteName('#__extensions'))
->set($db->quoteName('enabled') . ' = 1')
->where($db->quoteName('type') . ' = ' . $db->quote('plugin'))
->where($db->quoteName('folder') . ' = ' . $db->quote($group))
->where($db->quoteName('element') . ' = ' . $db->quote($element));
$db->setQuery($query);
$db->execute();
}
catch (\Throwable $e)
{
Log::add('Error enabling plugin ' . $group . '/' . $element . ': ' . $e->getMessage(), Log::WARNING, 'jerror');
}
}
}