protected function execute(InputInterface $input, OutputInterface $output) { $rc = 0; try { $updatableHandles = array(); $force = $input->getOption('force'); if ($input->getOption('all')) { if (count($input->getArgument('packages')) > 0) { throw new Exception('If you use the --all option you can\'t specify package handles.'); } if ($force) { foreach (Package::getInstalledHandles() as $pkgHandle) { $updatableHandles[] = $pkgHandle; } if (empty($updatableHandles)) { $output->writeln("No package has been found."); } } else { foreach (Package::getLocalUpgradeablePackages() as $pkg) { $updatableHandles[] = $pkg->getPackageHandle(); } if (empty($updatableHandles)) { $output->writeln("No package needs to be updated."); } } } else { $updatableHandles = $input->getArgument('packages'); if (empty($updatableHandles)) { throw new Exception('No package handle specified and the --all option has not been specified.'); } } foreach ($updatableHandles as $updatableHandle) { try { $this->updatePackage($updatableHandle, $output, $force); } catch (Exception $x) { $output->writeln('<error>' . $x->getMessage() . '</error>'); $rc = 1; } } } catch (Exception $x) { $output->writeln('<error>' . $x->getMessage() . '</error>'); $rc = 1; } return $rc; }
/** * @deprecated */ public static function getInstalledHandles() { // this should go through the facade instead return \Concrete\Core\Support\Facade\Package::getInstalledHandles(); }
public function getAvailableMarketplaceItems($filterInstalled = true) { $fh = Core::make('helper/file'); if (!$fh) { return array(); } $dbConfig = Core::make('config/database'); // Retrieve the URL contents $csToken = $dbConfig->get('concrete.marketplace.token'); $csiURL = urlencode(Core::getApplicationURL()); $url = Config::get('concrete.urls.concrete5') . Config::get('concrete.urls.paths.marketplace.purchases'); $url .= "?csToken={$csToken}&csiURL=" . $csiURL . "&csiVersion=" . APP_VERSION; $json = $fh->getContents($url, Config::get('concrete.marketplace.request_timeout')); $addons = array(); $objects = @Core::make('helper/json')->decode($json); if (is_array($objects)) { try { foreach ($objects as $addon) { $mi = new RemoteItem(); $mi->setPropertiesFromJSONObject($addon); $remoteCID = $mi->getRemoteCollectionID(); if (!empty($remoteCID)) { $addons[$mi->getHandle()] = $mi; } } } catch (Exception $e) { } if ($filterInstalled && is_array($addons)) { $handles = Package::getInstalledHandles(); if (is_array($handles)) { $adlist = array(); foreach ($addons as $key => $ad) { if (!in_array($ad->getHandle(), $handles)) { $adlist[$key] = $ad; } } $addons = $adlist; } } } return $addons; }