public function FacetsSummary::getProcessorsByStage in Facets 8
Loads this facets processors for a specific stage.
Parameters
string $stage: The stage for which to return the processors. One of the \Drupal\facets_summary\Processor\ProcessorInterface::STAGE_* constants.
bool $only_enabled: (optional) If FALSE, also include disabled processors. Otherwise, only load enabled ones.
Return value
\Drupal\facets_summary\Processor\ProcessorInterface[] An array of all enabled (or available, if if $only_enabled is FALSE) processors that support the given stage, ordered by the weight for that stage.
Overrides FacetsSummaryInterface::getProcessorsByStage
File
- modules/
facets_summary/ src/ Entity/ FacetsSummary.php, line 232
Class
- FacetsSummary
- Defines the facet summary entity.
Namespace
Drupal\facets_summary\EntityCode
public function getProcessorsByStage($stage, $only_enabled = TRUE) {
$processors = $this
->getProcessors($only_enabled);
$processor_settings = $this
->getProcessorConfigs();
$processor_weights = [];
// Get a list of all processors for given stage.
foreach ($processors as $name => $processor) {
if ($processor
->supportsStage($stage)) {
if (!empty($processor_settings[$name]['weights'][$stage])) {
$processor_weights[$name] = $processor_settings[$name]['weights'][$stage];
}
else {
$processor_weights[$name] = $processor
->getDefaultWeight($stage);
}
}
}
// Sort requested processors by weight.
asort($processor_weights);
$return_processors = [];
foreach ($processor_weights as $name => $weight) {
$return_processors[$name] = $processors[$name];
}
return $return_processors;
}