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

Fix date time range filter data extraction #24

Merged
merged 3 commits into from
Jul 4, 2024
Merged
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
2 changes: 1 addition & 1 deletion Event/Subscriber/AbstractDoctrineSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public function filterDateTimeRange(GetFilterConditionEvent $event)
$values = $event->getValues();
$value = $values['value'];

if (isset($value['left_datetime'][0]) || $value['right_datetime'][0]) {
if (isset($value['left_datetime'][0]) || isset($value['right_datetime'][0])) {
$event->setCondition($expr->datetimeInRange($event->getField(), $value['left_datetime'][0], $value['right_datetime'][0]));
}
}
Expand Down
2 changes: 1 addition & 1 deletion Filter/DataExtractor/FormDataExtractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function addMethod(DataExtractionMethodInterface $method)
public function extractData(FormInterface $form, $methodName)
{
if (!isset($this->methods[$methodName])) {
throw new \RuntimeException(sprintf('Unknown extration method maned "%s".', $methodName));
throw new \RuntimeException(sprintf('Unknown extraction method maned "%s".', $methodName));
}

return $this->methods[$methodName]->extract($form);
Expand Down
3 changes: 0 additions & 3 deletions Filter/DataExtractor/Method/ValueKeysExtractionMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@ public function extract(FormInterface $form)
$values['value'][$key][$k] = $v;
}
}
} else {
dump($keys, $data);
throw new \InvalidArgumentException(sprintf('No value found for key "%s" in form data.', $key));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have removed the exception, I'm not sure about this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, because calling

$this->filterUpdater->addFilterConditions($filter, $filterBuilder);

will throw if we do not provide all the date filters. I think filters are optional and should not throw an exception if one is missing. All the other extraction method have the same behavior and it is not part of the contract either.

}
}

Expand Down
Loading