Skip to content

Commit 106ac89

Browse files
authored
Removed deprecated ContentType::isContainer property (#1472)
1 parent cbd7f43 commit 106ac89

File tree

9 files changed

+17
-19
lines changed

9 files changed

+17
-19
lines changed

phpstan-baseline.neon

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4000,11 +4000,6 @@ parameters:
40004000
count: 1
40014001
path: src/lib/Form/Data/FormMapper/ContentTypeDraftMapper.php
40024002

4003-
-
4004-
message: "#^Access to an undefined property Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\ValueObject\\:\\:\\$isContainer\\.$#"
4005-
count: 1
4006-
path: src/lib/Form/Data/FormMapper/ContentTypeDraftMapper.php
4007-
40084003
-
40094004
message: "#^Access to an undefined property Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\ValueObject\\:\\:\\$mainLanguageCode\\.$#"
40104005
count: 2
@@ -4045,6 +4040,11 @@ parameters:
40454040
count: 1
40464041
path: src/lib/Form/Data/FormMapper/ContentTypeDraftMapper.php
40474042

4043+
-
4044+
message: "#^Call to an undefined method Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\ValueObject\\:\\:isContainer\\(\\)\\.$#"
4045+
count: 1
4046+
path: src/lib/Form/Data/FormMapper/ContentTypeDraftMapper.php
4047+
40484048
-
40494049
message: "#^Method Ibexa\\\\AdminUi\\\\Form\\\\Data\\\\FormMapper\\\\ContentTypeDraftMapper\\:\\:configureOptions\\(\\) has no return type specified\\.$#"
40504050
count: 1

src/bundle/Controller/LocationController.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ public function moveAction(Request $request): Response
144144
$location = $data->getLocation();
145145
$newParentLocation = $data->getNewParentLocation();
146146

147-
if (!$newParentLocation->getContent()->getContentType()->isContainer) {
147+
if (!$newParentLocation->getContent()->getContentType()->isContainer()) {
148148
throw new InvalidArgumentException(
149149
'$newParentLocation',
150150
'Cannot move the Location to a parent that is not a container'
@@ -197,7 +197,7 @@ public function copyAction(Request $request): Response
197197
$location = $data->getLocation();
198198
$newParentLocation = $data->getNewParentLocation();
199199

200-
if (!$newParentLocation->getContent()->getContentType()->isContainer) {
200+
if (!$newParentLocation->getContent()->getContentType()->isContainer()) {
201201
throw new InvalidArgumentException(
202202
'$newParentLocation',
203203
'Cannot copy the Location to a parent that is not a container'
@@ -305,7 +305,7 @@ public function swapAction(Request $request): Response
305305
$childCount = $this->locationService->getLocationChildCount($currentLocation);
306306
$contentType = $newLocation->getContent()->getContentType();
307307

308-
if (!$contentType->isContainer && $childCount) {
308+
if (!$contentType->isContainer() && $childCount) {
309309
throw new \InvalidArgumentException(
310310
'Cannot swap a Location that has sub-items with a Location that is not a container'
311311
);

src/lib/Form/Data/FormMapper/ContentTypeDraftMapper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public function mapToFormData(ValueObject $contentTypeDraft, array $params = [])
7676
$contentTypeData->remoteId = $contentTypeDraft->remoteId;
7777
$contentTypeData->urlAliasSchema = $contentTypeDraft->urlAliasSchema;
7878
$contentTypeData->nameSchema = $contentTypeDraft->nameSchema;
79-
$contentTypeData->isContainer = $contentTypeDraft->isContainer;
79+
$contentTypeData->isContainer = $contentTypeDraft->isContainer();
8080
$contentTypeData->mainLanguageCode = $contentTypeDraft->mainLanguageCode;
8181
$contentTypeData->defaultSortField = $contentTypeDraft->defaultSortField;
8282
$contentTypeData->defaultSortOrder = $contentTypeDraft->defaultSortOrder;

src/lib/Menu/ContentCreateRightSidebarBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public function createStructure(array $options): ItemInterface
104104
$locationCreateStruct = $this->locationService->newLocationCreateStruct($parentLocation->id);
105105

106106
$canPublish = $this->permissionResolver->canUser('content', 'publish', $contentCreateStruct, [$locationCreateStruct]);
107-
$canCreate = $this->permissionResolver->canUser('content', 'create', $contentCreateStruct, [$locationCreateStruct]) && $parentContentType->isContainer;
107+
$canCreate = $this->permissionResolver->canUser('content', 'create', $contentCreateStruct, [$locationCreateStruct]) && $parentContentType->isContainer();
108108
$canPreview = $this->permissionResolver->canUser('content', 'versionread', $contentCreateStruct, [$locationCreateStruct]);
109109

110110
$publishAttributes = [

src/lib/Menu/ContentRightSidebarBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public function createStructure(array $options): ItemInterface
125125
$startingLocationId = $this->udwConfigResolver->getConfig('default')['starting_location_id'];
126126

127127
$lookupLimitationsResult = $this->limitationResolver->getContentCreateLimitations($location);
128-
$canCreate = $lookupLimitationsResult->hasAccess && $contentType->isContainer;
128+
$canCreate = $lookupLimitationsResult->hasAccess && $contentType->isContainer();
129129
$uwdConfig = $this->udwExtension->renderUniversalDiscoveryWidgetConfig('single_container');
130130
$canEdit = $this->permissionResolver->canUser(
131131
'content',

src/lib/Specification/Location/IsContainer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ class IsContainer extends AbstractSpecification
1919
*/
2020
public function isSatisfiedBy($item): bool
2121
{
22-
return $item->getContent()->getContentType()->isContainer;
22+
return $item->getContent()->getContentType()->isContainer();
2323
}
2424
}

src/lib/UI/Config/Provider/ContentTypes.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ private function getContentTypeData(ContentType $contentType, bool $isHidden): a
117117
'id' => $contentType->id,
118118
'identifier' => $contentType->identifier,
119119
'name' => $contentType->getName(),
120-
'isContainer' => $contentType->isContainer,
120+
'isContainer' => $contentType->isContainer(),
121121
'thumbnail' => $this->contentTypeIconResolver->getContentTypeIcon($contentType->identifier),
122122
'href' => $this->urlGenerator->generate('ibexa.rest.load_content_type', [
123123
'contentTypeId' => $contentType->id,

tests/lib/Form/Data/FormMapper/ContentTypeDraftMapperTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ private function createContentType(FieldDefinitionCollectionInterface $fieldDefi
121121

122122
private function createContentTypeDraft(ContentType $contentType): ContentTypeDraft
123123
{
124-
return new ContentTypeDraft(['innerContentType' => $contentType]);
124+
return new ContentTypeDraft(['innerContentType' => $contentType, 'isContainer' => false]);
125125
}
126126

127127
private function createFieldDefinitionCollectionForFieldDefinitionsData(): FieldDefinitionCollectionInterface
@@ -254,7 +254,7 @@ private function createContentTypeData(ContentTypeDraft $contentTypeDraft): Cont
254254
'remoteId' => $contentTypeDraft->remoteId,
255255
'urlAliasSchema' => $contentTypeDraft->urlAliasSchema,
256256
'nameSchema' => $contentTypeDraft->nameSchema,
257-
'isContainer' => $contentTypeDraft->isContainer,
257+
'isContainer' => $contentTypeDraft->isContainer(),
258258
'mainLanguageCode' => $contentTypeDraft->mainLanguageCode,
259259
'defaultSortField' => $contentTypeDraft->defaultSortField,
260260
'defaultSortOrder' => $contentTypeDraft->defaultSortOrder,

tests/lib/Validator/Constraint/LocationIsContainerValidatorTest.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ protected function setUp(): void
5353
public function testValid()
5454
{
5555
$this->contentType
56-
->method('__get')
57-
->with('isContainer')
56+
->method('isContainer')
5857
->willReturn(true);
5958

6059
$this->executionContext
@@ -67,8 +66,7 @@ public function testValid()
6766
public function testInvalid()
6867
{
6968
$this->contentType
70-
->method('__get')
71-
->with('isContainer')
69+
->method('isContainer')
7270
->willReturn(false);
7371

7472
$this->executionContext

0 commit comments

Comments
 (0)