Skip to content

Commit

Permalink
linting
Browse files Browse the repository at this point in the history
  • Loading branch information
stovak committed Nov 13, 2024
1 parent 12cab2c commit 7debd4b
Showing 1 changed file with 87 additions and 91 deletions.
178 changes: 87 additions & 91 deletions src/Plugin/SolrConnector/PantheonSolrConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\search_api_pantheon\Services\PantheonGuzzle;
use Drupal\search_api_pantheon\Services\SolariumClient as PantheonSolariumClient;
use Drupal\Core\Logger\LoggerChannelFactoryInterface;
use Drupal\Core\Datetime\DateFormatterInterface;

/**
Expand Down Expand Up @@ -74,11 +73,10 @@ class PantheonSolrConnector extends SolrConnectorPluginBase implements
* Class constructor.
*/
public function __construct(
array $configuration,
$plugin_id,
array $plugin_definition,
LoggerChannelFactoryInterface $logger_factory,
ContainerInterface $container,
array $configuration,
$plugin_id,
array $plugin_definition,
ContainerInterface $container,
) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->pantheonGuzzle = $container->get('search_api_pantheon.pantheon_guzzle');
Expand All @@ -102,17 +100,17 @@ public function __construct(
* @throws \Exception
*/
public static function create(
ContainerInterface $container,
array $configuration,
$plugin_id,
$plugin_definition
) {
ContainerInterface $container,
array $configuration,
$plugin_id,
$plugin_definition
) {
return new static(
$configuration,
$plugin_id,
$plugin_definition,
$container,
);
$configuration,
$plugin_id,
$plugin_definition,
$container,
);
}

