SearchCommands
Drush commands for core's Search module.
Search pages are loaded as config entities rather than through the Search module's services, so this class can be loaded without the module.
- Full name:
\Drupal\helper\Drush\Commands\SearchCommands - Parent class:
DrushCommands - This class implements:
SiteAliasManagerAwareInterface
Properties
style
The output style, built here because DrushCommands::io() is deprecated.
protected ?\Drush\Style\DrushStyle $style
entityTypeManager
protected \Drupal\Core\Entity\EntityTypeManagerInterface $entityTypeManager
Methods
__construct
public __construct(\Drupal\Core\Entity\EntityTypeManagerInterface $entityTypeManager): mixed
Parameters:
| Parameter | Type | Description |
|---|---|---|
$entityTypeManager |
\Drupal\Core\Entity\EntityTypeManagerInterface |
io
{@inheritdoc}
protected io(): \Drush\Style\DrushStyle
status
Shows how many items each search page has indexed and has remaining.
public status(?string $pageId = null): \Consolidation\OutputFormatters\StructuredData\RowsOfFields
Parameters:
| Parameter | Type | Description |
|---|---|---|
$pageId |
?string |
index
Indexes search pages, like a cron run does.
public index(?string $pageId = null, array $options = ['all' => false, 'limit' => null]): void
Each call to the plugin's updateIndex() indexes up to search.settings' index.cron_limit items. By default each page gets one call, like cron; --limit keeps calling it, so it's rounded up to whole batches, and --limit=0 calls it until nothing remains. With more than one page, each page is indexed in its own Drush process, so memory is freed between pages and a page that fails doesn't stop the others.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$pageId |
?string | |
$options |
array |
reset
Marks search pages for reindexing, or clears their index.
public reset(?string $pageId = null, array $options = ['all' => false, 'clear' => false]): void
Parameters:
| Parameter | Type | Description |
|---|---|---|
$pageId |
?string | |
$options |
array |
validateSearchPage
Asks which search page to use when none is given.
public validateSearchPage(\Consolidation\AnnotatedCommand\CommandData $commandData): void
With --all, without interaction, or with only one page, every page is used.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$commandData |
\Consolidation\AnnotatedCommand\CommandData |
getSearchPages
Gets indexable search pages.
protected getSearchPages(string|null $pageId): \Drupal\search\SearchPageInterface[]
Parameters:
| Parameter | Type | Description |
|---|---|---|
$pageId |
string|null | |
| A search page ID, or NULL for every enabled, indexable search page. |
Return Value:
The search pages, keyed by ID.
Throws:
When the page doesn't exist, is disabled or isn't indexable.
- RuntimeException
getIndexingPlugin
Gets the indexing plugin of a search page from getSearchPages().
protected getIndexingPlugin(\Drupal\search\SearchPageInterface $page): \Drupal\search\Plugin\SearchIndexingInterface
Parameters:
| Parameter | Type | Description |
|---|---|---|
$page |
\Drupal\search\SearchPageInterface |