/**
  * Returns an array of content translation permissions.
  *
  * @return array
  */
 public function contentPermissions()
 {
     $permission = [];
     // Create a translate permission for each enabled entity type and (optionally)
     // bundle.
     foreach ($this->entityManager->getDefinitions() as $entity_type_id => $entity_type) {
         if ($permission_granularity = $entity_type->getPermissionGranularity()) {
             $t_args = ['@entity_label' => $entity_type->getLowercaseLabel()];
             switch ($permission_granularity) {
                 case 'bundle':
                     foreach ($this->entityManager->getBundleInfo($entity_type_id) as $bundle => $bundle_info) {
                         if (content_translation_enabled($entity_type_id, $bundle)) {
                             $t_args['%bundle_label'] = isset($bundle_info['label']) ? $bundle_info['label'] : $bundle;
                             $permission["translate {$bundle} {$entity_type_id}"] = ['title' => $this->t('Translate %bundle_label @entity_label', $t_args)];
                         }
                     }
                     break;
                 case 'entity_type':
                     if (content_translation_enabled($entity_type_id)) {
                         $permission["translate {$entity_type_id}"] = ['title' => $this->t('Translate @entity_label', $t_args)];
                     }
                     break;
             }
         }
     }
     return $permission;
 }
 /**
  * Asserts that translatability has the expected value for the given bundle.
  *
  * @param string $entity_type
  *   The entity type for which to check translatibility.
  * @param string $bundle
  *   The bundle for which to check translatibility.
  * @param boolean $enabled
  *   TRUE if translatibility should be enabled, FALSE otherwise.
  * @param array $edit
  *   An array of values to submit to the content translation settings page.
  *
  * @return boolean
  *   TRUE if the assertion succeeded, FALSE otherwise.
  */
 protected function assertSettings($entity_type, $bundle, $enabled, $edit)
 {
     $this->drupalPostForm('admin/config/regional/content-language', $edit, t('Save'));
     $args = array('@entity_type' => $entity_type, '@bundle' => $bundle, '@enabled' => $enabled ? 'enabled' : 'disabled');
     $message = format_string('Translation for entity @entity_type (@bundle) is @enabled.', $args);
     \Drupal::entityManager()->clearCachedDefinitions();
     return $this->assertEqual(content_translation_enabled($entity_type, $bundle), $enabled, $message);
 }