Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #2723259 by yanniboi: Allow data collection input for multiple context fields #450

Open
wants to merge 1 commit into
base: 8.x-3.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/Context/ContextHandlerIntegrityTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,10 @@ protected function checkDataTypeCompatible(CoreContextDefinitionInterface $conte
$target_type = $context_definition->getDataDefinition()->getDataType();

// Special case any and entity target types for now.
if ($target_type == 'any' || ($target_type == 'entity' && strpos($provided->getDataType(), 'entity:') !== FALSE)) {
if ($target_type == 'any' ||
($target_type == 'entity' && strpos($provided->getDataType(), 'entity:') !== FALSE) ||
($target_type == 'list' && $context_definition->isMultiple())
) {
return;
}
if ($target_type != $provided->getDataType()) {
Expand Down
6 changes: 5 additions & 1 deletion src/Core/RulesActionBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,11 @@ public function execute() {
// passing the defined context as arguments.
$args = [];
foreach ($this->getContextDefinitions() as $name => $definition) {
$args[$name] = $this->getContextValue($name);
$value = $this->getContextValue($name);
if ($definition->isMultiple() && !is_array($value)) {
$value = [$value];
}
$args[$name] = $value;
}
call_user_func_array([$this, 'doExecute'], $args);
}
Expand Down
6 changes: 5 additions & 1 deletion src/Core/RulesConditionBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ public function evaluate() {
// passing the defined context as arguments.
$args = [];
foreach ($this->getContextDefinitions() as $name => $definition) {
$args[$name] = $this->getContextValue($name);
$value = $this->getContextValue($name);
if ($definition->isMultiple() && !is_array($value)) {
$value = [$value];
}
$args[$name] = $value;
}
return call_user_func_array([$this, 'doEvaluate'], $args);
}
Expand Down