public function DefaultConfigEntityHandler::updateEntityTypeDefinition in CMS Content Sync 2.1.x
Same name and namespace in other branches
- 8 src/Plugin/cms_content_sync/entity_handler/DefaultConfigEntityHandler.php \Drupal\cms_content_sync\Plugin\cms_content_sync\entity_handler\DefaultConfigEntityHandler::updateEntityTypeDefinition()
- 2.0.x src/Plugin/cms_content_sync/entity_handler/DefaultConfigEntityHandler.php \Drupal\cms_content_sync\Plugin\cms_content_sync\entity_handler\DefaultConfigEntityHandler::updateEntityTypeDefinition()
Parameters
\EdgeBox\SyncCore\Interfaces\Configuration\IDefineEntityType $definition:
Overrides EntityHandlerBase::updateEntityTypeDefinition
File
- src/
Plugin/ cms_content_sync/ entity_handler/ DefaultConfigEntityHandler.php, line 39
Class
- DefaultConfigEntityHandler
- Class DefaultConfigEntityHandler, providing a minimalistic implementation for any config entity type.
Namespace
Drupal\cms_content_sync\Plugin\cms_content_sync\entity_handlerCode
public function updateEntityTypeDefinition(&$definition) {
// Add properties that are listed as "config_export" keys from the entity
// type annotation.
$typeMapping = [
'uuid' => 'string',
'boolean' => 'boolean',
'email' => 'string',
'integer' => 'integer',
'float' => 'float',
'string' => 'string',
'text' => 'string',
'label' => 'string',
'uri' => 'string',
'mapping' => 'object',
'sequence' => 'object',
];
foreach ($this
->getConfigProperties() as $key => $config) {
$type = $config['type'];
if (empty($typeMapping[$type])) {
continue;
}
$remoteType = $typeMapping[$type];
$multiple = false;
if ('array' === $remoteType) {
$type = $config['sequence']['type'];
if (empty($typeMapping[$type])) {
continue;
}
$remoteType = $typeMapping[$type];
$multiple = true;
}
if ('string' === $remoteType) {
$definition
->addStringProperty($key, $config['label'], $multiple);
}
elseif ('boolean' === $remoteType) {
$definition
->addBooleanProperty($key, $config['label'], $multiple);
}
elseif ('integer' === $remoteType) {
$definition
->addIntegerProperty($key, $config['label'], $multiple);
}
elseif ('float' === $remoteType) {
$definition
->addFloatProperty($key, $config['label'], $multiple);
}
else {
$definition
->addObjectProperty($key, $config['label'], $multiple);
}
}
}