Remove an uninstalled package from the Assets database

@param \Composer\Package\PackageInterface $package
@param \AssetsManager\Composer\Installer\AssetsInstallerInterface $installer
@return void
322291
public static function unregisterPackage(PackageInterface $package, AssetsInstallerInterface $installer = null)
    {
        self::$__autoloader->unregisterPackage($package, $installer);
    }
914695
public function isInstalled(InstalledRepositoryInterface $repo, PackageInterface $package)
    {
        if (false === parent::isInstalled($repo, $package)) {
            return false;
        }

        $targetRoot = $this->getContaoRoot();

        foreach ($this->getSources($package) as $targetPath) {
            if (!file_exists($this->filesystem->normalizePath($targetRoot . '/' . $targetPath))) {
                return false;
            }
        }

        return true;
    }
790288
public function setLock(PackageInterface $package, $state)
    {
        if ((bool) $state) {
            return $this->lockPackage($package);
        }

        return $this->unlockPackage($package);
    }
428529
protected function removeStandards(InstalledRepositoryInterface $repo, PackageInterface $package)
    {
        $srcStandards = $this->getSourceStandards($package);
        $dstStandards = $this->getDestinationStandards($repo);
        $this->io->writeError('    Removing PHP-CodeSniffer Standards:', false);
        foreach ($srcStandards as $srcStandard) {
            if (! $dstStandards->hasStandard($srcStandard)) {
                continue;
            }
            $this->io->writeError(sprintf(' <info>%s</info>', $srcStandard->getName()));
            $dstStandard = $dstStandards->getStandard($srcStandard);

            $this->filesystem->removeDirectory($dstStandard->getPath());
        }
    }
1108175
public function uninstallWordPressPlugin(PackageEvent $event)
    {
        if (! $this->isWordPressPlugin($this->getPackage($event))) {
            return;
        }
        
        static::$plugin->getInstanceOf(PluginInteractor::class)->uninstall(
            $event->getComposer(),
            $event->getIO(),
            preg_replace('/^wpackagist-plugin\//', '', $this->getPackageName($event))
        );
    }
1364989
public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
    {
        parent::install($repo, $package);

        $this->_installAutoloader($package);
        $this->_copyAssets($package);
    }
970181
protected function installLoader(PackageInterface $package)
    {
        $source = $this->getLoaderFilePackagePath($package);
        $target = $this->getLoaderFileInstallPath($package);

        copy($source, $target);
    }
346122
public function install(\Composer\Repository\InstalledRepositoryInterface $repo, \Composer\Package\PackageInterface $package) {
		parent::install($repo, $package);
		
		$this->removeResources($package);
		$this->installResources($package);
		
	}
129612
function uninstall( $package, $installType, $parameters,
                      $name, $os, $filename, $subdirectory,
                      $content, &$installParameters,
                      &$installData )
    {
        $extensionName = $content->getAttribute( 'name' );

        $siteINI = eZINI::instance();
        $extensionDir = $siteINI->variable( 'ExtensionSettings', 'ExtensionDirectory' ) . '/' . $extensionName;

        // TODO: don't delete modified files?

        if ( file_exists( $extensionDir ) )
            eZDir::recursiveDelete( $extensionDir );

        // Deactivate extension
        $siteINI = eZINI::instance( 'site.ini', 'settings/override', null, null, false, true );
        $selectedExtensions = $siteINI->variable( 'ExtensionSettings', "ActiveExtensions" );

        if ( in_array( $extensionName, $selectedExtensions ) )
        {
            $extensionsFlipped = array_flip( $selectedExtensions );

            $extKey = $extensionsFlipped[$extensionName];
            unset( $selectedExtensions[$extKey] );

            $siteINI->setVariable( "ExtensionSettings", "ActiveExtensions", $selectedExtensions );
            $siteINI->save( 'site.ini.append', '.php', false, false );
        }

        // Regenerate the autoloads to remove of no longer existing classes
        ezpAutoloader::updateExtensionAutoloadArray();

        return true;
    }
1290647
public static function hasExtraActivation(PackageInterface $package)
    {
        $extra = $package->getExtra();

        return isset($extra['foxy']) && true === $extra['foxy'];
    }
