Example #1
0
 public function update($package_id, $initial_extra, $target_extra)
 {
     $io = $this->getIO();
     list($uninstall, $update, $install) = ArrayOps::arrayCircularDiffKey($initial_extra, $target_extra);
     if (!empty($uninstall)) {
         $this->uninstall($package_id, ArrayOps::arrayFilterByKey($uninstall, $initial_extra));
     }
     if (!empty($install)) {
         $this->install($package_id, ArrayOps::arrayFilterByKey($install, $target_extra));
     }
     foreach (ArrayOps::arrayFilterByKey($update, $target_extra) as $name => $config) {
         $io->write("~ Updating route {$name}...");
         $this->getPackageInstaller()->route()->get($name)->merge($config)->persist();
         $io->write("<info>done.</info>", false);
     }
 }
 private function packageUpdate($initial, $target)
 {
     // get initial package properties
     $initial_package_name = $initial->getPrettyName();
     $initial_package_path = $this->composer->getInstallationManager()->getInstallPath($initial);
     $initial_package_version = $initial->getPrettyVersion();
     // get target package properties
     $target_package_name = $target->getPrettyName();
     $target_package_path = $this->composer->getInstallationManager()->getInstallPath($target);
     $target_package_version = $target->getPrettyVersion();
     // get local installer
     $installer = $this->getPackageInstaller();
     // init packagemanager and update package, just in case
     $package_manager = new PackageManager($this->composer, $this->io, $initial_package_path, $installer);
     $package_id = $package_manager->update($initial_package_name, $initial_package_version, $target_package_name, $target_package_version);
     // map actions
     $initial_actions_map = Parser::parse($initial);
     $target_actions_map = Parser::parse($target);
     list($uninstall, $update, $install) = ArrayOps::arrayCircularDiffKey($initial_actions_map, $target_actions_map);
     foreach ($uninstall as $action => $extra) {
         $action_instance = new $action($this->composer, $this->io, $initial_package_path, $installer);
         $action_instance->uninstall($package_id, $extra);
     }
     foreach ($install as $action => $extra) {
         $action_instance = new $action($this->composer, $this->io, $target_package_path, $installer);
         $action_instance->install($package_id, $extra);
     }
     foreach ($update as $action => $extra) {
         $action_instance = new $action($this->composer, $this->io, $target_package_path, $installer);
         $action_instance->update($package_id, $this->initial_actions_map[$action], $extra);
     }
 }