Example #1
0
    /**
     * Uninstall a package
     *
     * Remove files
     * @param \PEAR2\Pyrus\Package $package
     */
    function uninstall(PackageFileInterface $package, RegistryInterface $reg)
    {
        if (!empty($this->_options['register-only'])) {
            // pretty much nothing happens if we are only registering the install
            return;
        }

        try {
            $config = new Config\Snapshot($package->date . ' ' . $package->time);
        } catch (\Exception $e) {
            throw new Installer\Exception('Cannot retrieve files, config ' .
                                    'snapshot could not be processed', $e);
        }

        $configpaths = array();
        foreach (Installer\Role::getValidRoles($package->getPackageType()) as $role) {
            // set up a list of file role => configuration variable
            // for storing in the registry
            $roleobj = Installer\Role::factory($package->getPackageType(), $role);
            $configpaths[$role] = $config->{$roleobj->getLocationConfig()};
        }

        $ret = array();
        foreach ($reg->info($package->name, $package->channel, 'installedfiles') as $file) {
            $transact = AtomicFileTransaction::getTransactionObject($file['configpath']);
            $transact->removePath($file['relativepath']);
        }
    }