Skip to content

Commit

Permalink
EZP-31078: Enhanced Content Type Value Object (#1169)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamwojs authored and lserwatka committed Dec 20, 2019
1 parent d983e84 commit d901535
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,11 @@ private function resolveNewFieldDefinitionIdentifier(
int $startIndex,
string $fieldTypeIdentifier
): string {
$fieldDefinitionIdentifiers = array_map(function (FieldDefinition $fieldDefinition) {
return $fieldDefinition->identifier;
}, $contentTypeDraft->getFieldDefinitions());
$fieldDefinitionIdentifiers = $contentTypeDraft
->getFieldDefinitions()
->map(static function (FieldDefinition $fieldDefinition): string {
return $fieldDefinition->identifier;
});

do {
$fieldDefinitionIdentifier = sprintf('new_%s_%d', $fieldTypeIdentifier, ++$startIndex);
Expand Down
8 changes: 1 addition & 7 deletions src/lib/Specification/ContentType/ContentTypeIsUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,6 @@ public function isSatisfiedBy($contentType): bool
return true;
}

foreach ($contentType->getFieldDefinitions() as $fieldDefinition) {
if ($fieldDefinition->fieldTypeIdentifier === self::EZUSER_FIELD_TYPE_IDENTIFIER) {
return true;
}
}

return false;
return $contentType->hasFieldDefinitionOfType(self::EZUSER_FIELD_TYPE_IDENTIFIER);
}
}
2 changes: 1 addition & 1 deletion src/lib/Util/FieldDefinitionGroupsUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function __construct(FieldsGroupsList $fieldsGroupsListHelper)
*
* @return array
*/
public function groupFieldDefinitions(array $fieldDefinitions): array
public function groupFieldDefinitions(iterable $fieldDefinitions): array
{
$fieldDefinitionsByGroup = [];
foreach ($this->fieldsGroupsListHelper->getGroups() as $groupId => $groupName) {
Expand Down

0 comments on commit d901535

Please sign in to comment.