You are here

function tca_modules_installed in Token Content Access 2.0.x

Same name and namespace in other branches
  1. 8 tca.module \tca_modules_installed()

Implements hook_modules_installed().

File

./tca.module, line 136
Contains tca.module.

Code

function tca_modules_installed($modules) {
  $plugin_manager = \Drupal::service('plugin.manager.tca_plugin');
  $definition_update_manager = \Drupal::entityDefinitionUpdateManager();
  foreach ($modules as $module) {
    $plugin_definitions = $plugin_manager
      ->loadDefinitionsByModuleName($module);
    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) {
          $definition_update_manager
            ->installFieldStorageDefinition($name, $entity_type_id, $provider, $storage_definition);
        }
      }
    }
  }
}