Back to Installer class

Method update

public bool
update
(mixed $path = null)
Package update method
Parameters
  • string $path Path to package source folder
Returns
  • bool True if successful
Since
  • 3.1
Class: Installer
Project: Joomla

Method update - Source code

/**
 * Package update method
 *
 * @param   string  $path  Path to package source folder
 *
 * @return  boolean  True if successful
 *
 * @since   3.1
 */
public function update($path = null)
{
    if ($path && Folder::exists($path)) {
        $this->setPath('source', $path);
    } else {
        $this->abort(Text::_('JLIB_INSTALLER_ABORT_NOUPDATEPATH'));
        return false;
    }
    if (!($adapter = $this->setupInstall('update', true))) {
        $this->abort(Text::_('JLIB_INSTALLER_ABORT_DETECTMANIFEST'));
        return false;
    }
    if (!\is_object($adapter)) {
        return false;
    }
    // Add the languages from the package itself
    if (method_exists($adapter, 'loadLanguage')) {
        $adapter->loadLanguage($path);
    }
    // Fire the onExtensionBeforeUpdate event.
    PluginHelper::importPlugin('extension');
    Factory::getApplication()->triggerEvent('onExtensionBeforeUpdate', array('type' => $this->manifest->attributes()->type, 'manifest' => $this->manifest));
    // Run the update
    $result = $adapter->update();
    // Fire the onExtensionAfterUpdate
    Factory::getApplication()->triggerEvent('onExtensionAfterUpdate', array('installer' => clone $this, 'eid' => $result));
    if ($result !== false) {
        return true;
    }
    return false;
}