Back to FileAdapter class

Method storeExtension

protected void
storeExtension
()
Method to store the extension to the database
Returns
  • void
Since
  • 3.4
-
  • \RuntimeException
Class: FileAdapter
Project: Joomla

Method storeExtension - Source code

/**
 * Method to store the extension to the database
 *
 * @return  void
 *
 * @since   3.4
 * @throws  \RuntimeException
 */
protected function storeExtension()
{
    if ($this->currentExtensionId) {
        // Load the entry and update the manifest_cache
        $this->extension->load($this->currentExtensionId);
        // Update name
        $this->extension->name = $this->name;
        // Update manifest
        $this->extension->manifest_cache = $this->parent->generateManifestCache();
        if (!$this->extension->store()) {
            // Install failed, roll back changes
            throw new \RuntimeException(Text::sprintf('JLIB_INSTALLER_ABORT_ROLLBACK', Text::_('JLIB_INSTALLER_' . strtoupper($this->route)), $this->extension->getError()));
        }
    } else {
        // Add an entry to the extension table with a whole heap of defaults
        $this->extension->name = $this->name;
        $this->extension->type = 'file';
        $this->extension->element = $this->element;
        $this->extension->changelogurl = $this->changelogurl;
        // There is no folder for files so leave it blank
        $this->extension->folder = '';
        $this->extension->enabled = 1;
        $this->extension->protected = 0;
        $this->extension->access = 0;
        $this->extension->client_id = 0;
        $this->extension->params = '';
        // Update the manifest cache for the entry
        $this->extension->manifest_cache = $this->parent->generateManifestCache();
        if (!$this->extension->store()) {
            // Install failed, roll back changes
            throw new \RuntimeException(Text::sprintf('JLIB_INSTALLER_ABORT_ROLLBACK', Text::_('JLIB_INSTALLER_' . strtoupper($this->route)), $this->extension->getError()));
        }
        // Since we have created a module item, we add it to the installation step stack
        // so that if we have to rollback the changes we can undo it.
        $this->parent->pushStep(array('type' => 'extension', 'extension_id' => $this->extension->extension_id));
    }
}