- md5
- 6c79bc509f9ca0df9fe0a2a9ec30fd9a
- sha1
- 6d5d866b8c499bc87c1458728584568b0fb55638
- sha256
- dc626c050f076cf88bad4cdeea6adbce2eef2cd011e5f28bef53922577785192
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
<?php
/**
* Joomla! Content Management System
*
* @copyright (C) 2022 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\CMS\Installer;
/**
* Legacy installer script which delegates the methods to the internal instance when possible.
*
* @since 4.2.0
*/
class LegacyInstallerScript implements InstallerScriptInterface
{
/**
* @var \stdClass
* @since 4.2.0
*/
private $installerScript;
/**
* @param \stdClass $installerScript The script instance
*/
public function __construct($installerScript)
{
$this->installerScript = $installerScript;
}
/**
* Function called after the extension is installed.
*
* @param InstallerAdapter $adapter The adapter calling this method
*
* @return boolean True on success
*
* @since 4.2.0
*/
public function install(InstallerAdapter $adapter): bool
{
return $this->callOnScript('install', [$adapter]);
}
/**
* Function called after the extension is updated.
*
* @param InstallerAdapter $adapter The adapter calling this method
*
* @return boolean True on success
*
* @since 4.2.0
*/
public function update(InstallerAdapter $adapter): bool
{
return $this->callOnScript('update', [$adapter]);
}
/**
* Function called after the extension is uninstalled.
*
* @param InstallerAdapter $adapter The adapter calling this method
*
* @return boolean True on success
*
* @since 4.2.0
*/
public function uninstall(InstallerAdapter $adapter): bool
{
return $this->callOnScript('uninstall', [$adapter]);
}
/**
* Function called before extension installation/update/removal procedure commences.
*
* @param string $type The type of change (install or discover_install, update, uninstall)
* @param InstallerAdapter $adapter The adapter calling this method
*
* @return boolean True on success
*
* @since 4.2.0
*/
public function preflight(string $type, InstallerAdapter $adapter): bool
{
return $this->callOnScript('preflight', [$type, $adapter]);
}
/**
* Function called after extension installation/update/removal procedure commences.
*
* @param string $type The type of change (install or discover_install, update, uninstall)
* @param InstallerAdapter $adapter The adapter calling this method
*
* @return boolean True on success
*
* @since 4.2.0
*/
public function postflight(string $type, InstallerAdapter $adapter): bool
{
return $this->callOnScript('postflight', [$type, $adapter]);
}
/**
* Sets the variable to the internal script.
*
* @param string $name The name of the variable
* @param mixed $value The value of the variable
*
* @return void
*
* @since 4.2.0
*/
public function __set(string $name, $value)
{
$this->installerScript->$name = $value;
}
/**
* Returns the variable from the internal script.
*
* @param string $name The name of the variable
*
* @return mixed
*
* @since 4.2.0
*/
public function __get(string $name)
{
return $this->installerScript->$name;
}
/**
* Calls the function with the given name on the internal script with
* the given name and arguments.
*
* @param string $name The name of the function
* @param array $arguments The arguments
*
* @return mixed
*
* @since 4.2.0
*/
public function __call(string $name, array $arguments)
{
return call_user_func_array([$this->installerScript, $name], $arguments);
}
/**
* Calls the function with the given name on the internal script with
* some condition checking.
*
* @param string $name The name of the function
* @param array $arguments The arguments
*
* @return bool
*
* @since 4.2.0
*/
private function callOnScript(string $name, array $arguments): bool
{
if (!method_exists($this->installerScript, $name)) {
return true;
}
$return = $this->__call($name, $arguments);
// When function doesn't have a return value, assume it succeeded
if ($return === null) {
return true;
}
return (bool) $return;
}
}
The same content is in 5 releases, Joomla 4.2.0-beta3 to 4.2.1-rc2. See them all, or every version of this file.