/**
Expand Down Expand Up @@ -171,9 +169,9 @@ public function defaultConfiguration() {
* Form render array.
*/
public function buildConfigurationForm(
array $form,
FormStateInterface $form_state
) {
array $form,
FormStateInterface $form_state
) {
$form = parent::buildConfigurationForm($form, $form_state);

$fields = [
Expand Down Expand Up @@ -209,9 +207,9 @@ function ($field_name) use ($fields) {
* Form state object.
*/
public function validateConfigurationForm(
array &$form,
FormStateInterface $form_state
) {
array &$form,
FormStateInterface $form_state
) {
}

/**
Expand All @@ -223,9 +221,9 @@ public function validateConfigurationForm(
* Form state object.
*/
public function submitConfigurationForm(
array &$form,
FormStateInterface $form_state
) {
array &$form,
FormStateInterface $form_state
) {
$configuration = array_merge($this->defaultConfiguration(), $form_state->getValues());

$this->setConfiguration($configuration);
Expand Down Expand Up @@ -294,16 +292,16 @@ public function getStatsSummary() {
}

$summary = [
'@pending_docs' => '',
'@autocommit_time_seconds' => '',
'@autocommit_time' => '',
'@deletes_by_id' => '',
'@deletes_by_query' => '',
'@deletes_total' => '',
'@schema_version' => '',
'@core_name' => '',
'@index_size' => '',
];
'@pending_docs' => '',
'@autocommit_time_seconds' => '',
'@autocommit_time' => '',
'@deletes_by_id' => '',
'@deletes_by_query' => '',
'@deletes_total' => '',
'@schema_version' => '',
'@core_name' => '',
'@index_size' => '',
];

if (empty($stats) || empty($indexStats)) {
return $summary;
Expand All @@ -312,33 +310,33 @@ public function getStatsSummary() {
$max_time = -1;
$update_handler_stats = $stats['UPDATE']['updateHandler']['stats'] ?? -1;
$summary['@pending_docs'] =
(int) $update_handler_stats['UPDATE.updateHandler.docsPending'] ?? -1;
(int) $update_handler_stats['UPDATE.updateHandler.docsPending'] ?? -1;
if (
isset(
$update_handler_stats['UPDATE.updateHandler.softAutoCommitMaxTime']
)
) {
isset(
$update_handler_stats['UPDATE.updateHandler.softAutoCommitMaxTime']
)
) {
$max_time =
(int) $update_handler_stats['UPDATE.updateHandler.softAutoCommitMaxTime'];
(int) $update_handler_stats['UPDATE.updateHandler.softAutoCommitMaxTime'];
}
$summary['@deletes_by_id'] =
(int) $update_handler_stats['UPDATE.updateHandler.deletesById'] ?? -1;
(int) $update_handler_stats['UPDATE.updateHandler.deletesById'] ?? -1;
$summary['@deletes_by_query'] =
(int) $update_handler_stats['UPDATE.updateHandler.deletesByQuery'] ?? -1;
(int) $update_handler_stats['UPDATE.updateHandler.deletesByQuery'] ?? -1;
$summary['@core_name'] =
$stats['CORE']['core']['class'] ??
$this->t('No information available.');
$stats['CORE']['core']['class'] ??
$this->t('No information available.');
$summary['@index_size'] =
$indexStats['numDocs'] ?? $this->t('No information available.');
$indexStats['numDocs'] ?? $this->t('No information available.');

$summary['@autocommit_time_seconds'] = $max_time / 1000;
$summary['@autocommit_time'] = $this->dateFormatter
->formatInterval($max_time / 1000);
$summary['@deletes_total'] =
(
intval($summary['@deletes_by_id'] ?? 0)
+ intval($summary['@deletes_by_query'] ?? 0)
) ?? -1;
(
intval($summary['@deletes_by_id'] ?? 0)
+ intval($summary['@deletes_by_query'] ?? 0)
) ?? -1;
$summary['@schema_version'] = $this->getSchemaVersionString(TRUE);
return $summary;
}
Expand All @@ -347,9 +345,9 @@ public function getStatsSummary() {
* {@inheritdoc}
*/
public function useTimeout(
string $timeout = self::QUERY_TIMEOUT,
?Endpoint $endpoint = NULL
) {
string $timeout = self::QUERY_TIMEOUT,
?Endpoint $endpoint = NULL
) {
}

/**
Expand All @@ -361,25 +359,25 @@ public function viewSettings() {
$view_settings = [];

$view_settings[] = [
'label' => $this->t('Pantheon Sitename'),
'info' => $this->getEndpoint()->getCore(),
];
'label' => $this->t('Pantheon Sitename'),
'info' => $this->getEndpoint()->getCore(),
];
$view_settings[] = [
'label' => $this->t('Pantheon Environment'),
'info' => getenv('PANTHEON_ENVIRONMENT'),
];
'label' => $this->t('Pantheon Environment'),
'info' => getenv('PANTHEON_ENVIRONMENT'),
];
$view_settings[] = [
'label' => $this->t('Schema Version'),
'info' => $this->getSchemaVersion(TRUE),
];
'label' => $this->t('Schema Version'),
'info' => $this->getSchemaVersion(TRUE),
];

$core_info = $this->getCoreInfo(TRUE);
foreach ($core_info['core'] as $key => $value) {
if (is_string($value)) {
$view_settings[] = [
'label' => ucwords($key),
'info' => $value,
];
'label' => ucwords($key),
'info' => $value,
];
}
}

Expand Down Expand Up @@ -410,10 +408,8 @@ public function reloadCore() {
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();
$this->logger->info('Core reloaded.');
return TRUE;
}

Expand Down Expand Up @@ -468,29 +464,29 @@ protected function createClient(array &$configuration) {
*/
protected function getStatsQuery(string $handler) {
return json_decode(
$this->pantheonGuzzle
->get(
$handler,
[
'query' =>
[
'stats' => 'true',
'wt' => 'json',
'accept' => 'application/json',
'contenttype' => 'application/json',
'json.nl' => 'flat',
],
'headers' =>
[
'Content-Type' => 'application/json',
'Accept' => 'application/json',
],
]
)
->getBody(),
TRUE,
JSON_THROW_ON_ERROR
);
$this->pantheonGuzzle
->get(
$handler,
[
'query' =>
[
'stats' => 'true',
'wt' => 'json',
'accept' => 'application/json',
'contenttype' => 'application/json',
'json.nl' => 'flat',
],
'headers' =>
[
'Content-Type' => 'application/json',
'Accept' => 'application/json',
],
]
)
->getBody(),
TRUE,
JSON_THROW_ON_ERROR
);
}

}

0 comments on commit 7debd4b

Please sign in to comment.