function ContentEntitySourcePluginUi::getTranslatableBundles

A function to get entity translatable bundles.

Note that for comment entity type it will return the same as for node as comment bundles have no use (i.e. in queries).

Parameters

string $entity_type: Drupal entity type.

Return value

array Array of key => values, where key is type and value its label.

3 calls to ContentEntitySourcePluginUi::getTranslatableBundles()
ContentEntitySourcePluginUi::overviewForm in sources/content/src/ContentEntitySourcePluginUi.php
Builds the overview form for the source entities.
ContentEntitySourcePluginUi::overviewFormHeader in sources/content/src/ContentEntitySourcePluginUi.php
Gets overview form header.
ContentEntitySourcePluginUi::overviewSearchFormPart in sources/content/src/ContentEntitySourcePluginUi.php
Builds search form for entity sources overview.

File

sources/content/src/ContentEntitySourcePluginUi.php, line 327

Class

ContentEntitySourcePluginUi
Content entity source plugin UI.

Namespace

Drupal\tmgmt_content

Code

function getTranslatableBundles($entity_type) {

  // If given entity type does not have entity translations enabled, no reason
  // to continue.
  $enabled_types = \Drupal::service('plugin.manager.tmgmt.source')
    ->createInstance('content')
    ->getItemTypes();
  if (!isset($enabled_types[$entity_type])) {
    return array();
  }
  $translatable_bundle_types = array();
  $content_translation_manager = \Drupal::service('content_translation.manager');
  foreach (\Drupal::service('entity_type.bundle.info')
    ->getBundleInfo($entity_type) as $bundle_type => $bundle_definition) {
    if ($content_translation_manager
      ->isEnabled($entity_type, $bundle_type)) {
      $translatable_bundle_types[$bundle_type] = $bundle_definition['label'];
    }
  }
  return $translatable_bundle_types;
}