Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
pwtyler committed Nov 13, 2024
1 parent b1e21d8 commit 0e0449f
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 60 deletions.
2 changes: 1 addition & 1 deletion search_api_pantheon.services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ services:
- { name: event_subscriber }
search_api_pantheon.reload:
class: Drupal\search_api_pantheon\Services\Reload
arguments: ['@logger.factory', '@search_api_pantheon.pantheon_guzzle']
arguments: ['@logger.factory', '@search_api_pantheon.pantheon_guzzle']
112 changes: 54 additions & 58 deletions src/Services/Reload.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,82 +2,78 @@

namespace Drupal\search_api_pantheon\Services;


use Drupal\Core\Logger\LoggerChannelFactoryInterface;
use Drupal\search_api_pantheon\Exceptions\PantheonSearchApiException;
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\Psr7\Uri;
use Psr\Log\LoggerAwareInterface;
use Psr\Log\LoggerAwareTrait;
use Drupal\search_api_pantheon\Services\PantheonGuzzle;

class Reload implements LoggerAwareInterface {
use LoggerAwareTrait;
use LoggerAwareTrait;

/**
* @var \Drupal\search_api_pantheon\Services\Reload
*/
protected $configuration;
/**
* @var \Drupal\search_api_pantheon\Services\Reload
*/
protected $logger_factory;
/**
* @var \Drupal\search_api_pantheon\Services\Reload
*/
protected $configuration;
/**
* @var \Drupal\search_api_pantheon\Services\Reload
*/
protected $logger_factory;

/**
* @var \Drupal\search_api_pantheon\Services\PantheonGuzzle
*/
protected PantheonGuzzle $client;
/**
* @var \Drupal\search_api_pantheon\Services\PantheonGuzzle
*/
protected PantheonGuzzle $client;

/**
* Class Constructor.
*/
public function __construct(
/**
* Class Constructor.
*/
public function __construct(
LoggerChannelFactoryInterface $logger_factory,
PantheonGuzzle $client,
) {
$this->logger_factory = $logger_factory;
$this->client = $client;
}
$this->logger_factory = $logger_factory;
$this->client = $client;
}

/**
* Reload the server after schema upload.
*
* @throws \Drupal\search_api_pantheon\Exceptions\PantheonSearchApiException
*/
public function reloadServer(): void {
// Schema upload URL.
$uri = new Uri(
$this->getClient()
->getEndpoint()
->getReloadUri()
);

/**
* Reload the server after schema upload.
*
* @throws \Drupal\search_api_pantheon\Exceptions\PantheonSearchApiException
*/
public function reloadServer(): void {
// Schema upload URL.
$uri = new Uri(
$this->getClient()
->getEndpoint()
->getReloadUri()
);
$this->logger->debug('Reload url: ' . (string) $uri);

$this->logger->debug('Reload url: ' . (string) $uri);
// Send the request.
$request = new Request(
'POST',
$uri,
[
'Accept' => 'application/json',
'Content-Type' => 'application/json',
]
);
$response = $this->getClient()->sendRequest($request);

// Send the request.
$request = new Request(
'POST',
$uri,
[
'Accept' => 'application/json',
'Content-Type' => 'application/json',
]
);
$response = $this->getClient()->sendRequest($request);

$status_code = $response->getStatusCode();
$reload_logger_content = [
'status_code' => $status_code,
'reason' => $response->getReasonPhrase(),
];
if ($status_code >= 200 && $status_code < 300) {
$this->logger->info('Server reloaded: {status_code} {reason}', $reload_logger_content);
return;
}
$this->logger->error('Server not reloaded: {status_code} {reason}', $reload_logger_content);
throw new PantheonSearchApiException('Server not reloaded.');
$status_code = $response->getStatusCode();
$reload_logger_content = [
'status_code' => $status_code,
'reason' => $response->getReasonPhrase(),
];
if ($status_code >= 200 && $status_code < 300) {
$this->logger->info('Server reloaded: {status_code} {reason}', $reload_logger_content);
return;
}

$this->logger->error('Server not reloaded: {status_code} {reason}', $reload_logger_content);
throw new PantheonSearchApiException('Server not reloaded.');
}

}
1 change: 0 additions & 1 deletion src/Services/SchemaPoster.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
use Psr\Log\LoggerInterface;
use Drupal\Core\Logger\LoggerChannelFactoryInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\search_api_pantheon\Exceptions\PantheonSearchApiException;

/**
* Posting schema for Pantheon-specific solr driver.
Expand Down

0 comments on commit 0e0449f

Please sign in to comment.