[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * Joomla! Content Management System 5 * 6 * @copyright (C) 2022 Open Source Matters, Inc. <https://www.joomla.org> 7 * @license GNU General Public License version 2 or later; see LICENSE.txt 8 */ 9 10 namespace Joomla\CMS\Installer; 11 12 // phpcs:disable PSR1.Files.SideEffects 13 \defined('_JEXEC') or die; 14 // phpcs:enable PSR1.Files.SideEffects 15 16 /** 17 * Legacy installer script which delegates the methods to the internal instance when possible. 18 * 19 * @since 4.2.0 20 */ 21 class LegacyInstallerScript implements InstallerScriptInterface 22 { 23 /** 24 * @var \stdClass 25 * @since 4.2.0 26 */ 27 private $installerScript; 28 29 /** 30 * @param \stdClass $installerScript The script instance 31 */ 32 public function __construct($installerScript) 33 { 34 $this->installerScript = $installerScript; 35 } 36 37 /** 38 * Function called after the extension is installed. 39 * 40 * @param InstallerAdapter $adapter The adapter calling this method 41 * 42 * @return boolean True on success 43 * 44 * @since 4.2.0 45 */ 46 public function install(InstallerAdapter $adapter): bool 47 { 48 return $this->callOnScript('install', [$adapter]); 49 } 50 51 /** 52 * Function called after the extension is updated. 53 * 54 * @param InstallerAdapter $adapter The adapter calling this method 55 * 56 * @return boolean True on success 57 * 58 * @since 4.2.0 59 */ 60 public function update(InstallerAdapter $adapter): bool 61 { 62 return $this->callOnScript('update', [$adapter]); 63 } 64 65 /** 66 * Function called after the extension is uninstalled. 67 * 68 * @param InstallerAdapter $adapter The adapter calling this method 69 * 70 * @return boolean True on success 71 * 72 * @since 4.2.0 73 */ 74 public function uninstall(InstallerAdapter $adapter): bool 75 { 76 return $this->callOnScript('uninstall', [$adapter]); 77 } 78 79 /** 80 * Function called before extension installation/update/removal procedure commences. 81 * 82 * @param string $type The type of change (install or discover_install, update, uninstall) 83 * @param InstallerAdapter $adapter The adapter calling this method 84 * 85 * @return boolean True on success 86 * 87 * @since 4.2.0 88 */ 89 public function preflight(string $type, InstallerAdapter $adapter): bool 90 { 91 return $this->callOnScript('preflight', [$type, $adapter]); 92 } 93 94 /** 95 * Function called after extension installation/update/removal procedure commences. 96 * 97 * @param string $type The type of change (install or discover_install, update, uninstall) 98 * @param InstallerAdapter $adapter The adapter calling this method 99 * 100 * @return boolean True on success 101 * 102 * @since 4.2.0 103 */ 104 public function postflight(string $type, InstallerAdapter $adapter): bool 105 { 106 return $this->callOnScript('postflight', [$type, $adapter]); 107 } 108 109 /** 110 * Sets the variable to the internal script. 111 * 112 * @param string $name The name of the variable 113 * @param mixed $value The value of the variable 114 * 115 * @return void 116 * 117 * @since 4.2.0 118 */ 119 public function __set(string $name, $value) 120 { 121 $this->installerScript->$name = $value; 122 } 123 124 /** 125 * Returns the variable from the internal script. 126 * 127 * @param string $name The name of the variable 128 * 129 * @return mixed 130 * 131 * @since 4.2.0 132 */ 133 public function __get(string $name) 134 { 135 return $this->installerScript->$name; 136 } 137 138 /** 139 * Calls the function with the given name on the internal script with 140 * the given name and arguments. 141 * 142 * @param string $name The name of the function 143 * @param array $arguments The arguments 144 * 145 * @return mixed 146 * 147 * @since 4.2.0 148 */ 149 public function __call(string $name, array $arguments) 150 { 151 return call_user_func_array([$this->installerScript, $name], $arguments); 152 } 153 154 /** 155 * Calls the function with the given name on the internal script with 156 * some condition checking. 157 * 158 * @param string $name The name of the function 159 * @param array $arguments The arguments 160 * 161 * @return bool 162 * 163 * @since 4.2.0 164 */ 165 private function callOnScript(string $name, array $arguments): bool 166 { 167 if (!method_exists($this->installerScript, $name)) { 168 return true; 169 } 170 171 $return = $this->__call($name, $arguments); 172 173 // When function doesn't have a return value, assume it succeeded 174 if ($return === null) { 175 return true; 176 } 177 178 return (bool) $return; 179 } 180 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Sep 7 05:41:13 2022 | Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer |