Skip to content

Commit

Permalink
toms hasily coded slapdash core reload.
Browse files Browse the repository at this point in the history
  • Loading branch information
stovak committed Nov 12, 2024
1 parent 89fd4bc commit a6b1488
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 17 deletions.
40 changes: 23 additions & 17 deletions src/Plugin/SolrConnector/PantheonSolrConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ class PantheonSolrConnector extends SolrConnectorPluginBase implements
*/
protected $messenger;

/**
* The container.
*
* @var \Symfony\Component\DependencyInjection\ContainerInterface
*/
protected ContainerInterface $container;

/**
* Class constructor.
*/
Expand All @@ -72,19 +79,17 @@ public function __construct(
$plugin_id,
array $plugin_definition,
LoggerChannelFactoryInterface $logger_factory,
PantheonGuzzle $pantheon_guzzle,
PantheonSolariumClient $solarium_client,
DateFormatterInterface $date_formatter,
MessengerInterface $messenger
ContainerInterface $container,
) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->pantheonGuzzle = $pantheon_guzzle;
$this->solariumClient = $solarium_client;
$this->dateFormatter = $date_formatter;
$this->messenger = $messenger;
$this->setLogger($logger_factory->get('PantheonSearch'));
$this->pantheonGuzzle = $container->get('search_api_pantheon.pantheon_guzzle');
$this->solariumClient = $container->get('search_api_pantheon.solarium_client');
$this->dateFormatter = $container->get('date.formatter');
$this->messenger = $container->get('messenger');
$this->setLogger($container->get('logger.factory')->get('PantheonSearch'));
$this->configuration['core'] = self::getPlatformConfig()['core'];
$this->configuration['schema'] = self::getPlatformConfig()['schema'];
$this->container = $container;
$this->connect();
}

Expand All @@ -107,11 +112,7 @@ public static function create(
$configuration,
$plugin_id,
$plugin_definition,
$container->get('logger.factory'),
$container->get('search_api_pantheon.pantheon_guzzle'),
$container->get('search_api_pantheon.solarium_client'),
$container->get('date.formatter'),
$container->get('messenger')
$container,
);
}

Expand Down Expand Up @@ -406,9 +407,14 @@ public function getEndpoint($key = 'search_api_solr') {
* Success or Failure.
*/
public function reloadCore() {
$this->logger->notice(
$this->t('Reload Core action for Pantheon Solr is automatic when Schema is updated.')
);
$sp = $this->container->get('search_api_pantheon.schema_poster');
if (!$sp instanceof SchemaPoster) {
throw new \RuntimeException('Unable to instantiate Schema Poster.');
}
// Get the server id
$server_id = $this->getServerInfo()['server_id'];
$sp->postSchema($server_id);
$sp->reloadCore();
return TRUE;
}

Expand Down
5 changes: 5 additions & 0 deletions src/Services/SchemaPoster.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@ public function postSchema(string $server_id, $files = []): array {
return $this->processResponse($response);
}

/**
* Reload the server after schema upload.
*
* @throws \Drupal\search_api_pantheon\Exceptions\PantheonSearchApiException
*/
public function reloadServer(): void {
// Schema upload URL.
$uri = new Uri(
Expand Down

0 comments on commit a6b1488

Please sign in to comment.