-
Notifications
You must be signed in to change notification settings - Fork 16
Made CriteriaConverter capable of using lazy constructors #643
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
base: 4.6
Are you sure you want to change the base?
Changes from all commits
b330f57
bb4e09c
cb7e2fd
a45b16f
a5fb038
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
use Doctrine\DBAL\Query\QueryBuilder; | ||
use Ibexa\Contracts\Core\Repository\Exceptions\NotImplementedException; | ||
use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; | ||
use Traversable; | ||
|
||
/** | ||
* Content locator gateway implementation using the DoctrineDatabase. | ||
|
@@ -20,25 +21,41 @@ class CriteriaConverter | |
* | ||
* @var \Ibexa\Core\Search\Legacy\Content\Common\Gateway\CriterionHandler[] | ||
*/ | ||
protected $handlers; | ||
protected iterable $handlers; | ||
|
||
/** | ||
* Construct from an optional array of Criterion handlers. | ||
* | ||
* @param \Ibexa\Core\Search\Legacy\Content\Common\Gateway\CriterionHandler[] $handlers | ||
*/ | ||
public function __construct(array $handlers = []) | ||
public function __construct(iterable $handlers = []) | ||
{ | ||
$this->handlers = $handlers; | ||
} | ||
|
||
/** | ||
* Adds handler. | ||
* | ||
* @param \Ibexa\Core\Search\Legacy\Content\Common\Gateway\CriterionHandler $handler | ||
* @deprecated The "%s" method is deprecated. Use a service definition tag instead (one of | ||
* "ibexa.search.legacy.gateway.criterion_handler.content", | ||
* "ibexa.search.legacy.gateway.criterion_handler.location", | ||
* "ibexa.search.legacy.trash.gateway.criterion.handler"). | ||
*/ | ||
public function addHandler(CriterionHandler $handler) | ||
{ | ||
trigger_deprecation( | ||
'ibexa/core', | ||
'4.6.24', | ||
'The "%s" method is deprecated. Use a service definition tag instead (one of "%s").', | ||
__METHOD__, | ||
implode('", "', [ | ||
'ibexa.search.legacy.gateway.criterion_handler.content', | ||
'ibexa.search.legacy.gateway.criterion_handler.location', | ||
'ibexa.search.legacy.trash.gateway.criterion.handler', | ||
]), | ||
); | ||
|
||
if ($this->handlers instanceof Traversable) { | ||
$this->handlers = iterator_to_array($this->handlers); | ||
} | ||
Comment on lines
+56
to
+58
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Converting a Traversable to array using Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||
$this->handlers[] = $handler; | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Converting a Traversable to array using
iterator_to_array()
may cause performance issues if the iterator is large or expensive to iterate. Consider checking if this conversion is necessary or if the code can work with the iterator directly.Copilot uses AI. Check for mistakes.