Skip to content

Commit bba4d2d

Browse files
author
Bertrand Dunogier
committed
Handled spaces in content types groups names (#54)
1 parent fd610e0 commit bba4d2d

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

DomainContent/NameHelper.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@ public function domainContentField(ContentType $contentType)
4747

4848
public function domainGroupName(ContentTypeGroup $contentTypeGroup)
4949
{
50-
return 'DomainGroup' . ucfirst($this->toCamelCase($contentTypeGroup->identifier));
50+
return 'DomainGroup' . ucfirst($this->toCamelCase($this->sanitizeContentTypeGroupIdentifier($contentTypeGroup)));
5151
}
5252

5353
public function domainGroupField(ContentTypeGroup $contentTypeGroup)
5454
{
55-
return lcfirst($this->toCamelCase($contentTypeGroup->identifier));
55+
return lcfirst($this->toCamelCase($this->sanitizeContentTypeGroupIdentifier($contentTypeGroup)));
5656
}
5757

5858
public function fieldDefinitionField(FieldDefinition $fieldDefinition)
@@ -109,4 +109,16 @@ private function pluralize($name)
109109

110110
return $name . 's';
111111
}
112+
113+
/**
114+
* Removes potential spaces in content types groups names.
115+
* (content types groups identifiers are actually their name)
116+
*
117+
* @param ContentTypeGroup $contentTypeGroup
118+
* @return string
119+
*/
120+
protected function sanitizeContentTypeGroupIdentifier(ContentTypeGroup $contentTypeGroup): string
121+
{
122+
return str_replace(' ', '_', $contentTypeGroup->identifier);
123+
}
112124
}

0 commit comments

Comments
 (0)