Provides installation path for package. Kudos go to
https://github.com/johnpbloch/wordpress-core-installer

@param PackageInterface $package Installed package.

@todo refactor

@return string
@since 0.1.0
420149
public function getInstallPath(PackageInterface $package)
    {
        $prettyName = $package->getPrettyName();
        DebugPrinter::log(
            'Getting install path for `%s` package',
            array($prettyName,)
        );
        if (isset($this->installDirCache[$prettyName])) {
            return $this->installDirCache[$prettyName];
        }
        $installDir = null;
        if ($this->composer->getPackage()) {
            $rootExtra = $this->composer->getPackage()->getExtra();
            if (!empty($rootExtra['opencart-install-dir'])) {
                $installDir = $rootExtra['opencart-install-dir'];
            }
        }
        if (!$installDir) {
            $extra = $package->getExtra();
            if (!empty($extra['opencart-install-dir'])) {
                $installDir = $extra['opencart-install-dir'];
            }
        }
        if (is_array($installDir)) {
            if (isset($installDir[$prettyName])) {
                $this->installDirCache[$prettyName] = $installDir[$prettyName];
                return $installDir[$prettyName];
            }
            $this->installDirCache[$prettyName] = $this->defaultInstallDir;
            return $this->defaultInstallDir;
        }
        $installDir = $installDir ? $installDir : $this->defaultInstallDir;
        DebugPrinter::log(
            'Computed install dir for package `%s`: `%s`',
            array($prettyName, $installDir,)
        );
        $this->installDirCache[$prettyName] = $installDir;
        return $installDir;
    }
707032
protected function installPatchesForPackage(PackageInterface $package)
    {
        $considerPatchErrorsAsWarnings = $this->considerPatchErrorsAsWarnings();
        $patches = $this->getPatchCollection()->getPatchesFor($package);
        $patcher = $this->getPatcher();
        $appliedPatchesToSave = method_exists($package, 'setExtra') ? array() : null;
        foreach ($patches->getPatches() as $patch) {
            try {
                $patcher->applyPatch($patch, $package);
                if ($appliedPatchesToSave !== null) {
                    $appliedPatchesToSave[] = array(
                        'from-package' => $patch->getFromPackage()->getPrettyString(),
                        'path' => $patch->getOriginalPath(),
                        'description' => $patch->getDescription(),
                    );
                }
            } catch (GenericException $x) {
                $appliedPatchesToSave = null;
                if (!$considerPatchErrorsAsWarnings) {
                    throw $x;
                }
                $this->io->write('<error>'.$x->getMessage().'</error>');
            }
        }
        if ($appliedPatchesToSave !== null) {
            $this->setPatchedPackageData($package, array(
                'hash' => $patches->getHash(),
                'list' => $appliedPatchesToSave,
            ));
        }
    }
970181
protected function installLoader(PackageInterface $package)
    {
        $source = $this->getLoaderFilePackagePath($package);
        $target = $this->getLoaderFileInstallPath($package);

        copy($source, $target);
    }
890536
protected function loadInits(PackageInterface $package)
    {
        if (!$package->getInits()) {
            return $this;
        }

        $initLoader = \Parable\DI\Container::create(\Parable\Framework\Loader\InitLoader::class);
        $initLoader->load($package->getInits());
        return $this;
    }
1326639
public function getInstallPath(PackageInterface $package)
    {
        $textpattern = new Textpattern();
        $path = $textpattern->getRelativePath();
        $themes = $path . '/admin-themes';

        // Textpattern <= 4.5.x uses 'theme' directory.
        if (!file_exists($themes)) {
            $themes = $path . '/theme';
        }

        return $themes . '/' . basename($package->getPrettyName());
    }
938154
public function getInstallPath(PackageInterface $package)
    {
        if ($package->getType() === 'oxid-base') {
            return $this->_locations[$package->getType()];
        }
        $themeName = "ra";
        $extra = $package->getExtra();
        $installFolder = $this->_locations[$package->getType()] . '/' . str_replace(array($themeName . "/", '-theme'), '', $package->getPrettyName());
        if ($extra) {
            $themeName = $extra["themeName"];
            $installFolder = $this->_locations[$package->getType()] . '/' . $themeName;
        }

        return $installFolder;
    }
45660
public function getRequiredVersion(RootPackageInterface $package)
    {
        foreach (array($package->getRequires(), $package->getDevRequires()) as $requiredPackages) {
            if (isset($requiredPackages[static::PACKAGE_NAME])) {
                return $requiredPackages[static::PACKAGE_NAME]->getPrettyConstraint();
            }
        }
        throw new \RuntimeException('Can not determine required version of ' . static::PACKAGE_NAME);
    }
