You are here

class SearchApiSolrAdminCommands in Search API Solr 4.x

Defines Drush commands for the Search API Solr Admin.

Hierarchy

  • class \Drupal\search_api_solr_admin\Commands\SearchApiSolrAdminCommands extends \Drush\Commands\DrushCommands implements \Consolidation\AnnotatedCommand\Input\StdinAwareInterface uses \Consolidation\AnnotatedCommand\Input\StdinAwareTrait

Expanded class hierarchy of SearchApiSolrAdminCommands

1 string reference to 'SearchApiSolrAdminCommands'
drush.services.yml in modules/search_api_solr_admin/drush.services.yml
modules/search_api_solr_admin/drush.services.yml
1 service uses SearchApiSolrAdminCommands
search_api_solr_admin.commands in modules/search_api_solr_admin/drush.services.yml
Drupal\search_api_solr_admin\Commands\SearchApiSolrAdminCommands

File

modules/search_api_solr_admin/src/Commands/SearchApiSolrAdminCommands.php, line 22

Namespace

Drupal\search_api_solr_admin\Commands
View source
class SearchApiSolrAdminCommands extends DrushCommands implements StdinAwareInterface {
  use StdinAwareTrait;

  /**
   * The command helper.
   *
   * @var \Drupal\search_api_solr_admin\Utility\SolrAdminCommandHelper
   */
  protected $commandHelper;

  /**
   * Constructs a SearchApiSolrCommands object.
   *
   * @param \Drupal\search_api_solr_admin\Utility\SolrAdminCommandHelper $commandHelper
   *   The command helper.
   */
  public function __construct(SolrAdminCommandHelper $commandHelper) {
    parent::__construct();
    $this->commandHelper = $commandHelper;
  }

  /**
   * {@inheritdoc}
   */
  public function setLogger(LoggerInterface $logger) {
    parent::setLogger($logger);
    $this->commandHelper
      ->setLogger($logger);
  }

  /**
   * Reload Solr core or collection.
   *
   * @param string $server_id
   *   The ID of the server.
   *
   * @throws \Drupal\search_api\SearchApiException
   * @throws \Drupal\search_api_solr\SearchApiSolrException
   *
   * @command search-api-solr:reload
   *
   * @usage drush search-api-solr:reload server_id
   *   Forces the Solr server to reload the core or collection to apply config changes.
   *
   * @aliases solr-reload
   */
  public function reload(string $server_id) : void {
    $this->commandHelper
      ->reload($server_id);
    $this
      ->logger()
      ->success(dt('Solr core/collection of %server_id reloaded.', [
      '%server_id' => $server_id,
    ]));
  }

  /**
   * Delete Solr collection.
   *
   * @param string $server_id
   *   The ID of the server.
   *
   * @throws \Drupal\search_api\SearchApiException
   * @throws \Drupal\search_api_solr\SearchApiSolrException
   *
   * @command search-api-solr:delete-collection
   *
   * @usage drush search-api-solr:delete-collection server_id
   *   Forces the Solr server to delete the collection.
   *
   * @aliases solr-delete-collection
   */
  public function deleteCollection(string $server_id) : void {
    $this->commandHelper
      ->deleteCollection($server_id);
    $this
      ->logger()
      ->success(dt('Solr collection of %server_id deleted.', [
      '%server_id' => $server_id,
    ]));
  }

  /**
   * Upload a configset and reload the collection or create it.
   *
   * @param string $server_id
   *   The ID of the server.
   * @param string $num_shards
   *   (optional) The number of shards in case a new collection will be created.
   *
   * @throws \Drupal\search_api\SearchApiException
   * @throws \Drupal\search_api_solr\SearchApiSolrException
   * @throws \ZipStream\Exception\FileNotFoundException
   * @throws \ZipStream\Exception\FileNotReadableException
   * @throws \ZipStream\Exception\OverflowException
   *
   * @command search-api-solr:upload-configset
   *
   * @usage drush search-api-solr:upload-configset server_id num_shards
   *   Upload a configset and reload the collection or create it with num_shards.
   *
   * @aliases solr-upload-conf
   */
  public function uploadConfigset(string $server_id, int $num_shards = 3) : void {
    $this->commandHelper
      ->uploadConfigset($server_id, $num_shards, $this
      ->output()
      ->isVerbose());
    $this
      ->logger()
      ->success(dt('Solr configset for %server_id uploaded.', [
      '%server_id' => $server_id,
    ]));
  }

}

Members

Namesort descending Modifiers Type Description Overrides
SearchApiSolrAdminCommands::$commandHelper protected property The command helper.
SearchApiSolrAdminCommands::deleteCollection public function Delete Solr collection.
SearchApiSolrAdminCommands::reload public function Reload Solr core or collection.
SearchApiSolrAdminCommands::setLogger public function
SearchApiSolrAdminCommands::uploadConfigset public function Upload a configset and reload the collection or create it.
SearchApiSolrAdminCommands::__construct public function Constructs a SearchApiSolrCommands object.