errorCollector = $callback; } /** * Collect errors. * * @param string $context A context/place where error happened * @param \Throwable $error The error that occurred * * @return void * * @since 4.4.0 */ protected function collectError(string $context, \Throwable $error) { // The errorCollector are required // However when someone already running the script manually the code may fail. if ($this->errorCollector) { call_user_func($this->errorCollector, $context, $error); } else { Log::add($error->getMessage(), Log::ERROR, 'Update'); } } /** * Function to act prior to installation process begins * * @param string $action Which action is happening (install|uninstall|discover_install|update) * @param Installer $installer The class calling this method * * @return boolean True on success * * @since 3.7.0 */ public function preflight($action, $installer) { if ($action === 'update') { // Get the version we are updating from if (!empty($installer->extension->manifest_cache)) { $manifestValues = json_decode($installer->extension->manifest_cache, true); if (array_key_exists('version', $manifestValues)) { $this->fromVersion = $manifestValues['version']; Log::add(Text::_('COM_DEPOT_PREFLIGHT_FROM_VERSION'), Log::INFO, 'Update'); return true; } } return false; } return true; } /** * Method to update Depot * * @param Installer $installer The class calling this method * * @return void */ public function update($installer) { } /** * Called after any type of action * * @param string $action Which action is happening (install|uninstall|discover_install|update) * @param Installer $installer The class calling this method * * @return boolean True on success * * @since 4.0.0 */ public function postflight($action, $installer) { if ($action !== 'update') { return true; } if (empty($this->fromVersion) || version_compare($this->fromVersion, '0.0.1', 'ge')) { return true; } return true; } }