You are here

function tca_update_8101 in Token Content Access 2.0.x

Same name and namespace in other branches
  1. 8 tca.install \tca_update_8101()

Add the public field to TCA Settings entity.

File

./tca.install, line 11
Contains tca.install.

Code

function tca_update_8101(&$sandbox) {
  $plugin_manager = \Drupal::service('plugin.manager.tca_plugin');
  $definition_update_manager = \Drupal::entityDefinitionUpdateManager();
  $plugin_definitions = $plugin_manager
    ->getDefinitions();
  foreach ($plugin_definitions as $plugin_definition) {
    $provider = $plugin_definition['provider'];
    $entity_type_id = $plugin_definition['entityType'];
    $plugin = $plugin_manager
      ->createInstanceByEntityType($entity_type_id);
    if ($plugin && $plugin
      ->isFieldable()) {
      $fields = _tca_extra_field_definitions();
      foreach ($fields as $name => $storage_definition) {
        if (in_array($name, [
          'tca_public',
        ])) {
          $definition_update_manager
            ->installFieldStorageDefinition($name, $entity_type_id, $provider, $storage_definition);
        }
      }
    }
  }
}