You are here

class LingotekLanguageContentSettingsForm in Lingotek Translation 3.4.x

Same name and namespace in other branches
  1. 8.2 src/Form/LingotekLanguageContentSettingsForm.php \Drupal\lingotek\Form\LingotekLanguageContentSettingsForm
  2. 4.0.x src/Form/LingotekLanguageContentSettingsForm.php \Drupal\lingotek\Form\LingotekLanguageContentSettingsForm
  3. 3.0.x src/Form/LingotekLanguageContentSettingsForm.php \Drupal\lingotek\Form\LingotekLanguageContentSettingsForm
  4. 3.1.x src/Form/LingotekLanguageContentSettingsForm.php \Drupal\lingotek\Form\LingotekLanguageContentSettingsForm
  5. 3.2.x src/Form/LingotekLanguageContentSettingsForm.php \Drupal\lingotek\Form\LingotekLanguageContentSettingsForm
  6. 3.3.x src/Form/LingotekLanguageContentSettingsForm.php \Drupal\lingotek\Form\LingotekLanguageContentSettingsForm
  7. 3.5.x src/Form/LingotekLanguageContentSettingsForm.php \Drupal\lingotek\Form\LingotekLanguageContentSettingsForm
  8. 3.6.x src/Form/LingotekLanguageContentSettingsForm.php \Drupal\lingotek\Form\LingotekLanguageContentSettingsForm
  9. 3.7.x src/Form/LingotekLanguageContentSettingsForm.php \Drupal\lingotek\Form\LingotekLanguageContentSettingsForm
  10. 3.8.x src/Form/LingotekLanguageContentSettingsForm.php \Drupal\lingotek\Form\LingotekLanguageContentSettingsForm

Alters the Drupal language content settings form.

@package Drupal\lingotek\Form

Hierarchy

Expanded class hierarchy of LingotekLanguageContentSettingsForm

1 string reference to 'LingotekLanguageContentSettingsForm'
lingotek.services.yml in ./lingotek.services.yml
lingotek.services.yml
1 service uses LingotekLanguageContentSettingsForm
lingotek.language_content_settings_form in ./lingotek.services.yml
Drupal\lingotek\Form\LingotekLanguageContentSettingsForm

File

src/Form/LingotekLanguageContentSettingsForm.php, line 14

Namespace

Drupal\lingotek\Form
View source
class LingotekLanguageContentSettingsForm {
  use StringTranslationTrait;

  /**
   * The entity type bundle info service.
   *
   * @var \Drupal\Core\Entity\EntityTypeBundleInfoInterface
   */
  protected $entityBundleInfo;

  /**
   * Constructs a new LingotekConfigTranslationService object.
   *
   * @param \Drupal\Core\Entity\EntityTypeBundleInfoInterface $entity_bundle_info
   *   The entity type bundle info service.
   */
  public function __construct(EntityTypeBundleInfoInterface $entity_bundle_info) {
    $this->entityBundleInfo = $entity_bundle_info;
  }

  /**
   * Alters the Drupal language content settings form for removing the lingotek
   * fields that we don't want to be enabled for translation.
   *
   * @param array $form
   *   The form definition array for the language content settings.
   * @param \Drupal\Core\Form\FormStateInterface $form_state
   *   The current state of the form.
   */
  public function form(array &$form, FormStateInterface $form_state) {
    $entity_types = $form['entity_types']['#options'];
    foreach ($entity_types as $entity_type_id => $entity_type) {
      $bundles = $this->entityBundleInfo
        ->getBundleInfo($entity_type_id);
      foreach ($bundles as $bundle => $bundle_info) {
        if (isset($form['settings'][$entity_type_id][$bundle]['fields'])) {
          $bundle_fields = $form['settings'][$entity_type_id][$bundle]['fields'];
          $keys = [
            'lingotek_metadata',
            'lingotek_translation_source',
          ];
          foreach ($keys as $key) {
            if (array_key_exists($key, $bundle_fields)) {
              unset($form['settings'][$entity_type_id][$bundle]['fields'][$key]);
            }
          }
        }
      }
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
LingotekLanguageContentSettingsForm::$entityBundleInfo protected property The entity type bundle info service.
LingotekLanguageContentSettingsForm::form public function Alters the Drupal language content settings form for removing the lingotek fields that we don't want to be enabled for translation.
LingotekLanguageContentSettingsForm::__construct public function Constructs a new LingotekConfigTranslationService object.
StringTranslationTrait::$stringTranslation protected property The string translation service. 4
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.