1086249
protected function _copyAssets(PackageInterface $package)
    {
        $path       = rtrim($this->getInstallPath($package), '/');
        $asset_path = $path.'/resources/assets';
        $vendor_dir = dirname(dirname($path));

        // Check for libraries/joomla. vendor directory sits in libraries/ folder in Joomla 3.4+
        $is_joomla = is_dir(dirname($vendor_dir).'/joomla') || is_dir(dirname($vendor_dir).'/libraries/joomla');

        if ($is_joomla && is_dir($asset_path))
        {
            $manifest    = $this->_getKoowaManifest($package);

            $root        = is_dir(dirname($vendor_dir).'/joomla') ? dirname(dirname($vendor_dir)) : dirname($vendor_dir);
            $destination = $root.'/media/koowa/com_'.$manifest->name;

            $this->_copyDirectory($asset_path, $destination);
        }
    }
493956
public function isSharedPackage(PackageInterface $package)
    {
        $prettyName = $package->getPrettyName();

        // Avoid putting this package into dependencies folder, because on the first installation the package won't be
        // installed in dependencies folder but in the vendor folder.
        // So I prefer keeping this behavior for further installs.
        if (SharedPackageInstaller::PACKAGE_PRETTY_NAME === $prettyName) {
            return false;
        }

        if ($this->areAllShared || SharedPackageInstaller::PACKAGE_TYPE === $package->getType()) {
            return true;
        }

        foreach ($this->packageCallbacks as $equalityCallback) {
            if ($equalityCallback($prettyName)) {
                return true;
            }
        }

        return false;
    }
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);
            }
        }
    }
792427
public function addPackageUsage(PackageInterface $package)
    {
        $usageData = $this->getPackageUsage($package);
        $packageName = $this->composer->getPackage()->getName();

        if (!in_array($packageName, $usageData)) {
            $usageData[] = $packageName;
        }

        $this->updatePackageUsageFile($package, $usageData);
    }
1133967
public function install(InstalledRepositoryInterface $repo, PackageInterface $package) {
        parent::install($repo, $package);
        $instructions = $this->getInstructions($package);
        if (!$instructions || empty($instructions['install'])) { return; }
        $this->handleInstructions($package, $instructions['install']);
    }
1016339
public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package)
    {
        if ($this->isSourceDirUnused($package) && $this->io->askConfirmation(
                "The package version <info>" . $package->getPrettyName() . "</info> "
                . "(<fg=yellow>" . $package->getPrettyVersion() . "</fg=yellow>) seems to be unused."
                . PHP_EOL
                . 'Do you want to <fg=red>delete the source folder</fg=red> ? [y/n] (default: no) : ',
                false
            )) {
            $this->packageDataManager->setPackageInstallationSource($package);

            parent::uninstall($repo, $package);
        } else {
            $this->binaryInstaller->removeBinaries($package);
            $repo->removePackage($package);
        }

        $this->packageDataManager->removePackageUsage($package);
        $this->removePackageVendorSymlink($package);
    }
638250
protected function removeExtension(PackageInterface $package)
    {
        $extra = $package->getExtra();
        if (isset($extra[self::EXTRA_FIELD]['name'])) {
            $modules = $this->loadConfig(self::FRONTEND_MODULE_FILE);
            unset($modules[$extra[self::EXTRA_FIELD]['name']]);
            $this->saveConfig($modules, self::FRONTEND_MODULE_FILE);

            $backendModules = $this->loadConfig(self::BACKEND_MODULE_FILE);
            unset($backendModules[$extra[self::EXTRA_FIELD]['name']]);
            $this->saveConfig($backendModules, self::BACKEND_MODULE_FILE);

            $migrations = $this->loadConfig(self::MIGRATION_FILE);
            if (isset($extra[self::EXTRA_FIELD]['migrationNamespace'])) {
                foreach ($migrations as $id => $migration) {
                    if ($migration == $extra[self::EXTRA_FIELD]['migrationNamespace']) {
                        unset($migrations[$id]);
                    }
                }
                $this->saveConfig($migrations, self::MIGRATION_FILE);
            }

            $translates = $this->loadConfig(self::TRANSLATE_FILE);
            $translateName = $extra[self::EXTRA_FIELD]['name'] . '*';
            unset($translates[$translateName]);
            $this->saveConfig($translates, self::TRANSLATE_FILE);

        }
    }