*/
public function createInstallLocation($config_file)
{
- $install_location = $this->_dependencies->getInstance('Components_Pear_InstallLocation');
+ $install_location = $this->_dependencies->createInstance('Components_Pear_InstallLocation');
$install_location->setLocation(
dirname($config_file),
basename($config_file)
/**
* Create a package representation for a specific PEAR environment.
*
+ * @param string $package_file The path of the package XML file.
+ * @param Components_Pear_InstallLocation $environment The PEAR environment.
+ *
+ * @return NULL
+ */
+ public function createPackageForEnvironment(
+ $package_file,
+ Components_Pear_InstallLocation $environment
+ ) {
+ $package = $this->_dependencies->createInstance('Components_Pear_Package');
+ $package->setFactory($this);
+ $package->setEnvironment($environment);
+ $package->setPackageXml($package_file);
+ return $package;
+ }
+
+ /**
+ * Create a package representation for a specific PEAR environment.
+ *
* @param string $package_file The path of the package XML file.
* @param string $config_file The path to the configuration file.
*
*/
public function createPackageForInstallLocation($package_file, $config_file)
{
- $package = $this->_dependencies->getInstance('Components_Pear_Package');
+ $package = $this->_dependencies->createInstance('Components_Pear_Package');
$package->setFactory($this);
$package->setEnvironment($this->createInstallLocation($config_file));
$package->setPackageXml($package_file);
*/
public function createPackageForDefaultLocation($package_file)
{
- $package = $this->_dependencies->getInstance('Components_Pear_Package');
+ $package = $this->_dependencies->createInstance('Components_Pear_Package');
$package->setFactory($this);
$package->setEnvironment($this->_dependencies->getInstance('Components_Pear_InstallLocation'));
$package->setPackageXml($package_file);
}
}
+ /**
+ * Ensure the specified channels exists within the install location.
+ *
+ * @param array $channels The list of channels.
+ *
+ * @return NULL
+ */
+ public function provideChannels(array $channels)
+ {
+ foreach ($channels as $channel) {
+ $this->provideChannel($channel);
+ }
+ }
+
private function getInstallationHandler()
{
$installer = new PEAR_Command_Install(
$this->_getUpdatedPackageFile()->writePackageFile();
$this->_output->ok('Successfully updated ' . $this->_package_xml_path);
}
+
+ /**
+ * Return all channels required for this package and its dependencies.
+ *
+ * @return array The list of channels.
+ */
+ public function listAllRequiredChannels()
+ {
+ $dependencies = array();
+ foreach ($this->_getPackageFile()->getDeps() as $dependency) {
+ if (isset($dependency['channel'])) {
+ $dependencies[] = $dependency['channel'];
+ }
+ }
+ $dependencies[] = $this->_getPackageFile()->getChannel();
+ return array_unique($dependencies);
+ }
+
+ /**
+ * Return all channels required for this package and its dependencies.
+ *
+ * @return array The list of channels.
+ */
+ public function listAllExternalDependencies()
+ {
+ $dependencies = array();
+ foreach ($this->_getPackageFile()->getDeps() as $dependency) {
+ if (isset($dependency['channel']) && $dependency['channel'] != 'pear.horde.org') {
+ $dependencies[] = $dependency;
+ }
+ }
+ return $dependencies;
+ }
+
+ /**
+ * Return all channels required for this package and its dependencies.
+ *
+ * @return array The list of channels.
+ */
+ public function listAllHordeDependencies()
+ {
+ $dependencies = array();
+ foreach ($this->_getPackageFile()->getDeps() as $dependency) {
+ if (isset($dependency['channel']) && $dependency['channel'] == 'pear.horde.org') {
+ $dependencies[] = $dependency;
+ }
+ }
+ return $dependencies;
+ }
+
}
. $dependency . DIRECTORY_SEPARATOR . 'package.xml';
}
- $parser = new PEAR_PackageFile_Parser_v2();
- $parser->setConfig($environment->getPearConfig());
- $pkg = $parser->parse(file_get_contents($package_file), $package_file);
-
- $dependencies = $pkg->getDeps();
- foreach ($dependencies as $dependency) {
- if (isset($dependency['channel']) && $dependency['channel'] != 'pear.horde.org') {
- $environment->provideChannel($dependency['channel']);
- $key = $dependency['channel'] . '/' . $dependency['name'];
- if (in_array($key, $this->_run)) {
- continue;
- }
- $environment->addPackageFromPackage(
- $dependency['channel'], $dependency['name']
- );
- $this->_run[] = $key;
- } else if (isset($dependency['channel'])) {
- $environment->provideChannel($dependency['channel']);
- $key = $dependency['channel'] . '/' . $dependency['name'];
- if (in_array($key, $this->_run)) {
- continue;
- }
- $this->_run[] = $key;
- $this->_installHordeDependency($environment, $root_path, $dependency['name']);
+ $pkg = $this->_factory->createPackageForEnvironment($package_file, $environment);
+ $environment->provideChannels($pkg->listAllRequiredChannels());
+ foreach ($pkg->listAllExternalDependencies() as $dependency) {
+ $key = $dependency['channel'] . '/' . $dependency['name'];
+ if (in_array($key, $this->_run)) {
+ continue;
+ }
+ $environment->addPackageFromPackage(
+ $dependency['channel'], $dependency['name']
+ );
+ $this->_run[] = $key;
+ }
+ foreach ($pkg->listAllHordeDependencies() as $dependency) {
+ $key = $dependency['channel'] . '/' . $dependency['name'];
+ if (in_array($key, $this->_run)) {
+ continue;
}
+ $this->_run[] = $key;
+ $this->_installHordeDependency($environment, $root_path, $dependency['name']);
}
if (in_array($package_file, $this->_run)) {
return;
}
- $environment->provideChannel($pkg->getChannel());
$environment->addPackageFromSource(
$package_file
);