Back to ComponentAdapter class

Method copyBaseFiles

protected void
copyBaseFiles
()
Method to copy the extension's base files from the `<files>` tag(s) and the manifest file
Returns
  • void
Since
  • 3.4
-
  • \RuntimeException

Method copyBaseFiles - Source code

/**
 * Method to copy the extension's base files from the `<files>` tag(s) and the manifest file
 *
 * @return  void
 *
 * @since   3.4
 * @throws  \RuntimeException
 */
protected function copyBaseFiles()
{
    // Copy site files
    if ($this->getManifest()->files) {
        if ($this->route === 'update') {
            $result = $this->parent->parseFiles($this->getManifest()->files, 0, $this->oldFiles);
        } else {
            $result = $this->parent->parseFiles($this->getManifest()->files);
        }
        if ($result === false) {
            throw new \RuntimeException(Text::sprintf('JLIB_INSTALLER_ABORT_COMP_FAIL_SITE_FILES', Text::_('JLIB_INSTALLER_' . strtoupper($this->route))));
        }
    }
    // Copy admin files
    if ($this->getManifest()->administration->files) {
        if ($this->route === 'update') {
            $result = $this->parent->parseFiles($this->getManifest()->administration->files, 1, $this->oldAdminFiles);
        } else {
            $result = $this->parent->parseFiles($this->getManifest()->administration->files, 1);
        }
        if ($result === false) {
            throw new \RuntimeException(Text::sprintf('JLIB_INSTALLER_ABORT_COMP_FAIL_ADMIN_FILES', Text::_('JLIB_INSTALLER_' . strtoupper($this->route))));
        }
    }
    // Copy API files
    if ($this->getManifest()->api->files) {
        if ($this->route === 'update') {
            $result = $this->parent->parseFiles($this->getManifest()->api->files, 3, $this->oldApiFiles);
        } else {
            $result = $this->parent->parseFiles($this->getManifest()->api->files, 3);
        }
        if ($result === false) {
            throw new \RuntimeException(Text::sprintf('JLIB_INSTALLER_ABORT_COMP_FAIL_API_FILES', Text::_('JLIB_INSTALLER_' . strtoupper($this->route))));
        }
    }
    // If there is a manifest script, let's copy it.
    if ($this->manifest_script) {
        $path['src'] = $this->parent->getPath('source') . '/' . $this->manifest_script;
        $path['dest'] = $this->parent->getPath('extension_administrator') . '/' . $this->manifest_script;
        if ($this->parent->isOverwrite() || !file_exists($path['dest'])) {
            if (!$this->parent->copyFiles(array($path))) {
                throw new \RuntimeException(Text::sprintf('JLIB_INSTALLER_ABORT_MANIFEST', Text::_('JLIB_INSTALLER_' . strtoupper($this->route))));
            }
        }
    }
}