- }
-
- /**
- * Adds a active theme negotiation service.
- *
- * @param \Drupal\Core\Theme\ThemeNegotiatorInterface $negotiator
- * The theme negotiator to add.
- * @param int $priority
- * Priority of the theme negotiator.
- */
- public function addNegotiator(ThemeNegotiatorInterface $negotiator, $priority) {
- $this->negotiators[$priority][] = $negotiator;
- // Force the negotiators to be re-sorted.
- $this->sortedNegotiators = NULL;
- }
-
- /**
- * Returns the sorted array of theme negotiators.
- *
- * @return array|\Drupal\Core\Theme\ThemeNegotiatorInterface[]
- * An array of theme negotiator objects.
- */
- protected function getSortedNegotiators() {
- if (!isset($this->sortedNegotiators)) {
- // Sort the negotiators according to priority.
- krsort($this->negotiators);
- // Merge nested negotiators from $this->negotiators into
- // $this->sortedNegotiators.
- $this->sortedNegotiators = [];
- foreach ($this->negotiators as $builders) {
- $this->sortedNegotiators = array_merge($this->sortedNegotiators, $builders);
- }
- }
- return $this->sortedNegotiators;