diff --git a/src/lib/FieldMapper/ContentFieldMapper/BlockDocumentsBaseContentFields.php b/src/lib/FieldMapper/ContentFieldMapper/BlockDocumentsBaseContentFields.php index 14f58606..8ab82f7f 100644 --- a/src/lib/FieldMapper/ContentFieldMapper/BlockDocumentsBaseContentFields.php +++ b/src/lib/FieldMapper/ContentFieldMapper/BlockDocumentsBaseContentFields.php @@ -73,6 +73,7 @@ public function mapFields(Content $content) $ancestorLocationsContentIds[] = $contentInfo->ownerId; $section = $this->sectionHandler->load($contentInfo->sectionId); + $contentType = $this->contentTypeHandler->load($contentInfo->contentTypeId); return [ new Field( @@ -173,9 +174,14 @@ public function mapFields(Content $content) ), new Field( 'content_type_group_ids', - $this->contentTypeHandler->load($contentInfo->contentTypeId)->groupIds, + $contentType->groupIds, new FieldType\MultipleIdentifierField() ), + new Field( + 'content_type_is_container', + $contentType->isContainer, + new FieldType\BooleanField() + ), new Field( 'content_object_state_ids', $this->getObjectStateIds($contentInfo->id), diff --git a/src/lib/FieldMapper/LocationFieldMapper/LocationDocumentBaseFields.php b/src/lib/FieldMapper/LocationFieldMapper/LocationDocumentBaseFields.php index f52fbf06..da8aa62c 100644 --- a/src/lib/FieldMapper/LocationFieldMapper/LocationDocumentBaseFields.php +++ b/src/lib/FieldMapper/LocationFieldMapper/LocationDocumentBaseFields.php @@ -8,6 +8,7 @@ use Ibexa\Contracts\Core\Persistence\Content\Handler as ContentHandler; use Ibexa\Contracts\Core\Persistence\Content\Location; +use Ibexa\Contracts\Core\Persistence\Content\Type\Handler as ContentTypeHandler; use Ibexa\Contracts\Core\Search\Field; use Ibexa\Contracts\Core\Search\FieldType; use Ibexa\Contracts\Solr\DocumentMapper; @@ -23,9 +24,14 @@ class LocationDocumentBaseFields extends LocationFieldMapper */ protected $contentHandler; - public function __construct(ContentHandler $contentHandler) - { + protected ContentTypeHandler $contentTypeHandler; + + public function __construct( + ContentHandler $contentHandler, + ContentTypeHandler $contentTypeHandler + ) { $this->contentHandler = $contentHandler; + $this->contentTypeHandler = $contentTypeHandler; } public function accept(Location $location) @@ -36,6 +42,7 @@ public function accept(Location $location) public function mapFields(Location $location) { $contentInfo = $this->contentHandler->loadContentInfo($location->contentId); + $contentType = $this->contentTypeHandler->load($contentInfo->contentTypeId); return [ new Field( @@ -109,6 +116,11 @@ public function mapFields(Location $location) ($location->id == $contentInfo->mainLocationId), new FieldType\BooleanField() ), + new Field( + 'is_container', + $contentType->isContainer, + new FieldType\BooleanField() + ), ]; } diff --git a/src/lib/Query/Common/CriterionVisitor/BaseIsContainer.php b/src/lib/Query/Common/CriterionVisitor/BaseIsContainer.php new file mode 100644 index 00000000..210033c9 --- /dev/null +++ b/src/lib/Query/Common/CriterionVisitor/BaseIsContainer.php @@ -0,0 +1,41 @@ +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, received %s.', + Criterion\IsContainer::class, + get_debug_type($value), + )); + } + + return $this->getTargetField() . ':' . $this->toString($value[0]); + } +} diff --git a/src/lib/Query/Content/CriterionVisitor/IsContainer.php b/src/lib/Query/Content/CriterionVisitor/IsContainer.php new file mode 100644 index 00000000..d825a61f --- /dev/null +++ b/src/lib/Query/Content/CriterionVisitor/IsContainer.php @@ -0,0 +1,22 @@ +