예제 #1
0
 public function view()
 {
     $error = \Core::make('helper/validation/error');
     $r = $this->item->download();
     if ($r != false) {
         $error->add($r);
     }
     if (!$error->has()) {
         $pkg = PackageService::getByHandle($this->item->getHandle());
         if (is_object($pkg)) {
             $tests = $pkg->testForInstall();
             if (is_object($tests)) {
                 $error->add($tests);
             } else {
                 $p = PackageService::getClass($this->item->getHandle());
                 try {
                     $p->install();
                 } catch (\Exception $e) {
                     $error->add($e->getMessage());
                 }
             }
         }
     }
     $this->set('error', $error);
     $this->set('mri', $this->item);
 }
예제 #2
0
 /**
  * @deprecated
  */
 public static function getByHandle($pkgHandle)
 {
     // this should go through the facade instead
     return \Concrete\Core\Support\Facade\Package::getByHandle($pkgHandle);
 }
 protected function updatePackage($pkgHandle, OutputInterface $output, $force)
 {
     $output->write("Looking for package '{$pkgHandle}'... ");
     $pkg = null;
     foreach (Package::getInstalledList() as $installed) {
         if ($installed->getPackageHandle() === $pkgHandle) {
             $pkg = $installed;
             break;
         }
     }
     if ($pkg === null) {
         throw new Exception(sprintf("No package with handle '%s' is installed", $pkgHandle));
     }
     $output->writeln(sprintf('<info>found (%s).</info>', $pkg->getPackageName()));
     $output->write('Checking preconditions... ');
     $upPkg = null;
     foreach (Package::getLocalUpgradeablePackages() as $updatable) {
         if ($updatable->getPackageHandle() === $pkgHandle) {
             $upPkg = $updatable;
             break;
         }
     }
     if ($upPkg === null && $force !== true) {
         $output->writeln(sprintf("<info>the package is already up-to-date (v%s)</info>", $pkg->getPackageVersion()));
     } else {
         $test = $pkg->testForInstall(false);
         if (is_object($test)) {
             /**
              * @var $test Error
              */
             throw new Exception(implode("\n", $test->getList()));
         }
         $output->writeln('<info>good.</info>');
         if ($upPkg === null) {
             $output->write(sprintf('Forcing upgrade at v%s... ', $pkg->getPackageVersion()));
             $upPkg = Package::getByHandle($pkgHandle);
         } else {
             $output->write(sprintf('Updating from v%s to v%s... ', $upPkg->getPackageEntity()->getPackageVersion(), $upPkg->getPackageVersion()));
         }
         $upPkg->upgradeCoreData();
         $upPkg->upgrade();
         $output->writeln('<info>done.</info>');
     }
 }
예제 #4
0
 /**
  * Runs through all packages on the marketplace, sees if they're installed here, and updates the available version number for them.
  */
 public static function checkPackageUpdates()
 {
     $em = \ORM::entityManager();
     $items = self::getAvailableMarketplaceItems(false);
     foreach ($items as $i) {
         $p = Package::getByHandle($i->getHandle());
         if (is_object($p)) {
             /**
              * @var $p \Concrete\Core\Entity\Package
              */
             $p->setPackageAvailableVersion($i->getVersion());
             $em->persist($p);
         }
     }
     $em->flush();
 }