-
Notifications
You must be signed in to change notification settings - Fork 10
NGSTACK-995 upgrade bundle to ibexa 5 #39
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: master
Are you sure you want to change the base?
Changes from all commits
f99fb0e
a4c5740
92a3b90
7cbbaf0
7b561b3
8fef5a4
63eab05
49fe272
7c30ee5
a0ddb36
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,21 +6,35 @@ | |
|
||
use Doctrine\DBAL\Connection; | ||
use Doctrine\DBAL\Query\QueryBuilder; | ||
use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; | ||
use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface; | ||
use Ibexa\Core\Base\Exceptions\InvalidArgumentException; | ||
use Ibexa\Core\Search\Legacy\Content\Common\Gateway\CriteriaConverter; | ||
use Ibexa\Core\Search\Legacy\Content\Common\Gateway\CriterionHandler\FieldBase; | ||
use Netgen\Bundle\EnhancedSelectionBundle\API\Repository\Values\Content\Query\Criterion\EnhancedSelection as EnhancedSelectionCriterion; | ||
|
||
final class EnhancedSelection extends FieldBase | ||
{ | ||
public function accept(Criterion $criterion): bool | ||
public function accept(CriterionInterface $criterion): bool | ||
{ | ||
return $criterion instanceof EnhancedSelectionCriterion; | ||
} | ||
|
||
public function handle(CriteriaConverter $converter, QueryBuilder $queryBuilder, Criterion $criterion, array $languageSettings): string | ||
{ | ||
/** | ||
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. 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. If you look at the method declaration in the abstract class, it has a PHPDoc which says that it throws an I added the PHPDoc first and foremost to say that the 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. That's fine. As for @throws, we should not specify those if the method does not directly throw. Otherwise, we might put every throw on every method ever :D |
||
* @param CriteriaConverter $converter | ||
* @param QueryBuilder $queryBuilder | ||
* @param EnhancedSelectionCriterion $criterion | ||
* @param array $languageSettings | ||
* | ||
* @return string | ||
* | ||
* @throws InvalidArgumentException | ||
*/ | ||
public function handle( | ||
CriteriaConverter $converter, | ||
QueryBuilder $queryBuilder, | ||
CriterionInterface $criterion, | ||
array $languageSettings, | ||
): string { | ||
$fieldDefinitionIds = $this->getFieldDefinitionIds($criterion->target); | ||
|
||
$subSelect = $this->connection->createQueryBuilder(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
|
||
namespace Netgen\Bundle\EnhancedSelectionBundle\Core\Search\Solr\Query\CriterionVisitor; | ||
|
||
use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; | ||
use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface; | ||
use Ibexa\Contracts\Solr\Query\CriterionVisitor; | ||
use Ibexa\Core\Base\Exceptions\InvalidArgumentException; | ||
use Ibexa\Solr\Query\Common\CriterionVisitor\Field; | ||
|
@@ -14,12 +14,17 @@ | |
|
||
final class EnhancedSelection extends Field | ||
{ | ||
public function canVisit(Criterion $criterion): bool | ||
public function canVisit(CriterionInterface $criterion): bool | ||
{ | ||
return $criterion instanceof EnhancedSelectionCriterion; | ||
} | ||
|
||
public function visit(Criterion $criterion, ?CriterionVisitor $subVisitor = null): string | ||
/** | ||
* @param EnhancedSelectionCriterion $criterion | ||
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. Unneeded @param here. 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. The @param here is needed because it specifies that the |
||
* | ||
* @throws InvalidArgumentException | ||
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. We should use FQCN in PHPDocs. 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. May I ask why? I understand that there might be cases where it would be better (clearer) to use FQCN in PHPDocs, but here both classes are already imported and used elsewhere in this class. 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. Couple of reasons:
|
||
*/ | ||
public function visit(CriterionInterface $criterion, ?CriterionVisitor $subVisitor = null): string | ||
{ | ||
$searchFields = $this->getSearchFields($criterion); | ||
|
||
|
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.
Is this a dynamic property?
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.
In field_types.yaml file, the injected class here is
DoctrineStorage
, which extends an abstract classGateway
. I added the constructor here because of 'potentially polymorphic call` warning.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.
Where did the warning come from? The constructor is already in
Ibexa\Contracts\Core\FieldType\GatewayBasedStorage
abstract class and it doesn't make sense to repeat it here.