-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
7 changed files
with
115 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
/** | ||
* @copyright Copyright (C) Ibexa AS. All rights reserved. | ||
* @license For full copyright and license information view LICENSE file distributed with this source code. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Ibexa\Solr\Query\Common\CriterionVisitor; | ||
|
||
use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; | ||
use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Operator; | ||
use Ibexa\Contracts\Solr\Query\CriterionVisitor; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
abstract class BaseIsContainer extends CriterionVisitor | ||
{ | ||
abstract protected function getTargetField(): string; | ||
|
||
public function canVisit(Criterion $criterion): bool | ||
{ | ||
return $criterion instanceof Criterion\IsContainer && $criterion->operator === Operator::EQ; | ||
} | ||
|
||
public function visit(Criterion $criterion, CriterionVisitor $subVisitor = null): string | ||
{ | ||
$value = $criterion->value; | ||
|
||
if (!is_array($value) || !is_bool($value[0])) { | ||
throw new \LogicException(sprintf( | ||
'%s value should be of type array<bool>, received %s.', | ||
Criterion\IsContainer::class, | ||
get_debug_type($value), | ||
)); | ||
} | ||
|
||
return $this->getTargetField() . ':' . $this->toString($value[0]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
/** | ||
* @copyright Copyright (C) Ibexa AS. All rights reserved. | ||
* @license For full copyright and license information view LICENSE file distributed with this source code. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Ibexa\Solr\Query\Content\CriterionVisitor; | ||
|
||
use Ibexa\Solr\Query\Common\CriterionVisitor\BaseIsContainer; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
final class IsContainer extends BaseIsContainer | ||
{ | ||
public function getTargetField(): string | ||
{ | ||
return 'content_type_is_container_b'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
/** | ||
* @copyright Copyright (C) Ibexa AS. All rights reserved. | ||
* @license For full copyright and license information view LICENSE file distributed with this source code. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Ibexa\Solr\Query\Location\CriterionVisitor; | ||
|
||
use Ibexa\Solr\Query\Common\CriterionVisitor\BaseIsContainer; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
final class IsContainer extends BaseIsContainer | ||
{ | ||
public function getTargetField(): string | ||
{ | ||
return 'is_container_b'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters