You are here

public function RuleChainManager::rebuildOptimizedChain in ThemeKey 8

Triggerd by EventSubscriber

Overrides RuleChainManagerInterface::rebuildOptimizedChain

File

src/RuleChainManager.php, line 43
Contains OperatorManager.

Class

RuleChainManager
ThemeKey Rule Chain manager.

Namespace

Drupal\themekey

Code

public function rebuildOptimizedChain() {
  $chain = $this
    ->getChain();

  // Prepare optimized chain.
  $disabledRules = array();
  foreach ($chain as $ruleId => $rule) {
    if (!$rule['enabled'] || in_array($rule['parent'], $disabledRules)) {
      $disabledRules[] = $ruleId;
      unset($chain[$ruleId]);
    }
  }
  \Drupal::state()
    ->set('themekey.optimized_rule_chain', $chain);
}