248903
public function getInstallPath( PackageInterface $package, $frameworkType = '' ) {
		$type = $this->package->getType();

		$prettyName = $this->package->getPrettyName();
		if( strpos($prettyName, '/') !== false ) {
			list($vendor, $name) = explode('/', $prettyName);
		} else {
			$vendor = '';
			$name   = $prettyName;
		}

		$availableVars = $this->inflectPackageVars(compact('name', 'vendor', 'type'));

		$extra = $package->getExtra();
		if( !empty($extra['installer-name']) ) {
			$availableVars['name'] = $extra['installer-name'];
		}

		if( $this->composer->getPackage() ) {
			$extra = $this->composer->getPackage()->getExtra();
			if( !empty($extra['installer-paths']) ) {
				$customPath = $this->mapCustomInstallPaths($extra['installer-paths'], $prettyName, $type);
				if( $customPath !== false ) {
					return $this->templatePath($customPath, $availableVars);
				}
			}
		}

		$packageType = substr($type, strlen($frameworkType) + 1);
		if( !isset($this->locations[$packageType]) ) {
			throw new \InvalidArgumentException(sprintf('Package type "%s" is not supported', $type));
		}

		return $this->templatePath($this->locations[$packageType], $availableVars);
	}
172623
private function getCommandsFolder(ContainerInterface $container): string
    {
        assert($container->has(CacheSettingsProviderInterface::class));

        /** @var CacheSettingsProviderInterface $provider */
        $provider  = $container->get(CacheSettingsProviderInterface::class);
        $appConfig = $provider->getApplicationConfiguration();
        $folder    = $appConfig[S::KEY_COMMANDS_FOLDER];

        return $folder;
    }
1097372
public function unlinkDropins(PackageInterface $package)
    {
        $content_dir = realpath($this->getContentPath());
        $dropins_dir = realpath($this->getInstallPath($package) . '/dropins/');

        // Link dropins not yet added.
        foreach (new \DirectoryIterator($dropins_dir) as $dropin) {
            if ($dropin->isDot()) {
                continue;
            }

            $src  = $content_dir . '/' . $dropin->getFilename();
            $dest = $dropins_dir . '/' . $dropin->getFilename();

            if (file_exists($src)) {
                $this->io->write('<info>Unlinking ' . $this->filesystem->findShortestPath($src, $dest) . '</info>');
                unlink($src);
            }
        }
    }
487497
protected function getModuleName(PackageInterface $package)
    {
        $extra = $package->getExtra();

        if (isset($extra['modulename'])) {
            $name = $extra['modulename'];
        } else {
            $name = strtr($package->getPrettyName(), array(
                '\\' => '.',
                '-' => '.',
                '_' => '.',
                ' ' => ''
            ));
        }

        return $name;
    }
1001152
public function getInstallPath(PackageInterface $package)
    {
        if ($this->solver->isSharedPackage($package)) {
            return $this->symlinkInstaller->getInstallPath($package);
        }

        return $this->defaultInstaller->getInstallPath($package);
    }
106832
public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package)
	{
		if (getenv('OPUS_DISABLED')) {
			parent::uninstall($repo, $package);
			return;
		}

		//
		// Return immediately if we have no information relevant to our installer
		//

		if (!$this->checkFrameworkSupport($package)) {
			return;
		}

		$this->loadInstallationMap();

		foreach ($this->installationMap as $path => $packages) {
			if (($key = array_search($package->getName(), $packages)) !== FALSE) {
				unset($this->installationMap[$path][$key]);
			}
		}

		$this->cleanup();
		$this->saveInstallationMap();

		parent::uninstall($repo, $package);
	}
1012276
protected function removePackageVendorSymlink(PackageInterface $package)
    {
        if (
            $this->config->isSymlinkEnabled()
            && $this->filesystem->removeSymlink($this->getPackageVendorSymlink($package))
        ) {
            $this->io->write(array(
                '  - Deleting symlink for <info>' . $package->getPrettyName() . '</info> '
                . '(<fg=yellow>' . $package->getPrettyVersion() . '</fg=yellow>)',
                ''
            ));

            $symlinkParentDirectory = dirname($this->getPackageVendorSymlink($package));
            $this->filesystem->removeEmptyDirectory($symlinkParentDirectory);
        }
    }
1151607
protected function getRootPath(PackageInterface $package)
    {
        $rootPath = $this->vendorDir . '/raulfraile/ladybug-themes/Ladybug/';

        if ($this->composer->getPackage()->getName() === 'raulfraile/ladybug') {
            $rootPath = 'data/' . ($package->getType() === self::PACKAGE_TYPE_THEME ? 'themes' : 'plugins') . '/Ladybug/';
        }

        $rootPath .= ($package->getType() === self::PACKAGE_TYPE_THEME) ? 'Theme' : 'Plugin';

        return $rootPath;
    }
69654
protected static function isAsset(PackageInterface $package)
    {
        foreach (Assets::getTypes() as $type) {
            $type = Assets::createType($type);

            if ($package->getType() === $type->getComposerType()) {
                return true;
            }
        }

        return false;
    }
1130313
private function getPackageName(PackageInterface $package)
    {
        if (is_array($package->getExtra()) && isset($package->getExtra()['installer-name'])) {
            return $package->getExtra()['installer-name'];
        }

        $name = explode('/', $package->getPrettyName());
        $packageName = $name[1];

        if (count(explode('-', $packageName)) < 2) {
            throw new Exception('Bundle names should be like "vendor/NAME-bundle"');
        }

        $packageName = str_replace('-bundle', '', $packageName);

        return str_replace(' ', '', ucwords(str_replace('-', ' ', $packageName)));
    }