function system_update_11501

Install new design token entity type.

Attributes

#[MarkFutureUpdateEquivalent(12002, '12.0.0')]

File

core/modules/system/system.install, line 188

Code

function system_update_11501() : void {
  $entityDefinitionUpdateManager = \Drupal::entityDefinitionUpdateManager();
  $changeList = $entityDefinitionUpdateManager->getChangeList();
  if (isset($changeList['design_token']['entity_type']) && $changeList['design_token']['entity_type'] == EntityDefinitionUpdateManagerInterface::DEFINITION_CREATED) {
    $designTokenEntityType = new ConfigEntityType([
      'id' => 'design_token',
      'label' => new TranslatableMarkup('Design token'),
      'entity_keys' => [
        'id' => 'id',
        'label' => 'id',
      ],
      'admin_permission' => 'administer design tokens',
      'constraints' => [
        'ImmutableProperties' => [
          'properties' => [
            'id',
            'path',
            'type',
          ],
        ],
      ],
      'config_export' => [
        'id',
        'path',
        'type',
        'scopes',
      ],
    ]);
    $entityDefinitionUpdateManager->installEntityType($designTokenEntityType);
  }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.