diff --git a/composer.json b/composer.json
index aaa0be373d..578f689f02 100644
--- a/composer.json
+++ b/composer.json
@@ -69,7 +69,7 @@
"ibexa/code-style": "^1.0",
"phpunit/phpunit": "^8.2",
"matthiasnoback/symfony-dependency-injection-test": "^4.1",
- "symfony/phpunit-bridge": "^5.1",
+ "symfony/phpunit-bridge": "^5.4",
"symfony/proxy-manager-bridge": "^5.3",
"symfony/runtime": "^5.3.0",
"phpstan/phpstan": "^1.2",
diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon
index 5bf5afb553..e1f9776777 100644
--- a/phpstan-baseline.neon
+++ b/phpstan-baseline.neon
@@ -20230,16 +20230,6 @@ parameters:
count: 1
path: src/lib/Repository/Mapper/ContentDomainMapper.php
- -
- message: "#^Method Ibexa\\\\Core\\\\Repository\\\\Mapper\\\\ContentDomainMapper\\:\\:buildDomainFields\\(\\) has parameter \\$prioritizedLanguages with no value type specified in iterable type array\\.$#"
- count: 1
- path: src/lib/Repository/Mapper/ContentDomainMapper.php
-
- -
- message: "#^Method Ibexa\\\\Core\\\\Repository\\\\Mapper\\\\ContentDomainMapper\\:\\:buildDomainFields\\(\\) return type has no value type specified in iterable type array\\.$#"
- count: 1
- path: src/lib/Repository/Mapper/ContentDomainMapper.php
-
-
message: "#^Method Ibexa\\\\Core\\\\Repository\\\\Mapper\\\\ContentDomainMapper\\:\\:buildLocation\\(\\) has parameter \\$prioritizedLanguages with no value type specified in iterable type array\\.$#"
count: 1
@@ -21440,11 +21430,6 @@ parameters:
count: 1
path: src/lib/Repository/Values/Content/Location.php
- -
- message: "#^Property Ibexa\\\\Core\\\\Repository\\\\Values\\\\Content\\\\Location\\:\\:\\$path type has no value type specified in iterable type array\\.$#"
- count: 1
- path: src/lib/Repository/Values/Content/Location.php
-
-
message: "#^Method Ibexa\\\\Core\\\\Repository\\\\Values\\\\Content\\\\Query\\\\Criterion\\\\PermissionSubtree\\:\\:createFromQueryBuilder\\(\\) has no return type specified\\.$#"
count: 1
@@ -21475,11 +21460,6 @@ parameters:
count: 1
path: src/lib/Repository/Values/Content/TrashItem.php
- -
- message: "#^Property Ibexa\\\\Core\\\\Repository\\\\Values\\\\Content\\\\TrashItem\\:\\:\\$path type has no value type specified in iterable type array\\.$#"
- count: 1
- path: src/lib/Repository/Values/Content/TrashItem.php
-
-
message: "#^Method Ibexa\\\\Core\\\\Repository\\\\Values\\\\ContentType\\\\ContentType\\:\\:__construct\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#"
count: 1
@@ -47765,11 +47745,6 @@ parameters:
count: 1
path: tests/lib/MVC/Symfony/Security/UserTest.php
- -
- message: "#^Method Ibexa\\\\Tests\\\\Core\\\\MVC\\\\Symfony\\\\Security\\\\UserTest\\:\\:testToString\\(\\) has no return type specified\\.$#"
- count: 1
- path: tests/lib/MVC/Symfony/Security/UserTest.php
-
-
message: "#^Method Ibexa\\\\Tests\\\\Core\\\\MVC\\\\Symfony\\\\Security\\\\UserWrappedTest\\:\\:testGetSetAPIUser\\(\\) has no return type specified\\.$#"
count: 1
@@ -48816,7 +48791,7 @@ parameters:
path: tests/lib/MVC/Symfony/Templating/Twig/Extension/FileSystemTwigIntegrationTestCase.php
-
- message: "#^Anonymous function should return string but returns string\\|false\\.$#"
+ message: "#^Anonymous function should return non\\-empty\\-string but returns non\\-empty\\-string\\|false\\.$#"
count: 1
path: tests/lib/MVC/Symfony/Templating/Twig/Extension/RoutingExtensionTest.php
@@ -57985,6 +57960,81 @@ parameters:
count: 1
path: tests/lib/Repository/Service/Mock/BookmarkTest.php
+ -
+ message: "#^Method Ibexa\\\\Tests\\\\Core\\\\Repository\\\\Service\\\\Mock\\\\ContentDomainMapperTest\\:\\:getContentHandlerMock\\(\\) should return Ibexa\\\\Contracts\\\\Core\\\\Persistence\\\\Content\\\\Handler&PHPUnit\\\\Framework\\\\MockObject\\\\MockObject but returns PHPUnit\\\\Framework\\\\MockObject\\\\MockObject\\.$#"
+ count: 1
+ path: tests/lib/Repository/Service/Mock/ContentDomainMapperTest.php
+
+ -
+ message: "#^Method Ibexa\\\\Tests\\\\Core\\\\Repository\\\\Service\\\\Mock\\\\ContentDomainMapperTest\\:\\:getLanguageHandlerMock\\(\\) should return Ibexa\\\\Contracts\\\\Core\\\\Persistence\\\\Content\\\\Language\\\\Handler&PHPUnit\\\\Framework\\\\MockObject\\\\MockObject but returns PHPUnit\\\\Framework\\\\MockObject\\\\MockObject\\.$#"
+ count: 1
+ path: tests/lib/Repository/Service/Mock/ContentDomainMapperTest.php
+
+ -
+ message: "#^Method Ibexa\\\\Tests\\\\Core\\\\Repository\\\\Service\\\\Mock\\\\ContentDomainMapperTest\\:\\:getTypeHandlerMock\\(\\) should return Ibexa\\\\Contracts\\\\Core\\\\Persistence\\\\Content\\\\Type\\\\Handler&PHPUnit\\\\Framework\\\\MockObject\\\\MockObject but returns PHPUnit\\\\Framework\\\\MockObject\\\\MockObject\\.$#"
+ count: 1
+ path: tests/lib/Repository/Service/Mock/ContentDomainMapperTest.php
+
+ -
+ message: "#^Method Ibexa\\\\Tests\\\\Core\\\\Repository\\\\Service\\\\Mock\\\\ContentDomainMapperTest\\:\\:providerForBuildLocationDomainObjectsOnSearchResult\\(\\) has no return type specified\\.$#"
+ count: 1
+ path: tests/lib/Repository/Service/Mock/ContentDomainMapperTest.php
+
+ -
+ message: "#^Method Ibexa\\\\Tests\\\\Core\\\\Repository\\\\Service\\\\Mock\\\\ContentDomainMapperTest\\:\\:providerForBuildVersionInfo\\(\\) has no return type specified\\.$#"
+ count: 1
+ path: tests/lib/Repository/Service/Mock/ContentDomainMapperTest.php
+
+ -
+ message: "#^Method Ibexa\\\\Tests\\\\Core\\\\Repository\\\\Service\\\\Mock\\\\ContentDomainMapperTest\\:\\:testBuildLocationDomainObjectsOnSearchResult\\(\\) has no return type specified\\.$#"
+ count: 1
+ path: tests/lib/Repository/Service/Mock/ContentDomainMapperTest.php
+
+ -
+ message: "#^Method Ibexa\\\\Tests\\\\Core\\\\Repository\\\\Service\\\\Mock\\\\ContentDomainMapperTest\\:\\:testBuildLocationDomainObjectsOnSearchResult\\(\\) has parameter \\$contentIds with no value type specified in iterable type array\\.$#"
+ count: 1
+ path: tests/lib/Repository/Service/Mock/ContentDomainMapperTest.php
+
+ -
+ message: "#^Method Ibexa\\\\Tests\\\\Core\\\\Repository\\\\Service\\\\Mock\\\\ContentDomainMapperTest\\:\\:testBuildLocationDomainObjectsOnSearchResult\\(\\) has parameter \\$contentInfoList with no value type specified in iterable type array\\.$#"
+ count: 1
+ path: tests/lib/Repository/Service/Mock/ContentDomainMapperTest.php
+
+ -
+ message: "#^Method Ibexa\\\\Tests\\\\Core\\\\Repository\\\\Service\\\\Mock\\\\ContentDomainMapperTest\\:\\:testBuildLocationDomainObjectsOnSearchResult\\(\\) has parameter \\$languageFilter with no value type specified in iterable type array\\.$#"
+ count: 1
+ path: tests/lib/Repository/Service/Mock/ContentDomainMapperTest.php
+
+ -
+ message: "#^Method Ibexa\\\\Tests\\\\Core\\\\Repository\\\\Service\\\\Mock\\\\ContentDomainMapperTest\\:\\:testBuildLocationDomainObjectsOnSearchResult\\(\\) has parameter \\$locationHits with no value type specified in iterable type array\\.$#"
+ count: 1
+ path: tests/lib/Repository/Service/Mock/ContentDomainMapperTest.php
+
+ -
+ message: "#^Method Ibexa\\\\Tests\\\\Core\\\\Repository\\\\Service\\\\Mock\\\\ContentDomainMapperTest\\:\\:testBuildLocationWithContentForRootLocation\\(\\) has no return type specified\\.$#"
+ count: 1
+ path: tests/lib/Repository/Service/Mock/ContentDomainMapperTest.php
+
+ -
+ message: "#^Method Ibexa\\\\Tests\\\\Core\\\\Repository\\\\Service\\\\Mock\\\\ContentDomainMapperTest\\:\\:testBuildLocationWithContentIsAlignedWithBuildLocation\\(\\) has no return type specified\\.$#"
+ count: 1
+ path: tests/lib/Repository/Service/Mock/ContentDomainMapperTest.php
+
+ -
+ message: "#^Method Ibexa\\\\Tests\\\\Core\\\\Repository\\\\Service\\\\Mock\\\\ContentDomainMapperTest\\:\\:testBuildLocationWithContentThrowsInvalidArgumentException\\(\\) has no return type specified\\.$#"
+ count: 1
+ path: tests/lib/Repository/Service/Mock/ContentDomainMapperTest.php
+
+ -
+ message: "#^Method Ibexa\\\\Tests\\\\Core\\\\Repository\\\\Service\\\\Mock\\\\ContentDomainMapperTest\\:\\:testBuildVersionInfo\\(\\) has no return type specified\\.$#"
+ count: 1
+ path: tests/lib/Repository/Service/Mock/ContentDomainMapperTest.php
+
+ -
+ message: "#^Parameter \\#2 \\$locationHandler of class Ibexa\\\\Core\\\\Repository\\\\Mapper\\\\ContentDomainMapper constructor expects Ibexa\\\\Contracts\\\\Core\\\\Persistence\\\\Content\\\\Location\\\\Handler, PHPUnit\\\\Framework\\\\MockObject\\\\MockObject given\\.$#"
+ count: 1
+ path: tests/lib/Repository/Service/Mock/ContentDomainMapperTest.php
+
-
message: "#^Access to an undefined property Ibexa\\\\Contracts\\\\Core\\\\FieldType\\\\Value\\:\\:\\$value\\.$#"
count: 1
@@ -58885,81 +58935,6 @@ parameters:
count: 1
path: tests/lib/Repository/Service/Mock/ContentTest.php
- -
- message: "#^Method Ibexa\\\\Tests\\\\Core\\\\Repository\\\\Service\\\\Mock\\\\DomainMapperTest\\:\\:getContentHandlerMock\\(\\) should return Ibexa\\\\Contracts\\\\Core\\\\Persistence\\\\Content\\\\Handler&PHPUnit\\\\Framework\\\\MockObject\\\\MockObject but returns PHPUnit\\\\Framework\\\\MockObject\\\\MockObject\\.$#"
- count: 1
- path: tests/lib/Repository/Service/Mock/DomainMapperTest.php
-
- -
- message: "#^Method Ibexa\\\\Tests\\\\Core\\\\Repository\\\\Service\\\\Mock\\\\DomainMapperTest\\:\\:getLanguageHandlerMock\\(\\) should return Ibexa\\\\Contracts\\\\Core\\\\Persistence\\\\Content\\\\Language\\\\Handler&PHPUnit\\\\Framework\\\\MockObject\\\\MockObject but returns PHPUnit\\\\Framework\\\\MockObject\\\\MockObject\\.$#"
- count: 1
- path: tests/lib/Repository/Service/Mock/DomainMapperTest.php
-
- -
- message: "#^Method Ibexa\\\\Tests\\\\Core\\\\Repository\\\\Service\\\\Mock\\\\DomainMapperTest\\:\\:getTypeHandlerMock\\(\\) should return Ibexa\\\\Contracts\\\\Core\\\\Persistence\\\\Content\\\\Type\\\\Handler&PHPUnit\\\\Framework\\\\MockObject\\\\MockObject but returns PHPUnit\\\\Framework\\\\MockObject\\\\MockObject\\.$#"
- count: 1
- path: tests/lib/Repository/Service/Mock/DomainMapperTest.php
-
- -
- message: "#^Method Ibexa\\\\Tests\\\\Core\\\\Repository\\\\Service\\\\Mock\\\\DomainMapperTest\\:\\:providerForBuildLocationDomainObjectsOnSearchResult\\(\\) has no return type specified\\.$#"
- count: 1
- path: tests/lib/Repository/Service/Mock/DomainMapperTest.php
-
- -
- message: "#^Method Ibexa\\\\Tests\\\\Core\\\\Repository\\\\Service\\\\Mock\\\\DomainMapperTest\\:\\:providerForBuildVersionInfo\\(\\) has no return type specified\\.$#"
- count: 1
- path: tests/lib/Repository/Service/Mock/DomainMapperTest.php
-
- -
- message: "#^Method Ibexa\\\\Tests\\\\Core\\\\Repository\\\\Service\\\\Mock\\\\DomainMapperTest\\:\\:testBuildLocationDomainObjectsOnSearchResult\\(\\) has no return type specified\\.$#"
- count: 1
- path: tests/lib/Repository/Service/Mock/DomainMapperTest.php
-
- -
- message: "#^Method Ibexa\\\\Tests\\\\Core\\\\Repository\\\\Service\\\\Mock\\\\DomainMapperTest\\:\\:testBuildLocationDomainObjectsOnSearchResult\\(\\) has parameter \\$contentIds with no value type specified in iterable type array\\.$#"
- count: 1
- path: tests/lib/Repository/Service/Mock/DomainMapperTest.php
-
- -
- message: "#^Method Ibexa\\\\Tests\\\\Core\\\\Repository\\\\Service\\\\Mock\\\\DomainMapperTest\\:\\:testBuildLocationDomainObjectsOnSearchResult\\(\\) has parameter \\$contentInfoList with no value type specified in iterable type array\\.$#"
- count: 1
- path: tests/lib/Repository/Service/Mock/DomainMapperTest.php
-
- -
- message: "#^Method Ibexa\\\\Tests\\\\Core\\\\Repository\\\\Service\\\\Mock\\\\DomainMapperTest\\:\\:testBuildLocationDomainObjectsOnSearchResult\\(\\) has parameter \\$languageFilter with no value type specified in iterable type array\\.$#"
- count: 1
- path: tests/lib/Repository/Service/Mock/DomainMapperTest.php
-
- -
- message: "#^Method Ibexa\\\\Tests\\\\Core\\\\Repository\\\\Service\\\\Mock\\\\DomainMapperTest\\:\\:testBuildLocationDomainObjectsOnSearchResult\\(\\) has parameter \\$locationHits with no value type specified in iterable type array\\.$#"
- count: 1
- path: tests/lib/Repository/Service/Mock/DomainMapperTest.php
-
- -
- message: "#^Method Ibexa\\\\Tests\\\\Core\\\\Repository\\\\Service\\\\Mock\\\\DomainMapperTest\\:\\:testBuildLocationWithContentForRootLocation\\(\\) has no return type specified\\.$#"
- count: 1
- path: tests/lib/Repository/Service/Mock/DomainMapperTest.php
-
- -
- message: "#^Method Ibexa\\\\Tests\\\\Core\\\\Repository\\\\Service\\\\Mock\\\\DomainMapperTest\\:\\:testBuildLocationWithContentIsAlignedWithBuildLocation\\(\\) has no return type specified\\.$#"
- count: 1
- path: tests/lib/Repository/Service/Mock/DomainMapperTest.php
-
- -
- message: "#^Method Ibexa\\\\Tests\\\\Core\\\\Repository\\\\Service\\\\Mock\\\\DomainMapperTest\\:\\:testBuildLocationWithContentThrowsInvalidArgumentException\\(\\) has no return type specified\\.$#"
- count: 1
- path: tests/lib/Repository/Service/Mock/DomainMapperTest.php
-
- -
- message: "#^Method Ibexa\\\\Tests\\\\Core\\\\Repository\\\\Service\\\\Mock\\\\DomainMapperTest\\:\\:testBuildVersionInfo\\(\\) has no return type specified\\.$#"
- count: 1
- path: tests/lib/Repository/Service/Mock/DomainMapperTest.php
-
- -
- message: "#^Parameter \\#2 \\$locationHandler of class Ibexa\\\\Core\\\\Repository\\\\Mapper\\\\ContentDomainMapper constructor expects Ibexa\\\\Contracts\\\\Core\\\\Persistence\\\\Content\\\\Location\\\\Handler, PHPUnit\\\\Framework\\\\MockObject\\\\MockObject given\\.$#"
- count: 1
- path: tests/lib/Repository/Service/Mock/DomainMapperTest.php
-
-
message: "#^Call to an undefined method Ibexa\\\\Contracts\\\\Core\\\\Persistence\\\\User\\\\Handler\\:\\:expects\\(\\)\\.$#"
count: 11
@@ -61400,31 +61375,6 @@ parameters:
count: 1
path: tests/lib/Repository/Values/Content/LocationTest.php
- -
- message: "#^Method Ibexa\\\\Tests\\\\Core\\\\Repository\\\\Values\\\\Content\\\\LocationTest\\:\\:testIsPropertySet\\(\\) has no return type specified\\.$#"
- count: 1
- path: tests/lib/Repository/Values/Content/LocationTest.php
-
- -
- message: "#^Method Ibexa\\\\Tests\\\\Core\\\\Repository\\\\Values\\\\Content\\\\LocationTest\\:\\:testMissingProperty\\(\\) has no return type specified\\.$#"
- count: 1
- path: tests/lib/Repository/Values/Content/LocationTest.php
-
- -
- message: "#^Method Ibexa\\\\Tests\\\\Core\\\\Repository\\\\Values\\\\Content\\\\LocationTest\\:\\:testNewClass\\(\\) has no return type specified\\.$#"
- count: 1
- path: tests/lib/Repository/Values/Content/LocationTest.php
-
- -
- message: "#^Method Ibexa\\\\Tests\\\\Core\\\\Repository\\\\Values\\\\Content\\\\LocationTest\\:\\:testReadOnlyProperty\\(\\) has no return type specified\\.$#"
- count: 1
- path: tests/lib/Repository/Values/Content/LocationTest.php
-
- -
- message: "#^Method Ibexa\\\\Tests\\\\Core\\\\Repository\\\\Values\\\\Content\\\\LocationTest\\:\\:testUnsetProperty\\(\\) has no return type specified\\.$#"
- count: 1
- path: tests/lib/Repository/Values/Content/LocationTest.php
-
-
message: "#^Method Ibexa\\\\Tests\\\\Core\\\\Repository\\\\Values\\\\Content\\\\Query\\\\Aggregation\\\\RangeTest\\:\\:dataProviderForTestToString\\(\\) return type has no value type specified in iterable type iterable\\.$#"
count: 1
@@ -61505,31 +61455,6 @@ parameters:
count: 1
path: tests/lib/Repository/Values/Content/TrashItemTest.php
- -
- message: "#^Method Ibexa\\\\Tests\\\\Core\\\\Repository\\\\Values\\\\Content\\\\VersionInfoTest\\:\\:createVersionInfoWithStatus\\(\\) has no return type specified\\.$#"
- count: 1
- path: tests/lib/Repository/Values/Content/VersionInfoTest.php
-
- -
- message: "#^Method Ibexa\\\\Tests\\\\Core\\\\Repository\\\\Values\\\\Content\\\\VersionInfoTest\\:\\:createVersionInfoWithStatus\\(\\) has parameter \\$status with no type specified\\.$#"
- count: 1
- path: tests/lib/Repository/Values/Content/VersionInfoTest.php
-
- -
- message: "#^Method Ibexa\\\\Tests\\\\Core\\\\Repository\\\\Values\\\\Content\\\\VersionInfoTest\\:\\:testIsArchived\\(\\) has no return type specified\\.$#"
- count: 1
- path: tests/lib/Repository/Values/Content/VersionInfoTest.php
-
- -
- message: "#^Method Ibexa\\\\Tests\\\\Core\\\\Repository\\\\Values\\\\Content\\\\VersionInfoTest\\:\\:testIsDraft\\(\\) has no return type specified\\.$#"
- count: 1
- path: tests/lib/Repository/Values/Content/VersionInfoTest.php
-
- -
- message: "#^Method Ibexa\\\\Tests\\\\Core\\\\Repository\\\\Values\\\\Content\\\\VersionInfoTest\\:\\:testIsPublished\\(\\) has no return type specified\\.$#"
- count: 1
- path: tests/lib/Repository/Values/Content/VersionInfoTest.php
-
-
message: "#^Method Ibexa\\\\Tests\\\\Core\\\\Repository\\\\Values\\\\ContentType\\\\ContentTypeDraftTest\\:\\:testObjectProperties\\(\\) has no return type specified\\.$#"
count: 1
diff --git a/phpunit-integration-legacy-solr.xml b/phpunit-integration-legacy-solr.xml
index 8c5db18b42..2008a3ff12 100644
--- a/phpunit-integration-legacy-solr.xml
+++ b/phpunit-integration-legacy-solr.xml
@@ -21,6 +21,7 @@
+
diff --git a/phpunit-integration-legacy.xml b/phpunit-integration-legacy.xml
index cb4a636435..5a608b168f 100644
--- a/phpunit-integration-legacy.xml
+++ b/phpunit-integration-legacy.xml
@@ -19,6 +19,7 @@
+
diff --git a/phpunit.xml b/phpunit.xml
index f8d8d30045..b55dae9d52 100644
--- a/phpunit.xml
+++ b/phpunit.xml
@@ -11,7 +11,7 @@
>
-
+
@@ -33,4 +33,7 @@
tests/bundle/LegacySearchEngineBundle
+
+
+
diff --git a/src/contracts/Repository/Values/Content/Content.php b/src/contracts/Repository/Values/Content/Content.php
index 43a33aeebe..d63aaa4cb4 100644
--- a/src/contracts/Repository/Values/Content/Content.php
+++ b/src/contracts/Repository/Values/Content/Content.php
@@ -15,14 +15,24 @@
/**
* this class represents a content object in a specific version.
*
- * @property-read \Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo $contentInfo convenience getter for getVersionInfo()->getContentInfo()
- * @property-read int $id convenience getter for retrieving the contentId: $versionInfo->contentInfo->id
+ * @property-read \Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo $contentInfo @deprecated 4.6.7 accessing magic getter is deprecated and will be removed in 5.0.0. Use {@see Content::getContentInfo()} instead.
+ * @property-read int $id @deprecated 4.6.7 accessing magic getter is deprecated and will be removed in 5.0.0. Use {@see Content::getId()} instead.
* @property-read \Ibexa\Contracts\Core\Repository\Values\Content\VersionInfo $versionInfo calls getVersionInfo()
* @property-read \Ibexa\Contracts\Core\Repository\Values\Content\Field[] $fields access fields, calls getFields()
* @property-read \Ibexa\Contracts\Core\Repository\Values\Content\Thumbnail|null $thumbnail calls getThumbnail()
*/
abstract class Content extends ValueObject
{
+ public function getId(): int
+ {
+ return $this->getContentInfo()->getId();
+ }
+
+ public function getContentInfo(): ContentInfo
+ {
+ return $this->getVersionInfo()->getContentInfo();
+ }
+
/**
* Returns the VersionInfo for this version.
*
diff --git a/src/contracts/Repository/Values/Content/ContentInfo.php b/src/contracts/Repository/Values/Content/ContentInfo.php
index 6a7a4e13c9..8d2c3cce09 100644
--- a/src/contracts/Repository/Values/Content/ContentInfo.php
+++ b/src/contracts/Repository/Values/Content/ContentInfo.php
@@ -15,9 +15,9 @@
/**
* This class provides all version independent information of the Content object.
*
- * @property-read int $id @deprecated Use {@see ContentInfo::getId} instead. The unique id of the Content object
+ * @property-read int $id @deprecated 4.6.7 accessing magic getter is deprecated and will be removed in 5.0.0. Use {@see ContentInfo::getId()} instead.
* @property-read int $contentTypeId The unique id of the content type item the Content object is an instance of
- * @property-read string $name the computed name (via name schema) in the main language of the Content object
+ * @property-read string $name @deprecated 4.6.7 accessing magic getter is deprecated and will be removed in 5.0.0. Use {@see ContentInfo::getName()} instead.
* @property-read int $sectionId @deprecated 4.6.2 Use {@see ContentInfo::getSectionId} instead. The section to which the Content object is assigned
* @property-read int $currentVersionNo Current Version number is the version number of the published version or the version number of a newly created draft (which is 1).
* @property-read bool $published true if there exists a published version false otherwise
@@ -29,7 +29,7 @@
* @property-read string $mainLanguageCode The main language code of the Content object. If the available flag is set to true the Content is shown in this language if the requested language does not exist.
* @property-read int|null $mainLocationId @deprecated Use {@see ContentInfo::getMainLocationId} instead
* @property-read int $status status of the Content object
- * @property-read bool $isHidden status of the Content object
+ * @property-read bool $isHidden @deprecated 4.6.7 accessing magic getter is deprecated and will be removed in 5.0.0. Use {@see ContentInfo::isHidden()} instead.
*/
class ContentInfo extends ValueObject
{
@@ -185,6 +185,11 @@ public function isTrashed(): bool
return $this->status === self::STATUS_TRASHED;
}
+ public function isHidden(): bool
+ {
+ return $this->isHidden;
+ }
+
public function getContentType(): ContentType
{
return $this->contentType;
@@ -229,6 +234,11 @@ public function getId(): int
{
return $this->id;
}
+
+ public function getName(): string
+ {
+ return $this->name;
+ }
}
class_alias(ContentInfo::class, 'eZ\Publish\API\Repository\Values\Content\ContentInfo');
diff --git a/src/contracts/Repository/Values/Content/Location.php b/src/contracts/Repository/Values/Content/Location.php
index 72c5348002..972302e695 100644
--- a/src/contracts/Repository/Values/Content/Location.php
+++ b/src/contracts/Repository/Values/Content/Location.php
@@ -16,17 +16,17 @@
* This class represents a location in the repository.
*
* @property-read \Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo $contentInfo calls getContentInfo()
- * @property-read int $contentId calls getContentInfo()->id
- * @property-read int $id the id of the location
+ * @property-read int $contentId @deprecated 4.6.7 accessing magic getter is deprecated and will be removed in 5.0.0. Use {@see Location::getContentId()} instead.
+ * @property-read int $id @deprecated 4.6.7 accessing magic getter is deprecated and will be removed in 5.0.0. Use {@see Location::getId()} instead.
* @property-read int $priority Position of the Location among its siblings when sorted using priority
- * @property-read bool $hidden Indicates that the Location entity is hidden (explicitly or hidden by content).
- * @property-read bool $invisible Indicates that the Location is not visible, being either marked as hidden itself, or implicitly hidden by its Content or an ancestor Location
+ * @property-read bool $hidden @deprecated 4.6.7 accessing magic getter is deprecated and will be removed in 5.0.0. Use {@see Location::isHidden()} instead.
+ * @property-read bool $invisible @deprecated 4.6.7 accessing magic getter is deprecated and will be removed in 5.0.0. Use {@see Location::isInvisible()} instead.
* @property-read bool $explicitlyHidden Indicates that the Location entity has been explicitly marked as hidden.
* @property-read string $remoteId a global unique id of the content object
* @property-read int $parentLocationId the id of the parent location
- * @property-read string $pathString @deprecated use {@see Location::getPathString()} instead.
- * @property-read array $path Same as $pathString but as array, e.g. [ 1, 2, 4, 23 ]
- * @property-read int $depth Depth location has in the location tree
+ * @property-read string $pathString @deprecated 4.6.7 accessing magic getter is deprecated and will be removed in 5.0.0. Use {@see Location::getPathString()} instead.
+ * @property-read array $path @deprecated 4.6.7 accessing magic getter is deprecated and will be removed in 5.0.0. Use {@see Location::getPath()} instead.
+ * @property-read int $depth @deprecated 4.6.7 accessing magic getter is deprecated and will be removed in 5.0.0. Use {@see Location::getDepth()} instead.
* @property-read int $sortField Specifies which property the child locations should be sorted on. Valid values are found at {@link Location::SORT_FIELD_*}
* @property-read int $sortOrder Specifies whether the sort order should be ascending or descending. Valid values are {@link Location::SORT_ORDER_*}
*/
@@ -158,6 +158,13 @@ abstract class Location extends ValueObject
*/
protected $pathString;
+ /**
+ * Same as {@see Location::$pathString} but as array, e.g.: [ '1', '2', '4', '23' ]
.
+ *
+ * @var string[]
+ */
+ protected array $path;
+
/**
* Depth location has in the location tree.
*
@@ -194,12 +201,22 @@ abstract class Location extends ValueObject
abstract public function getContentInfo(): ContentInfo;
/**
- * Return the parent location of of this location.
+ * Return the parent location of this location.
*
* @return \Ibexa\Contracts\Core\Repository\Values\Content\Location|null
*/
abstract public function getParentLocation(): ?Location;
+ public function getId(): int
+ {
+ return $this->id;
+ }
+
+ public function getContentId(): int
+ {
+ return $this->getContentInfo()->getId();
+ }
+
/**
* Returns true if current location is a draft.
*
@@ -248,6 +265,62 @@ public function getPathString(): string
{
return $this->pathString;
}
+
+ /**
+ * Same as {@see Location::getPathString()} but as array, e.g.: [ '1', '2', '4', '23' ]
.
+ *
+ * @return string[]
+ */
+ public function getPath(): array
+ {
+ if (isset($this->path)) {
+ return $this->path;
+ }
+
+ $pathString = trim($this->pathString ?? '', '/');
+
+ return $this->path = !empty($pathString) ? explode('/', $pathString) : [];
+ }
+
+ /**
+ * Indicates that the Location is not visible, being either marked as hidden itself, or implicitly hidden by
+ * its Content or an ancestor Location.
+ */
+ public function isInvisible(): bool
+ {
+ return $this->invisible;
+ }
+
+ /**
+ * Indicates that the Location is hidden either explicitly or by content.
+ */
+ public function isHidden(): bool
+ {
+ return $this->hidden;
+ }
+
+ public function getDepth(): int
+ {
+ return $this->depth;
+ }
+
+ public function __isset($property)
+ {
+ if ($property === 'path') {
+ return true;
+ }
+
+ return parent::__isset($property);
+ }
+
+ public function __get($property)
+ {
+ if ($property === 'path') {
+ return $this->getPath();
+ }
+
+ return parent::__get($property);
+ }
}
class_alias(Location::class, 'eZ\Publish\API\Repository\Values\Content\Location');
diff --git a/src/contracts/Repository/Values/Content/VersionInfo.php b/src/contracts/Repository/Values/Content/VersionInfo.php
index f416251c89..92bc68a74f 100644
--- a/src/contracts/Repository/Values/Content/VersionInfo.php
+++ b/src/contracts/Repository/Values/Content/VersionInfo.php
@@ -18,7 +18,7 @@
*
* @property-read \Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo $contentInfo calls getContentInfo()
* @property-read mixed $id the internal id of the version
- * @property-read int $versionNo the version number of this version (which only increments in scope of a single Content object)
+ * @property-read int $versionNo @deprecated 4.6.7 accessing magic getter is deprecated and will be removed in 5.0.0. Use {@see VersionInfo::getVersionNo()} instead.
* @property-read \DateTime $modificationDate the last modified date of this version
* @property-read \DateTime $creationDate the creation date of this version
* @property-read mixed $creatorId the user id of the user which created this version
@@ -115,6 +115,11 @@ public function getLanguageCodes(): array
return $this->languageCodes;
}
+ public function getVersionNo(): int
+ {
+ return $this->versionNo;
+ }
+
/**
* Returns true if version is a draft.
*
diff --git a/src/contracts/Repository/Values/ContentType/ContentType.php b/src/contracts/Repository/Values/ContentType/ContentType.php
index 3fdf59c188..b76e351963 100644
--- a/src/contracts/Repository/Values/ContentType/ContentType.php
+++ b/src/contracts/Repository/Values/ContentType/ContentType.php
@@ -19,7 +19,7 @@
* @property-read \Ibexa\Contracts\Core\Repository\Values\ContentType\FieldDefinitionCollection $fieldDefinitions calls getFieldDefinitions() or on access getFieldDefinition($fieldDefIdentifier)
* @property-read mixed $id the id of the content type
* @property-read int $status the status of the content type. One of ContentType::STATUS_DEFINED|ContentType::STATUS_DRAFT|ContentType::STATUS_MODIFIED
- * @property-read string $identifier the identifier of the content type
+ * @property-read string $identifier @deprecated 4.6.7 accessing magic getter is deprecated and will be removed in 5.0.0. Use {@see ContentType::getIdentifier()} instead.
* @property-read \DateTime $creationDate the date of the creation of this content type
* @property-read \DateTime $modificationDate the date of the last modification of this content type
* @property-read mixed $creatorId the user id of the creator of this content type
@@ -176,6 +176,11 @@ abstract public function getContentTypeGroups();
*/
abstract public function getFieldDefinitions(): FieldDefinitionCollection;
+ public function getIdentifier(): string
+ {
+ return $this->identifier;
+ }
+
/**
* This method returns the field definition for the given identifier.
*
diff --git a/src/contracts/Repository/Values/ContentType/FieldDefinition.php b/src/contracts/Repository/Values/ContentType/FieldDefinition.php
index f27f93bb68..ddf0df99a4 100644
--- a/src/contracts/Repository/Values/ContentType/FieldDefinition.php
+++ b/src/contracts/Repository/Values/ContentType/FieldDefinition.php
@@ -15,20 +15,20 @@
/**
* This class represents a field definition.
*
- * @property-read array $fieldSettings calls getFieldSettings()
- * @property-read array $validatorConfiguration calls getValidatorConfiguration()
- * @property-read int $id the id of the field definition
- * @property-read string $identifier the identifier of the field definition
- * @property-read string $fieldGroup the field group name
- * @property-read int $position the position of the field definition in the content type
- * @property-read string $fieldTypeIdentifier String identifier of the field type
- * @property-read bool $isTranslatable indicates if fields of this definition are translatable
- * @property-read bool $isRequired indicates if this field is required in the content object
- * @property-read bool $isSearchable indicates if the field is searchable
- * @property-read bool $isThumbnail indicates if the field can be thumbnail
- * @property-read bool $isInfoCollector indicates if this field is used for information collection
- * @property-read mixed $defaultValue the default value of the field
- * @property-read string $mainLanguageCode main Translation (language code) of a multilingual Field Definition
+ * @property-read array $fieldSettings @deprecated 4.6.7 accessing magic getter is deprecated and will be removed in 5.0.0. Use {@see FieldDefinition::getFieldSettings()} instead.
+ * @property-read array $validatorConfiguration @deprecated 4.6.7 accessing magic getter is deprecated and will be removed in 5.0.0. Use {@see FieldDefinition::getValidatorConfiguration()} instead.
+ * @property-read int $id @deprecated 4.6.7 accessing magic getter is deprecated and will be removed in 5.0.0. Use {@see FieldDefinition::getId()} instead.
+ * @property-read string $identifier @deprecated 4.6.7 accessing magic getter is deprecated and will be removed in 5.0.0. Use {@see FieldDefinition::getIdentifier()} instead.
+ * @property-read string $fieldGroup @deprecated 4.6.7 accessing magic getter is deprecated and will be removed in 5.0.0. Use {@see FieldDefinition::getFieldGroup()} instead.
+ * @property-read int $position @deprecated 4.6.7 accessing magic getter is deprecated and will be removed in 5.0.0. Use {@see FieldDefinition::getPosition()} instead.
+ * @property-read string $fieldTypeIdentifier @deprecated 4.6.7 accessing magic getter is deprecated and will be removed in 5.0.0. Use {@see FieldDefinition::getFieldTypeIdentifier()} instead.
+ * @property-read bool $isTranslatable @deprecated 4.6.7 accessing magic getter is deprecated and will be removed in 5.0.0. Use {@see FieldDefinition::$isTranslatable()} instead.
+ * @property-read bool $isRequired @deprecated 4.6.7 accessing magic getter is deprecated and will be removed in 5.0.0. Use {@see FieldDefinition::$isRequired()} instead.
+ * @property-read bool $isSearchable @deprecated 4.6.7 accessing magic getter is deprecated and will be removed in 5.0.0. Use {@see FieldDefinition::getIdentifier()} instead.
+ * @property-read bool $isThumbnail @deprecated 4.6.7 accessing magic getter is deprecated and will be removed in 5.0.0. Use {@see FieldDefinition::isThumbnail()} instead.
+ * @property-read bool $isInfoCollector @deprecated 4.6.7 accessing magic getter is deprecated and will be removed in 5.0.0. Use {@see FieldDefinition::$isInfoCollector()} instead.
+ * @property-read mixed $defaultValue @deprecated 4.6.7 accessing magic getter is deprecated and will be removed in 5.0.0. Use {@see FieldDefinition::getDefaultValue()} instead.
+ * @property-read string $mainLanguageCode @deprecated 4.6.7 accessing magic getter is deprecated and will be removed in 5.0.0. Use {@see FieldDefinition::getMainLanguageCode()} instead.
*/
abstract class FieldDefinition extends ValueObject implements MultiLanguageName, MultiLanguageDescription
{
@@ -129,6 +129,69 @@ abstract public function getFieldSettings(): array;
* @var string
*/
protected $mainLanguageCode;
+
+ public function getId(): int
+ {
+ return $this->id;
+ }
+
+ public function getFieldGroup(): string
+ {
+ return $this->fieldGroup;
+ }
+
+ public function getPosition(): int
+ {
+ return $this->position;
+ }
+
+ public function isTranslatable(): bool
+ {
+ return $this->isTranslatable;
+ }
+
+ public function isRequired(): bool
+ {
+ return $this->isRequired;
+ }
+
+ public function isInfoCollector(): bool
+ {
+ return $this->isInfoCollector;
+ }
+
+ /**
+ * @return mixed
+ */
+ public function getDefaultValue()
+ {
+ return $this->defaultValue;
+ }
+
+ public function isSearchable(): bool
+ {
+ return $this->isSearchable;
+ }
+
+ public function getMainLanguageCode(): string
+ {
+ return $this->mainLanguageCode;
+ }
+
+ public function isThumbnail(): bool
+ {
+ return $this->isThumbnail;
+ }
+
+ public function getIdentifier(): string
+ {
+ return $this->identifier;
+ }
+
+ public function getFieldTypeIdentifier(): string
+ {
+ return $this->fieldTypeIdentifier;
+ }
}
class_alias(FieldDefinition::class, 'eZ\Publish\API\Repository\Values\ContentType\FieldDefinition');
diff --git a/src/contracts/Repository/Values/User/User.php b/src/contracts/Repository/Values/User/User.php
index cb970e20c0..c3dff9d2f9 100644
--- a/src/contracts/Repository/Values/User/User.php
+++ b/src/contracts/Repository/Values/User/User.php
@@ -11,11 +11,9 @@
use Ibexa\Contracts\Core\Repository\Values\Content\Content;
/**
- * This class represents a user value.
- *
- * @property-read string $login
+ * @property-read string $login @deprecated 4.6.7 accessing magic getter is deprecated and will be removed in 5.0.0. Use {@see User::getLogin()} instead.
* @property-read string $email
- * @property-read string $passwordHash
+ * @property-read string $passwordHash @deprecated 4.6.7 accessing magic getter is deprecated and will be removed in 5.0.0. Use {@see User::getPasswordHash()} instead.
* @property-read string $hashAlgorithm Hash algorithm used to hash the password
* @property-read \DateTimeInterface|null $passwordUpdatedAt
* @property-read bool $enabled User can not login if false
@@ -94,14 +92,20 @@ abstract class User extends Content implements UserReference
*/
protected $maxLogin;
- /**
- * The User id of the User.
- *
- * @return int
- */
public function getUserId(): int
{
- return $this->id;
+ // ATM User Id is the same as Content Id
+ return $this->getId();
+ }
+
+ public function getLogin(): string
+ {
+ return $this->login;
+ }
+
+ public function getPasswordHash(): string
+ {
+ return $this->passwordHash;
}
}
diff --git a/src/lib/MVC/Symfony/Routing/SimplifiedRequest.php b/src/lib/MVC/Symfony/Routing/SimplifiedRequest.php
index fc3ae105e0..602f50bf16 100644
--- a/src/lib/MVC/Symfony/Routing/SimplifiedRequest.php
+++ b/src/lib/MVC/Symfony/Routing/SimplifiedRequest.php
@@ -9,13 +9,13 @@
use Ibexa\Contracts\Core\Repository\Values\ValueObject;
/**
- * @property-read string $scheme The request scheme - http or https
- * @property-read string $host The host name
- * @property-read string $port The port the request is made on
- * @property-read string $pathinfo The path being requested relative to the executed script
- * @property-read array $queryParams Array of parameters extracted from the query string
- * @property-read array $languages List of languages acceptable by the client browser
- * @property-read array $headers Hash of request headers
+ * @property-read string $scheme @deprecated 4.6.7 accessing magic getter is deprecated and will be removed in 5.0.0. Use {@see SimplifiedRequest::getScheme()} instead.
+ * @property-read string $host @deprecated 4.6.7 accessing magic getter is deprecated and will be removed in 5.0.0. Use {@see SimplifiedRequest::getHost()} instead.
+ * @property-read string $port @deprecated 4.6.7 accessing magic getter is deprecated and will be removed in 5.0.0. Use {@see SimplifiedRequest::getPort()} instead.
+ * @property-read string $pathinfo @deprecated 4.6.7 accessing magic getter is deprecated and will be removed in 5.0.0. Use {@see SimplifiedRequest::getPathInfo()} instead.
+ * @property-read array $queryParams @deprecated 4.6.7 accessing magic getter is deprecated and will be removed in 5.0.0. Use {@see SimplifiedRequest::getQueryParams()} instead.
+ * @property-read array $languages @deprecated 4.6.7 accessing magic getter is deprecated and will be removed in 5.0.0. Use {@see SimplifiedRequest::getLanguages()} instead.
+ * @property-read array $headers @deprecated 4.6.7 accessing magic getter is deprecated and will be removed in 5.0.0. Use {@see SimplifiedRequest::getHeaders()} instead.
*/
class SimplifiedRequest extends ValueObject
{
@@ -158,6 +158,64 @@ public function __sleep()
return ['scheme', 'host', 'port', 'pathinfo', 'queryParams', 'languages', 'headers'];
}
+
+ /**
+ * The request scheme - http or https.
+ */
+ public function getScheme(): string
+ {
+ return $this->scheme;
+ }
+
+ public function getHost(): string
+ {
+ return $this->host;
+ }
+
+ public function getPort(): string
+ {
+ return $this->port;
+ }
+
+ /**
+ * The path being requested relative to the executed script.
+ */
+ public function getPathInfo(): string
+ {
+ return $this->pathinfo;
+ }
+
+ /**
+ * @return array
+ */
+ public function getQueryParams(): array
+ {
+ return $this->queryParams;
+ }
+
+ /**
+ * @return string[]
+ */
+ public function getLanguages(): array
+ {
+ return $this->languages;
+ }
+
+ /**
+ * @return array|null
+ */
+ public function getHeader(string $headerName): ?array
+ {
+ return $this->headers[$headerName] ?? null;
+ }
+
+ /**
+ * @return array>
+ */
+ public function getHeaders(): array
+ {
+ return $this->headers;
+ }
}
class_alias(SimplifiedRequest::class, 'eZ\Publish\Core\MVC\Symfony\Routing\SimplifiedRequest');
diff --git a/src/lib/MVC/Symfony/Security/User.php b/src/lib/MVC/Symfony/Security/User.php
index 655ec05d6e..0e2b1d65a2 100644
--- a/src/lib/MVC/Symfony/Security/User.php
+++ b/src/lib/MVC/Symfony/Security/User.php
@@ -57,12 +57,10 @@ public function getRoles()
*
* This should be the encoded password. On authentication, a plain-text
* password will be salted, encoded, and then compared to this value.
- *
- * @return string The password
*/
- public function getPassword()
+ public function getPassword(): string
{
- return $this->getAPIUser()->passwordHash;
+ return $this->getAPIUser()->getPasswordHash();
}
/**
@@ -79,12 +77,10 @@ public function getSalt()
/**
* Returns the username used to authenticate the user.
- *
- * @return string The username
*/
- public function getUsername()
+ public function getUsername(): string
{
- return $this->getAPIUser()->login;
+ return $this->getAPIUser()->getLogin();
}
/**
@@ -142,7 +138,7 @@ public function isEqualTo(BaseUserInterface $user)
public function __toString()
{
- return $this->getAPIUser()->contentInfo->name;
+ return $this->getAPIUser()->getContentInfo()->getName();
}
/**
diff --git a/src/lib/MVC/Symfony/SiteAccess/Router.php b/src/lib/MVC/Symfony/SiteAccess/Router.php
index 1cb57f141e..5445aa47c5 100644
--- a/src/lib/MVC/Symfony/SiteAccess/Router.php
+++ b/src/lib/MVC/Symfony/SiteAccess/Router.php
@@ -130,19 +130,20 @@ public function match(SimplifiedRequest $request)
}
// Request header always have precedence
- // Note: request headers are always in lower cased.
- if (!empty($request->headers['x-siteaccess'])) {
- $siteaccessName = $request->headers['x-siteaccess'][0];
- if (!$this->siteAccessProvider->isDefined($siteaccessName)) {
+ // Note: request headers are always lower case.
+ $xSiteAccess = $request->getHeader('x-siteaccess');
+ if (!empty($xSiteAccess) && is_array($xSiteAccess)) {
+ $siteAccessName = $xSiteAccess[0];
+ if (!$this->siteAccessProvider->isDefined($siteAccessName)) {
throw new InvalidSiteAccessException(
- $siteaccessName,
+ $siteAccessName,
$this->siteAccessProvider,
'X-Siteaccess request header',
$this->debug
);
}
- $this->siteAccess = $this->siteAccessProvider->getSiteAccess($siteaccessName);
+ $this->siteAccess = $this->siteAccessProvider->getSiteAccess($siteAccessName);
$this->siteAccess->matchingType = self::HEADER_SA_MATCHING_TYPE;
return $this->siteAccess;
diff --git a/src/lib/Repository/ContentService.php b/src/lib/Repository/ContentService.php
index 370ae73fe5..25dfd5fd49 100644
--- a/src/lib/Repository/ContentService.php
+++ b/src/lib/Repository/ContentService.php
@@ -253,7 +253,7 @@ public function loadContentInfoByRemoteId(string $remoteId): ContentInfo
*/
public function loadVersionInfo(ContentInfo $contentInfo, ?int $versionNo = null): APIVersionInfo
{
- return $this->loadVersionInfoById($contentInfo->id, $versionNo);
+ return $this->loadVersionInfoById($contentInfo->getId(), $versionNo);
}
/**
@@ -2121,9 +2121,7 @@ public function countReverseRelations(ContentInfo $contentInfo): int
return 0;
}
- return $this->persistenceHandler->contentHandler()->countReverseRelations(
- $contentInfo->id
- );
+ return $this->persistenceHandler->contentHandler()->countReverseRelations($contentInfo->getId());
}
/**
diff --git a/src/lib/Repository/Mapper/ContentDomainMapper.php b/src/lib/Repository/Mapper/ContentDomainMapper.php
index 45cc8cf94b..d2c2024d15 100644
--- a/src/lib/Repository/Mapper/ContentDomainMapper.php
+++ b/src/lib/Repository/Mapper/ContentDomainMapper.php
@@ -220,31 +220,35 @@ public function buildContentProxyList(
*
* @param \Ibexa\Contracts\Core\Persistence\Content\Field[] $spiFields
* @param \Ibexa\Contracts\Core\Repository\Values\ContentType\ContentType|\Ibexa\Contracts\Core\Persistence\Content\Type $contentType
- * @param array $prioritizedLanguages A language priority, filters returned fields and is used as prioritized language code on
+ * @param string[] $prioritizedLanguages A language priority, filters returned fields and is used as prioritized language code on
* returned value object. If not given all languages are returned.
* @param string|null $alwaysAvailableLanguage Language code fallback if a given field is not found in $prioritizedLanguages
*
- * @return array
+ * @return array<\Ibexa\Contracts\Core\Repository\Values\Content\Field>
*/
public function buildDomainFields(
array $spiFields,
$contentType,
array $prioritizedLanguages = [],
string $alwaysAvailableLanguage = null
- ) {
- if (!$contentType instanceof SPIContentType && !$contentType instanceof ContentType) {
+ ): array {
+ if ($contentType instanceof SPIContentType) {
+ $contentType = $this->mapPersistenceContentTypeToApi($contentType, $prioritizedLanguages, __METHOD__);
+ }
+
+ if (!$contentType instanceof ContentType) {
throw new InvalidArgumentType('$contentType', 'SPI ContentType | API ContentType');
}
$fieldDefinitionsMap = [];
- foreach ($contentType->fieldDefinitions as $fieldDefinition) {
- $fieldDefinitionsMap[$fieldDefinition->id] = $fieldDefinition;
+ foreach ($contentType->getFieldDefinitions() as $fieldDefinition) {
+ $fieldDefinitionsMap[$fieldDefinition->getId()] = $fieldDefinition;
}
$fieldInFilterLanguagesMap = [];
if (!empty($prioritizedLanguages) && $alwaysAvailableLanguage !== null) {
foreach ($spiFields as $spiField) {
- if (in_array($spiField->languageCode, $prioritizedLanguages)) {
+ if (in_array($spiField->languageCode, $prioritizedLanguages, true)) {
$fieldInFilterLanguagesMap[$spiField->fieldDefinitionId] = true;
}
}
@@ -259,7 +263,7 @@ public function buildDomainFields(
$fieldDefinition = $fieldDefinitionsMap[$spiField->fieldDefinitionId];
- if (!empty($prioritizedLanguages) && !in_array($spiField->languageCode, $prioritizedLanguages)) {
+ if (!empty($prioritizedLanguages) && !in_array($spiField->languageCode, $prioritizedLanguages, true)) {
// If filtering is enabled we ignore fields in other languages then $prioritizedLanguages, if:
if ($alwaysAvailableLanguage === null) {
// Ignore field if we don't have $alwaysAvailableLanguageCode fallback
@@ -273,13 +277,13 @@ public function buildDomainFields(
}
}
- $fields[$fieldDefinition->position][] = new Field(
+ $fields[$fieldDefinition->getPosition()][] = new Field(
[
'id' => $spiField->id,
'value' => $this->fieldTypeRegistry->getFieldType($spiField->type)
->fromPersistenceValue($spiField->value),
'languageCode' => $spiField->languageCode,
- 'fieldDefIdentifier' => $fieldDefinition->identifier,
+ 'fieldDefIdentifier' => $fieldDefinition->getIdentifier(),
'fieldTypeIdentifier' => $spiField->type,
]
);
@@ -536,12 +540,13 @@ private function buildRootLocation(SPILocation $spiLocation): APILocation
'alwaysAvailable' => 1,
'remoteId' => null,
'mainLanguageCode' => 'eng-GB',
+ 'isHidden' => false,
]);
$content = new Content([
'versionInfo' => new VersionInfo([
'names' => [
- $contentInfo->mainLanguageCode => $contentInfo->name,
+ $contentInfo->getMainLanguageCode() => $contentInfo->getName(),
],
'contentInfo' => $contentInfo,
'versionNo' => $contentInfo->currentVersionNo,
@@ -571,7 +576,7 @@ private function mapLocation(
'contentInfo' => $contentInfo,
'id' => $spiLocation->id,
'priority' => $spiLocation->priority,
- 'hidden' => $spiLocation->hidden || $contentInfo->isHidden,
+ 'hidden' => $spiLocation->hidden || $contentInfo->isHidden(),
'invisible' => $spiLocation->invisible,
'explicitlyHidden' => $spiLocation->hidden,
'remoteId' => $spiLocation->remoteId,
@@ -893,6 +898,34 @@ private function isRootLocation(SPILocation $spiLocation): bool
{
return $spiLocation->id === $spiLocation->parentId;
}
+
+ /**
+ * @param string[] $prioritizedLanguages
+ */
+ private function mapPersistenceContentTypeToApi(
+ SPIContentType $contentType,
+ array $prioritizedLanguages,
+ string $methodName
+ ): ContentType {
+ trigger_deprecation(
+ 'ibexa/core',
+ '4.6',
+ sprintf(
+ 'Passing %s instead of %s as 2nd argument of %s() method is deprecated and will cause a fatal error in 5.0. ' .
+ 'Build %s using %s::buildContentTypeDomainObject prior passing it to the method',
+ SPIContentType::class,
+ ContentType::class,
+ $methodName,
+ ContentType::class,
+ ContentTypeDomainMapper::class
+ )
+ );
+
+ return $this->contentTypeDomainMapper->buildContentTypeDomainObject(
+ $contentType,
+ $prioritizedLanguages
+ );
+ }
}
class_alias(ContentDomainMapper::class, 'eZ\Publish\Core\Repository\Mapper\ContentDomainMapper');
diff --git a/src/lib/Repository/Mapper/ContentLocationMapper/DecoratedLocationService.php b/src/lib/Repository/Mapper/ContentLocationMapper/DecoratedLocationService.php
index ae7bd4be89..2530991b36 100644
--- a/src/lib/Repository/Mapper/ContentLocationMapper/DecoratedLocationService.php
+++ b/src/lib/Repository/Mapper/ContentLocationMapper/DecoratedLocationService.php
@@ -123,8 +123,8 @@ private function setLocationMappings(iterable $locationList): void
{
foreach ($locationList as $location) {
$this->contentLocationMapper->setMapping(
- $location->id,
- $location->contentId
+ $location->getId(),
+ $location->getContentId()
);
}
}
diff --git a/src/lib/Repository/Strategy/ContentThumbnail/FirstMatchingFieldStrategy.php b/src/lib/Repository/Strategy/ContentThumbnail/FirstMatchingFieldStrategy.php
index b1f5b23e9a..07acac5abe 100644
--- a/src/lib/Repository/Strategy/ContentThumbnail/FirstMatchingFieldStrategy.php
+++ b/src/lib/Repository/Strategy/ContentThumbnail/FirstMatchingFieldStrategy.php
@@ -37,18 +37,18 @@ public function getThumbnail(ContentType $contentType, array $fields, ?VersionIn
$fieldDefinitions = $contentType->getFieldDefinitions();
foreach ($fieldDefinitions as $fieldDefinition) {
- $field = $this->getFieldByIdentifier($fieldDefinition->identifier, $fields);
+ $field = $this->getFieldByIdentifier($fieldDefinition->getIdentifier(), $fields);
if ($field === null) {
continue;
}
- $fieldType = $this->fieldTypeService->getFieldType($fieldDefinition->fieldTypeIdentifier);
+ $fieldType = $this->fieldTypeService->getFieldType($fieldDefinition->getFieldTypeIdentifier());
if (
- $fieldDefinition->isThumbnail
- && $this->contentFieldStrategy->hasStrategy($field->fieldTypeIdentifier)
- && !$fieldType->isEmptyValue($field->value)
+ $fieldDefinition->isThumbnail()
+ && $this->contentFieldStrategy->hasStrategy($field->getFieldTypeIdentifier())
+ && !$fieldType->isEmptyValue($field->getValue())
) {
return $this->contentFieldStrategy->getThumbnail($field, $versionInfo);
}
@@ -61,7 +61,7 @@ private function getFieldByIdentifier(string $identifier, array $fields): ?Field
{
/** @var \Ibexa\Contracts\Core\Repository\Values\Content\Field $field */
foreach ($fields as $field) {
- if ($field->fieldDefIdentifier === $identifier) {
+ if ($field->getFieldDefinitionIdentifier() === $identifier) {
return $field;
}
}
diff --git a/src/lib/Repository/UserService.php b/src/lib/Repository/UserService.php
index 75be48b612..b97730535d 100644
--- a/src/lib/Repository/UserService.php
+++ b/src/lib/Repository/UserService.php
@@ -479,12 +479,12 @@ public function loadUser(int $userId, array $prioritizedLanguages = []): APIUser
$content = $this->repository->getContentService()->internalLoadContentById($userId, $prioritizedLanguages);
// Get spiUser value from Field Value
foreach ($content->getFields() as $field) {
- if (!$field->value instanceof UserValue) {
+ $fieldValue = $field->getValue();
+ if (!$fieldValue instanceof UserValue) {
continue;
}
- /** @var \Ibexa\Core\FieldType\User\Value $value */
- $value = $field->value;
+ $value = $fieldValue;
$spiUser = new SPIUser();
$spiUser->id = $value->contentId;
$spiUser->login = $value->login;
diff --git a/src/lib/Repository/Values/Content/Content.php b/src/lib/Repository/Values/Content/Content.php
index a8ba1ed1d0..361ac6bb3c 100644
--- a/src/lib/Repository/Values/Content/Content.php
+++ b/src/lib/Repository/Values/Content/Content.php
@@ -75,9 +75,11 @@ public function __construct(array $data = [])
$this->prioritizedFieldLanguageCode = $data['prioritizedFieldLanguageCode'] ?? null;
foreach ($this->internalFields as $field) {
- $this->fieldDefinitionTranslationMap[$field->fieldDefIdentifier][$field->languageCode] = $field;
+ $languageCode = $field->getLanguageCode();
+ $fieldDefinitionIdentifier = $field->getFieldDefinitionIdentifier();
+ $this->fieldDefinitionTranslationMap[$fieldDefinitionIdentifier][$languageCode] = $field;
// kept for BC due to property-read magic getter
- $this->fields[$field->fieldDefIdentifier][$field->languageCode] = $field->value;
+ $this->fields[$fieldDefinitionIdentifier][$languageCode] = $field->getValue();
}
}
@@ -182,10 +184,10 @@ public function __get($property)
{
switch ($property) {
case 'id':
- return $this->versionInfo->getContentInfo()->id;
+ return $this->getVersionInfo()->getContentInfo()->getId();
case 'contentInfo':
- return $this->versionInfo->getContentInfo();
+ return $this->getVersionInfo()->getContentInfo();
case 'thumbnail':
return $this->getThumbnail();
diff --git a/src/lib/Repository/Values/Content/Location.php b/src/lib/Repository/Values/Content/Location.php
index 5397080aad..4b5caf6b1f 100644
--- a/src/lib/Repository/Values/Content/Location.php
+++ b/src/lib/Repository/Values/Content/Location.php
@@ -25,9 +25,6 @@ class Location extends APILocation
*/
protected $contentInfo;
- /** @var array */
- protected $path;
-
/** @var \Ibexa\Contracts\Core\Repository\Values\Content\Location|null */
protected $parentLocation;
@@ -71,18 +68,8 @@ protected function getProperties($dynamicProperties = ['contentId'])
*/
public function __get($property)
{
- switch ($property) {
- case 'contentId':
- return $this->contentInfo->id;
- case 'path':
- if ($this->path !== null) {
- return $this->path;
- }
- if (isset($this->pathString[1]) && $this->pathString[0] === '/') {
- return $this->path = explode('/', trim($this->pathString, '/'));
- }
-
- return $this->path = [];
+ if ($property === 'contentId') {
+ return $this->getContentInfo()->getId();
}
return parent::__get($property);
@@ -97,7 +84,7 @@ public function __get($property)
*/
public function __isset($property)
{
- if ($property === 'contentId' || $property === 'path') {
+ if ($property === 'contentId') {
return true;
}
diff --git a/src/lib/Repository/Values/Content/TrashItem.php b/src/lib/Repository/Values/Content/TrashItem.php
index e2753954c2..0c0bc1e30e 100644
--- a/src/lib/Repository/Values/Content/TrashItem.php
+++ b/src/lib/Repository/Values/Content/TrashItem.php
@@ -26,9 +26,6 @@ class TrashItem extends APITrashItem
*/
protected $contentInfo;
- /** @var array */
- protected $path;
-
/** @var \Ibexa\Contracts\Core\Repository\Values\Content\Location */
protected $parentLocation;
@@ -83,18 +80,8 @@ protected function getProperties($dynamicProperties = ['contentId', 'path'])
*/
public function __get($property)
{
- switch ($property) {
- case 'contentId':
- return $this->contentInfo->id;
- case 'path':
- if ($this->path !== null) {
- return $this->path;
- }
- if (isset($this->pathString[1]) && $this->pathString[0] === '/') {
- return $this->path = explode('/', trim($this->pathString, '/'));
- }
-
- return $this->path = [];
+ if ($property === 'contentId') {
+ return $this->contentInfo->id;
}
return parent::__get($property);
@@ -109,7 +96,7 @@ public function __get($property)
*/
public function __isset($property)
{
- if ($property === 'contentId' || $property === 'path') {
+ if ($property === 'contentId') {
return true;
}
diff --git a/src/lib/Repository/Values/ContentType/FieldDefinitionCollection.php b/src/lib/Repository/Values/ContentType/FieldDefinitionCollection.php
index 4861c9be98..31a6b7035f 100644
--- a/src/lib/Repository/Values/ContentType/FieldDefinitionCollection.php
+++ b/src/lib/Repository/Values/ContentType/FieldDefinitionCollection.php
@@ -34,7 +34,7 @@ public function __construct(iterable $fieldDefinitions = [])
foreach ($fieldDefinitions as $fieldDefinition) {
$this->fieldDefinitions[] = $fieldDefinition;
- $this->fieldDefinitionsByIdentifier[$fieldDefinition->identifier] = $fieldDefinition;
+ $this->fieldDefinitionsByIdentifier[$fieldDefinition->getIdentifier()] = $fieldDefinition;
}
}
@@ -162,7 +162,7 @@ public function toArray(): array
private function getIsTypePredicate(string $fieldTypeIdentifier): Closure
{
return static function (FieldDefinition $fieldDefinition) use ($fieldTypeIdentifier) {
- return $fieldDefinition->fieldTypeIdentifier === $fieldTypeIdentifier;
+ return $fieldDefinition->getFieldTypeIdentifier() === $fieldTypeIdentifier;
};
}
diff --git a/src/lib/Repository/Values/User/User.php b/src/lib/Repository/Values/User/User.php
index 081b54700b..8f757e0cb7 100644
--- a/src/lib/Repository/Values/User/User.php
+++ b/src/lib/Repository/Values/User/User.php
@@ -130,7 +130,7 @@ public function __get($property)
return $this->getVersionInfo()->getContentInfo();
case 'id':
- return $this->getVersionInfo()->getContentInfo()->id;
+ return $this->getVersionInfo()->getContentInfo()->getId();
case 'versionInfo':
return $this->getVersionInfo();
diff --git a/tests/bundle/Core/EventListener/ContentDownloadRouteReferenceListenerTest.php b/tests/bundle/Core/EventListener/ContentDownloadRouteReferenceListenerTest.php
index 6cc83d5fa6..dbbcf820e7 100644
--- a/tests/bundle/Core/EventListener/ContentDownloadRouteReferenceListenerTest.php
+++ b/tests/bundle/Core/EventListener/ContentDownloadRouteReferenceListenerTest.php
@@ -66,7 +66,7 @@ public function testThrowsExceptionOnBadFieldIdentifier()
'internalFields' => [],
'versionInfo' => new VersionInfo(
[
- 'contentInfo' => new ContentInfo(['mainLanguageCode' => 'eng-GB']),
+ 'contentInfo' => new ContentInfo(['id' => 1, 'mainLanguageCode' => 'eng-GB']),
]
),
]
diff --git a/tests/lib/MVC/Symfony/Routing/SimplifiedRequestTest.php b/tests/lib/MVC/Symfony/Routing/SimplifiedRequestTest.php
index 07d3a6449f..57d06dcab9 100644
--- a/tests/lib/MVC/Symfony/Routing/SimplifiedRequestTest.php
+++ b/tests/lib/MVC/Symfony/Routing/SimplifiedRequestTest.php
@@ -10,7 +10,7 @@
use PHPUnit\Framework\TestCase;
/**
- * @covers \Ibexa\Core\MVC\Symfony\Routing\SimplifiedRequest::fromUrl
+ * @covers \Ibexa\Core\MVC\Symfony\Routing\SimplifiedRequest
*/
class SimplifiedRequestTest extends TestCase
{
@@ -28,6 +28,26 @@ public function testFromUrl($url, $expectedRequest)
);
}
+ public function testStrictGetters(): void
+ {
+ $headers = ['Cookie' => ['abc', 'def']];
+ $languages = ['en', 'pl'];
+ $url = 'https://host.invalid:8080/foo?param=bar¶m2=bar2';
+
+ $request = SimplifiedRequest::fromUrl($url);
+ $request->setHeaders($headers);
+ $request->setLanguages($languages);
+
+ self::assertSame($headers['Cookie'], $request->getHeader('Cookie'));
+ self::assertSame($headers, $request->getHeaders());
+ self::assertSame($languages, $request->getLanguages());
+ self::assertSame('https', $request->getScheme());
+ self::assertSame('host.invalid', $request->getHost());
+ self::assertSame('8080', $request->getPort());
+ self::assertSame('/foo', $request->getPathInfo());
+ self::assertSame(['param' => 'bar', 'param2' => 'bar2'], $request->getQueryParams());
+ }
+
public function fromUrlProvider()
{
return [
diff --git a/tests/lib/MVC/Symfony/Security/UserTest.php b/tests/lib/MVC/Symfony/Security/UserTest.php
index 7f8a25d489..da74c5f5f5 100644
--- a/tests/lib/MVC/Symfony/Security/UserTest.php
+++ b/tests/lib/MVC/Symfony/Security/UserTest.php
@@ -111,22 +111,22 @@ public function testSetAPIUser()
$this->assertSame($apiUserB, $user->getAPIUser());
}
- public function testToString()
+ public function testToString(): void
{
$fullName = 'My full name';
- $userContentInfo = $this
- ->getMockBuilder(ContentInfo::class)
- ->setConstructorArgs([['name' => $fullName]])
- ->getMockForAbstractClass();
+ $userContentInfo = $this->createMock(ContentInfo::class);
+
+ $userContentInfo
+ ->method('getName')
+ ->willReturn($fullName);
+
$apiUser = $this->createMock(APIUser::class);
$apiUser
- ->expects($this->any())
- ->method('__get')
- ->with('contentInfo')
- ->will($this->returnValue($userContentInfo));
+ ->method('getContentInfo')
+ ->willReturn($userContentInfo);
$user = new User($apiUser);
- $this->assertSame($fullName, (string)$user);
+ self::assertSame($fullName, (string)$user);
}
}
diff --git a/tests/lib/MVC/Symfony/View/Builder/ContentViewBuilderTest.php b/tests/lib/MVC/Symfony/View/Builder/ContentViewBuilderTest.php
index 6d0b34572a..f1348661f4 100644
--- a/tests/lib/MVC/Symfony/View/Builder/ContentViewBuilderTest.php
+++ b/tests/lib/MVC/Symfony/View/Builder/ContentViewBuilderTest.php
@@ -151,7 +151,8 @@ public function testBuildViewWithoutContentReadPermission(): void
'invisible' => false,
'content' => new Content([
'versionInfo' => new VersionInfo([
- 'contentInfo' => new ContentInfo(),
+ 'id' => 2,
+ 'contentInfo' => new ContentInfo(['id' => 1]),
]),
]),
]
diff --git a/tests/lib/Repository/Service/Mock/DomainMapperTest.php b/tests/lib/Repository/Service/Mock/ContentDomainMapperTest.php
similarity index 84%
rename from tests/lib/Repository/Service/Mock/DomainMapperTest.php
rename to tests/lib/Repository/Service/Mock/ContentDomainMapperTest.php
index c30c109a72..525f740ea3 100644
--- a/tests/lib/Repository/Service/Mock/DomainMapperTest.php
+++ b/tests/lib/Repository/Service/Mock/ContentDomainMapperTest.php
@@ -8,7 +8,9 @@
use DateTime;
use Ibexa\Contracts\Core\Persistence\Content\ContentInfo as SPIContentInfo;
+use Ibexa\Contracts\Core\Persistence\Content\Field as PersistenceContentField;
use Ibexa\Contracts\Core\Persistence\Content\Location;
+use Ibexa\Contracts\Core\Persistence\Content\Type as PersistenceContentType;
use Ibexa\Contracts\Core\Persistence\Content\VersionInfo as SPIVersionInfo;
use Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException;
use Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo;
@@ -16,18 +18,23 @@
use Ibexa\Contracts\Core\Repository\Values\Content\Search\SearchHit;
use Ibexa\Contracts\Core\Repository\Values\Content\Search\SearchResult;
use Ibexa\Contracts\Core\Repository\Values\Content\VersionInfo as APIVersionInfo;
+use Ibexa\Contracts\Core\Repository\Values\ContentType\ContentType;
use Ibexa\Core\Repository\Mapper\ContentDomainMapper;
use Ibexa\Core\Repository\ProxyFactory\ProxyDomainMapperInterface;
use Ibexa\Core\Repository\Values\Content\Content;
use Ibexa\Core\Repository\Values\Content\VersionInfo;
+use Ibexa\Core\Repository\Values\ContentType\FieldDefinitionCollection;
use Ibexa\Tests\Core\Repository\Service\Mock\Base as BaseServiceMockTest;
use Psr\Log\LoggerInterface;
+use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
/**
* @covers \Ibexa\Core\Repository\Mapper\ContentDomainMapper
*/
-class DomainMapperTest extends BaseServiceMockTest
+final class ContentDomainMapperTest extends BaseServiceMockTest
{
+ use ExpectDeprecationTrait;
+
private const EXAMPLE_CONTENT_TYPE_ID = 1;
private const EXAMPLE_SECTION_ID = 1;
private const EXAMPLE_MAIN_LOCATION_ID = 1;
@@ -112,6 +119,34 @@ public function testBuildLocationWithContentIsAlignedWithBuildLocation()
);
}
+ /**
+ * @throws \Ibexa\Contracts\Core\Repository\Exceptions\Exception
+ *
+ * @group legacy
+ */
+ public function testBuildDomainFieldsDeprecatedBehavior(): void
+ {
+ $persistenceFields = [new PersistenceContentField()];
+ $persistenceContentType = $this->createMock(PersistenceContentType::class);
+ $apiContentTypeMock = $this->createMock(ContentType::class);
+ $apiContentTypeMock->method('getFieldDefinitions')->willReturn(new FieldDefinitionCollection());
+ $this
+ ->getContentTypeDomainMapperMock()
+ ->method('buildContentTypeDomainObject')
+ ->with($persistenceContentType, [])->willReturn($apiContentTypeMock)
+ ;
+
+ $this->expectDeprecation(
+ 'Since ibexa/core 4.6: Passing Ibexa\Contracts\Core\Persistence\Content\Type instead of ' .
+ 'Ibexa\Contracts\Core\Repository\Values\ContentType\ContentType as 2nd argument of ' .
+ 'Ibexa\Core\Repository\Mapper\ContentDomainMapper::buildDomainFields() method is deprecated and will cause ' .
+ 'a fatal error in 5.0. Build Ibexa\Contracts\Core\Repository\Values\ContentType\ContentType using ' .
+ 'Ibexa\Core\Repository\Mapper\ContentTypeDomainMapper::buildContentTypeDomainObject prior passing it to the method'
+ );
+
+ $this->getContentDomainMapper()->buildDomainFields($persistenceFields, $persistenceContentType);
+ }
+
public function providerForBuildVersionInfo()
{
$properties = [
@@ -240,7 +275,10 @@ public function testBuildLocationDomainObjectsOnSearchResult(
}
$spiResult = clone $result;
- $missingLocations = $this->getContentDomainMapper()->buildLocationDomainObjectsOnSearchResult($result, $languageFilter);
+ $missingLocations = $this->getContentDomainMapper()->buildLocationDomainObjectsOnSearchResult(
+ $result,
+ $languageFilter
+ );
$this->assertIsArray($missingLocations);
if (!$missing) {
@@ -309,4 +347,4 @@ protected function getLoggerMock(): LoggerInterface
}
}
-class_alias(DomainMapperTest::class, 'eZ\Publish\Core\Repository\Tests\Service\Mock\DomainMapperTest');
+class_alias(ContentDomainMapperTest::class, 'eZ\Publish\Core\Repository\Tests\Service\Mock\DomainMapperTest');
diff --git a/tests/lib/Repository/Values/Content/ContentInfoTest.php b/tests/lib/Repository/Values/Content/ContentInfoTest.php
index 18fecfb249..9f02ad8c10 100644
--- a/tests/lib/Repository/Values/Content/ContentInfoTest.php
+++ b/tests/lib/Repository/Values/Content/ContentInfoTest.php
@@ -4,6 +4,8 @@
* @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\Tests\Core\Repository\Values\Content;
use DateTimeImmutable;
@@ -13,7 +15,7 @@
/**
* @covers \Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo
*/
-class ContentInfoTest extends TestCase
+final class ContentInfoTest extends TestCase
{
public function testCreateObject(): void
{
@@ -33,13 +35,14 @@ public function testCreateObject(): void
'remoteId' => '1qaz2wsx',
'mainLanguageCode' => 'eng-GB',
'mainLocationId' => 2,
+ 'isHidden' => true,
]
);
$dateFormatted = $dateTime->format('c');
self::assertSame(1, $contentInfo->getId());
self::assertSame(2, $contentInfo->contentTypeId);
- self::assertSame('foo', $contentInfo->name);
+ self::assertSame('foo', $contentInfo->getName());
self::assertSame(1, $contentInfo->getSectionId());
self::assertSame(1, $contentInfo->currentVersionNo);
self::assertTrue($contentInfo->isPublished());
@@ -50,6 +53,7 @@ public function testCreateObject(): void
self::assertSame('1qaz2wsx', $contentInfo->remoteId);
self::assertSame('eng-GB', $contentInfo->getMainLanguageCode());
self::assertSame(2, $contentInfo->getMainLocationId());
+ self::assertTrue($contentInfo->isHidden());
}
}
diff --git a/tests/lib/Repository/Values/Content/ContentTest.php b/tests/lib/Repository/Values/Content/ContentTest.php
index 70cf04b3eb..fc0f284fbb 100644
--- a/tests/lib/Repository/Values/Content/ContentTest.php
+++ b/tests/lib/Repository/Values/Content/ContentTest.php
@@ -8,10 +8,11 @@
namespace Ibexa\Tests\Core\Repository\Values\Content;
+use Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo;
use Ibexa\Contracts\Core\Repository\Values\Content\Field;
-use Ibexa\Contracts\Core\Repository\Values\Content\VersionInfo;
use Ibexa\Core\FieldType\TextLine\Value as TextLineValue;
use Ibexa\Core\Repository\Values\Content\Content;
+use Ibexa\Core\Repository\Values\Content\VersionInfo;
use PHPUnit\Framework\TestCase;
/**
@@ -112,6 +113,22 @@ public function testObjectProperties(): void
}
}
+ public function testStrictGetters(): void
+ {
+ $contentInfo = new ContentInfo(['id' => 123]);
+ $content = new Content(
+ [
+ 'versionInfo' => new VersionInfo(
+ [
+ 'contentInfo' => $contentInfo,
+ ]
+ ),
+ ]
+ );
+ self::assertEquals(123, $content->getId());
+ self::assertEquals($contentInfo, $content->getContentInfo());
+ }
+
public function testGetName(): void
{
$name = 'Translated name';
diff --git a/tests/lib/Repository/Values/Content/LocationTest.php b/tests/lib/Repository/Values/Content/LocationTest.php
index 5634a8578e..082d8a796b 100644
--- a/tests/lib/Repository/Values/Content/LocationTest.php
+++ b/tests/lib/Repository/Values/Content/LocationTest.php
@@ -4,10 +4,13 @@
* @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\Tests\Core\Repository\Values\Content;
use Ibexa\Contracts\Core\Repository\Exceptions\PropertyNotFoundException;
use Ibexa\Contracts\Core\Repository\Exceptions\PropertyReadOnlyException;
+use Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo;
use Ibexa\Core\Repository\Values\Content\Location;
use Ibexa\Tests\Core\Repository\Values\ValueObjectTestTrait;
use PHPUnit\Framework\TestCase;
@@ -15,14 +18,14 @@
/**
* @covers \Ibexa\Core\Repository\Values\Content\Location
*/
-class LocationTest extends TestCase
+final class LocationTest extends TestCase
{
use ValueObjectTestTrait;
/**
* Test a new class and default values on properties.
*/
- public function testNewClass()
+ public function testNewClass(): void
{
$location = new Location();
@@ -45,10 +48,75 @@ public function testNewClass()
);
}
+ public function testStrictGetters(): void
+ {
+ $location = new Location(
+ [
+ 'id' => 123,
+ 'contentInfo' => new ContentInfo(['id' => 456]),
+ 'hidden' => true,
+ 'depth' => 3,
+ 'pathString' => '/1/2/123/',
+ ]
+ );
+
+ self::assertSame(123, $location->getId());
+ self::assertSame(456, $location->getContentId());
+ self::assertTrue($location->isHidden());
+ self::assertSame(3, $location->getDepth());
+ self::assertSame('/1/2/123/', $location->getPathString());
+ }
+
+ /**
+ * @return iterable
+ */
+ public static function getDataForTestPathComputedPropertyGetter(): iterable
+ {
+ yield 'nested path' => [
+ new Location(['id' => 3, 'pathString' => '/1/2/3/']),
+ ['1', '2', '3'],
+ ];
+
+ yield 'nested path no trailing slash' => [
+ new Location(['id' => 4, 'pathString' => '/1/2/4']),
+ ['1', '2', '4'],
+ ];
+
+ yield 'root element' => [
+ new Location(['id' => 1, 'pathString' => '/1/']),
+ ['1'],
+ ];
+
+ yield 'malformed path' => [
+ new Location(['id' => 1, 'pathString' => '/']),
+ [],
+ ];
+
+ yield 'empty path' => [
+ new Location(['id' => 1, 'pathString' => '']),
+ [],
+ ];
+
+ yield 'null path' => [
+ new Location(['id' => 1, 'pathString' => null]),
+ [],
+ ];
+ }
+
+ /**
+ * @dataProvider getDataForTestPathComputedPropertyGetter
+ *
+ * @param string[] $expectedPathValue
+ */
+ public function testPathComputedPropertyGetter(Location $location, array $expectedPathValue): void
+ {
+ self::assertSame($expectedPathValue, $location->getPath());
+ }
+
/**
* Test retrieving missing property.
*/
- public function testMissingProperty()
+ public function testMissingProperty(): void
{
$this->expectException(PropertyNotFoundException::class);
@@ -62,7 +130,7 @@ public function testMissingProperty()
*
* @covers \Ibexa\Core\Repository\Values\Content\Location::__set
*/
- public function testReadOnlyProperty()
+ public function testReadOnlyProperty(): void
{
$this->expectException(PropertyReadOnlyException::class);
@@ -74,7 +142,7 @@ public function testReadOnlyProperty()
/**
* Test if property exists.
*/
- public function testIsPropertySet()
+ public function testIsPropertySet(): void
{
$location = new Location();
$value = isset($location->notDefined);
@@ -89,7 +157,7 @@ public function testIsPropertySet()
*
* @covers \Ibexa\Core\Repository\Values\Content\Location::__unset
*/
- public function testUnsetProperty()
+ public function testUnsetProperty(): void
{
$this->expectException(PropertyReadOnlyException::class);
diff --git a/tests/lib/Repository/Values/Content/VersionInfoTest.php b/tests/lib/Repository/Values/Content/VersionInfoTest.php
index aca3d13e9c..e190798d15 100644
--- a/tests/lib/Repository/Values/Content/VersionInfoTest.php
+++ b/tests/lib/Repository/Values/Content/VersionInfoTest.php
@@ -4,14 +4,19 @@
* @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\Tests\Core\Repository\Values\Content;
use Ibexa\Core\Repository\Values\Content\VersionInfo;
use PHPUnit\Framework\TestCase;
-class VersionInfoTest extends TestCase
+/**
+ * @covers \Ibexa\Core\Repository\Values\Content\VersionInfo
+ */
+final class VersionInfoTest extends TestCase
{
- public function testIsDraft()
+ public function testIsDraft(): void
{
$versionInfo = $this->createVersionInfoWithStatus(VersionInfo::STATUS_DRAFT);
self::assertTrue($versionInfo->isDraft());
@@ -22,7 +27,7 @@ public function testIsDraft()
self::assertFalse($versionInfo->isDraft());
}
- public function testIsPublished()
+ public function testIsPublished(): void
{
$versionInfo = $this->createVersionInfoWithStatus(VersionInfo::STATUS_PUBLISHED);
self::assertTrue($versionInfo->isPublished());
@@ -33,7 +38,7 @@ public function testIsPublished()
self::assertFalse($versionInfo->isPublished());
}
- public function testIsArchived()
+ public function testIsArchived(): void
{
$versionInfo = $this->createVersionInfoWithStatus(VersionInfo::STATUS_ARCHIVED);
self::assertTrue($versionInfo->isArchived());
@@ -44,9 +49,16 @@ public function testIsArchived()
self::assertFalse($versionInfo->isArchived());
}
- private function createVersionInfoWithStatus($status)
+ public function testStrictGetters(): void
+ {
+ $versionInfo = $this->createVersionInfoWithStatus(VersionInfo::STATUS_PUBLISHED);
+ self::assertSame(123, $versionInfo->getVersionNo());
+ }
+
+ private function createVersionInfoWithStatus(int $status): VersionInfo
{
return new VersionInfo([
+ 'versionNo' => 123,
'status' => $status,
]);
}
diff --git a/tests/lib/Repository/Values/ContentType/ContentTypeTest.php b/tests/lib/Repository/Values/ContentType/ContentTypeTest.php
index a1b8a7ac6f..9de1080898 100644
--- a/tests/lib/Repository/Values/ContentType/ContentTypeTest.php
+++ b/tests/lib/Repository/Values/ContentType/ContentTypeTest.php
@@ -16,7 +16,7 @@
/**
* @covers \Ibexa\Core\Repository\Values\ContentType\ContentType
*/
-class ContentTypeTest extends TestCase
+final class ContentTypeTest extends TestCase
{
private const EXAMPLE_FIELD_DEFINITION_IDENTIFIER = 'example';
private const EXAMPLE_FIELD_TYPE_IDENTIFIER = 'ezcustom';
@@ -61,6 +61,14 @@ public function testObjectProperties(): void
}
}
+ public function testStrictGetters(): void
+ {
+ $identifier = 'foo_content_type';
+ $contentType = new ContentType(['identifier' => $identifier]);
+
+ self::assertSame($identifier, $contentType->getIdentifier());
+ }
+
public function testGetFieldDefinition(): void
{
$fieldDefinition = $this->createMock(FieldDefinition::class);
diff --git a/tests/lib/Repository/Values/ContentType/FieldDefinitionCollectionTest.php b/tests/lib/Repository/Values/ContentType/FieldDefinitionCollectionTest.php
index eb883b32a4..d1e847f100 100644
--- a/tests/lib/Repository/Values/ContentType/FieldDefinitionCollectionTest.php
+++ b/tests/lib/Repository/Values/ContentType/FieldDefinitionCollectionTest.php
@@ -282,19 +282,35 @@ public function testToArray(): void
private function createFieldDefinitions(string ...$identifiers): array
{
- return $this->createFieldDefinitionsWith('identifier', $identifiers);
+ return array_map(
+ fn (string $identifier): APIFieldDefinition => $this->createFieldDefinition($identifier),
+ $identifiers
+ );
}
private function createFieldDefinitionsWith(string $property, array $values): array
{
- return array_map(function (string $identifier) use ($property): APIFieldDefinition {
- return $this->createFieldDefinition($identifier, $property);
- }, $values);
+ return array_map(
+ fn (string $value): APIFieldDefinition => $this->createFieldDefinition(
+ uniqid('field_def_identifier', true),
+ $property,
+ $value
+ ),
+ $values
+ );
}
- private function createFieldDefinition(string $identifier, string $property = 'identifier'): APIFieldDefinition
- {
- return new FieldDefinition([$property => $identifier]);
+ private function createFieldDefinition(
+ string $identifier,
+ ?string $property = null,
+ ?string $value = null
+ ): APIFieldDefinition {
+ $properties = ['identifier' => $identifier];
+ if (null !== $property) {
+ $properties[$property] = $value;
+ }
+
+ return new FieldDefinition($properties);
}
/**
diff --git a/tests/lib/Repository/Values/ContentType/FieldDefinitionTest.php b/tests/lib/Repository/Values/ContentType/FieldDefinitionTest.php
new file mode 100644
index 0000000000..6634f3bdfa
--- /dev/null
+++ b/tests/lib/Repository/Values/ContentType/FieldDefinitionTest.php
@@ -0,0 +1,53 @@
+createMock(BaseFieldValue::class);
+ $fieldDefinition = new FieldDefinition(
+ [
+ 'id' => 123,
+ 'identifier' => 'my_field_definition',
+ 'fieldTypeIdentifier' => 'ibexa_field_type',
+ 'fieldGroup' => 'content',
+ 'position' => 1,
+ 'isTranslatable' => true,
+ 'isRequired' => true,
+ 'isInfoCollector' => false,
+ 'defaultValue' => $defaultValueMock,
+ 'isSearchable' => true,
+ 'mainLanguageCode' => 'eng-GB',
+ 'isThumbnail' => true,
+ ]
+ );
+
+ self::assertSame(123, $fieldDefinition->getId());
+ self::assertSame('my_field_definition', $fieldDefinition->getIdentifier());
+ self::assertSame('ibexa_field_type', $fieldDefinition->getFieldTypeIdentifier());
+ self::assertSame('content', $fieldDefinition->getFieldGroup());
+ self::assertSame(1, $fieldDefinition->getPosition());
+ self::assertTrue($fieldDefinition->isTranslatable());
+ self::assertTrue($fieldDefinition->isRequired());
+ self::assertFalse($fieldDefinition->isInfoCollector());
+ self::assertSame($defaultValueMock, $fieldDefinition->getDefaultValue());
+ self::assertTrue($fieldDefinition->isSearchable());
+ self::assertSame('eng-GB', $fieldDefinition->getMainLanguageCode());
+ self::assertTrue($fieldDefinition->isThumbnail());
+ }
+}