CodeExplorer getCmsAwareFields example
return $customEntityXmlSchema;
} private function enrichCmsAware(CustomEntityXmlSchema
$customEntityXmlSchema): CustomEntityXmlSchema
{ foreach ($customEntityXmlSchema->
getEntities()?->
getEntities() ??
[] as $entity) { if ($entity->
isCmsAware() !== true
) { continue;
} $fields =
$entity->
getFields();
$fields =
array_merge($fields, CmsAwareFields::
getCmsAwareFields());
$entity->
setFields($fields);
$flags =
$entity->
getFlags();
$flags =
[...
$flags, ...
['cms-aware' =>
['name' =>
$entity->
getName()]]];
$entity->
setFlags($flags);
} return $customEntityXmlSchema;
} private function enrichAdminUi(CustomEntityXmlSchema
$customEntityXmlSchema, AdminUiXmlSchema
$adminUiXmlSchema): CustomEntityXmlSchema
{ class CmsAwareFieldsTest extends TestCase
{ private const TEST_LOCALE = 'en-GB';
public function testGetCmsAwareFields(): void
{ $actualCmsAwareFields =
array_reduce(CmsAwareFields::
getCmsAwareFields(),
static function D
$accumulator,
$field) { $accumulator[$field->
getName()] =
$field;
return $accumulator;
},
[]);
static::
assertCount(11,
$actualCmsAwareFields);
foreach ($actualCmsAwareFields as $actualCmsAwareField) { $currentField =
$actualCmsAwareField->
toArray(self::TEST_LOCALE
);
static::
assertStringStartsWith('sw_',
$currentField['name'
]);
static::
assertTrue($currentField['storeApiAware'
]);
}