Пример #1
0
 /**
  * @Method("GET|POST")
  * @Route("extension.update", name="api-project.update")
  * @ParamConverter("site", class="Model:Site", options={"request_path":"site", "query_path":"site", "repository_method":"findOneByUid"})
  * @Api("Undine\Form\Type\Api\ExtensionUpdateType")
  */
 public function downloadUpdateFromUrlAction(Site $site, ExtensionUpdateCommand $command)
 {
     $updates = $site->getSiteState()->getSiteUpdates();
     if (!isset($updates[$command->getExtension()])) {
         throw $this->createNotFoundException('The extension could not be found.');
     }
     $extension = $command->getExtension();
     $url = $updates[$command->getExtension()]->getRecommendedDownloadLink();
     $reaction = $this->oxygenClient->sendAsync($site, new ExtensionDownloadUpdateFromUrlAction($extension, $url))->then(function (ExtensionDownloadUpdateFromUrlReaction $reaction) use($site, $extension) {
         return $this->oxygenClient->sendAsync($site, new ExtensionUpdateAction($extension));
     })->then(function (ExtensionUpdateReaction $reaction) use($site) {
         return $this->oxygenClient->sendAsync($site, new DatabaseListMigrationsAction());
     })->then(function (DatabaseListMigrationsReaction $reaction) use($site) {
         $migrationGenerator = function () use($site, $reaction) {
             foreach ($reaction->getMigrations() as $migration) {
                 (yield $this->oxygenClient->sendAsync($site, new DatabaseRunMigrationAction($migration['module'], $migration['number'], $migration['dependencyMap'])));
             }
         };
         return \GuzzleHttp\Promise\each_limit_all($migrationGenerator(), 1);
     })->wait();
     return new ExtensionUpdateResult();
 }
Пример #2
0
 /**
  * Returns a list of parameters that should be passed to the Oxygen module's AttachStateListener.
  * For example, this method attaches 'extensionsChecksum' property, and if it does not match with the 'system' table checksum
  * on the Drupal site that the Oxygen module is on, the module returns full table as a result, and the new checksum.
  *
  * @param Site $site
  *
  * @return array
  */
 public function getParameters(Site $site)
 {
     return ['extensionsChecksum' => $site->getSiteState()->getExtensionsChecksum()];
 }
Пример #3
0
 public function includeState(Site $site)
 {
     return $this->item($site->getSiteState(), $this->transformers->get(SiteState::class));
 }