You are here

protected function Engine::walkRuleChildren in ThemeKey 8

1 call to Engine::walkRuleChildren()
Engine::determineTheme in src/Engine/Engine.php
Determine the active theme for the request.

File

src/Engine/Engine.php, line 71

Class

Engine

Namespace

Drupal\themekey\Engine

Code

protected function walkRuleChildren($chain, $theme = NULL, $parent = 0) {
  $has_children = FALSE;
  foreach ($chain as $ruleId => $ruleMetaData) {
    if ($ruleMetaData['parent'] == $parent) {
      $has_children = TRUE;
      $rule = ThemeKeyRule::load($ruleId);
      if ($this
        ->matchCondition($rule)) {
        $theme = $this
          ->walkRuleChildren($chain, $rule
          ->theme(), $ruleId);
        if ($theme) {
          return $theme;
        }
      }
    }
  }

  // No children: return theme of parent.
  // Has children: all children did not match => return no theme.
  return $has_children ? NULL : $theme;
}