예제 #1
0
 /**
  * Get packages that a properly installed, pending installed and locally installed.
  *
  * @return PackageCollection
  */
 public function getAllPackages()
 {
     $collection = new PackageCollection();
     if ($this->started === false) {
         return $collection;
     }
     // Installed
     $installed = $this->app['extend.action']['show']->execute('installed');
     foreach ($installed as $composerPackage) {
         $package = Package::createFromComposerPackage($composerPackage['package']);
         $name = $package->getName();
         $extension = $this->app['extensions']->getResolved($name);
         // Handle non-Bolt packages
         if ($extension) {
             $title = $extension->getDisplayName();
             $constraint = $extension->getDescriptor()->getConstraint() ?: $this->app['bolt_version'];
             $readme = $this->linkReadMe($extension);
             $config = $this->linkConfig($extension);
             $valid = $extension->isValid();
             $enabled = $extension->isEnabled();
         } else {
             $title = $name;
             $constraint = $this->app['bolt_version'];
             $readme = null;
             $config = null;
             $valid = true;
             $enabled = true;
         }
         $package->setStatus('installed');
         $package->setTitle($title);
         $package->setReadmeLink($readme);
         $package->setConfigLink($config);
         $package->setConstraint($constraint);
         $package->setValid($valid);
         $package->setEnabled($enabled);
         $collection->add($package);
     }
     // Local
     $extensions = $this->app['extensions']->all();
     foreach ($extensions as $name => $extension) {
         if ($collection->get($extension->getId())) {
             continue;
         }
         /** @var JsonFile $composerJson */
         $composerJson = $extension->getBaseDirectory()->get('composer.json');
         $package = Package::createFromComposerJson($composerJson->parse());
         $package->setStatus('local');
         $package->setTitle($extension->getDisplayName());
         $package->setReadmeLink($this->linkReadMe($extension));
         $package->setConfigLink($this->linkConfig($extension));
         $package->setValid($extension->isValid());
         $package->setEnabled($extension->isEnabled());
         $collection->add($package);
     }
     // Pending
     $requires = isset($this->json['require']) ? $this->json['require'] : [];
     foreach ($requires as $name => $version) {
         if ($collection->get($name)) {
             continue;
         }
         $package = new Package();
         $package->setStatus('pending');
         $package->setName($name);
         $package->setTitle($name);
         $package->setReadmeLink(null);
         $package->setConfigLink(null);
         $package->setVersion($version);
         $package->setType('unknown');
         $package->setDescription(Trans::__('Not yet installed.'));
         $collection->add($package);
     }
     return $collection;
 }
예제 #2
0
 /**
  * Get packages that a properly installed, pending installed and locally installed.
  *
  * @return PackageCollection
  */
 public function getAllPackages()
 {
     $collection = new PackageCollection();
     if ($this->started === false) {
         return $collection;
     }
     // Installed
     $installed = $this->app['extend.action']['show']->execute('installed');
     foreach ($installed as $composerPackage) {
         /** @var CompletePackageInterface $composerPackage */
         $composerPackage = $composerPackage['package'];
         $package = Package::createFromComposerPackage($composerPackage);
         $name = $package->getName();
         $extension = $this->app['extensions']->getResolved($name);
         // Handle non-Bolt packages
         if ($extension) {
             $title = $extension->getDisplayName();
             $constraint = $extension->getDescriptor()->getConstraint() ?: Bolt\Version::VERSION;
             $readme = $this->linkReadMe($extension);
             $config = $this->linkConfig($extension);
             $valid = $extension->isValid();
             $enabled = $extension->isEnabled();
         } else {
             $title = $name;
             $constraint = Bolt\Version::VERSION;
             $readme = null;
             $config = null;
             $valid = true;
             $enabled = true;
         }
         $package->setStatus('installed');
         $package->setTitle($title);
         $package->setReadmeLink($readme);
         $package->setConfigLink($config);
         $package->setRepositoryLink($composerPackage->getSourceUrl());
         $package->setConstraint($constraint);
         $package->setValid($valid);
         $package->setEnabled($enabled);
         $collection->add($package);
     }
     // Pending
     $requires = isset($this->json['require']) ? $this->json['require'] : [];
     foreach ($requires as $name => $version) {
         if ($collection->get($name)) {
             continue;
         }
         $package = new Package();
         $package->setStatus('pending');
         $package->setName($name);
         $package->setTitle($name);
         $package->setReadmeLink(null);
         $package->setConfigLink(null);
         $package->setVersion($version);
         $package->setType('unknown');
         $package->setDescription(Trans::__('general.phrase.not-installed-yet'));
         $collection->add($package);
     }
     return $collection;
 }