Skip to content
Snippets Groups Projects
Commit f49e5904 authored by chetan's avatar chetan
Browse files

fixed

parent 1d3dc0bd
No related branches found
No related tags found
1 merge request!19fixed
......@@ -65,21 +65,26 @@ class RulesComponent {
*/
public static function createFromConfiguration(array $configuration) {
$configuration += [
'context_definitions' => [],
'provided_context_definitions' => [],
'context_definitions' => [],
'provided_context_definitions' => [],
];
// @todo Can we improve this use dependency injection somehow?
$expression_manager = \Drupal::service('plugin.manager.rules_expression');
$expression = $expression_manager->createInstance($configuration['expression']['id'], $configuration['expression']);
$expression_manager = \Drupal::service('plugin.manager.rules_expression');
// Check if $configuration['expression'] exists and is an array before using it.
$expressionConfig = isset($configuration['expression']) && is_array($configuration['expression']) ? $configuration['expression'] : [];
$expression = $expression_manager->createInstance($expressionConfig['id'], $expressionConfig);
$component = static::create($expression);
foreach ($configuration['context_definitions'] as $name => $definition) {
$component->addContextDefinition($name, ContextDefinition::createFromArray($definition));
$component->addContextDefinition($name, ContextDefinition::createFromArray($definition));
}
foreach ($configuration['provided_context_definitions'] as $name => $definition) {
$component->provideContext($name);
$component->provideContext($name);
}
return $component;
}
}
/**
* Constructs the object.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment