You are here

class LingotekContentTranslationHandler in Lingotek Translation 3.4.x

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

Hierarchy

Expanded class hierarchy of LingotekContentTranslationHandler

File

src/LingotekContentTranslationHandler.php, line 14

Namespace

Drupal\lingotek
View source
class LingotekContentTranslationHandler implements LingotekContentTranslationHandlerInterface, EntityHandlerInterface {
  use DependencySerializationTrait;

  /**
   * The type of the entity being translated.
   *
   * @var string
   */
  protected $entityTypeId;

  /**
   * Information about the entity type.
   *
   * @var \Drupal\Core\Entity\EntityTypeInterface
   */
  protected $entityType;

  /**
   * The language manager.
   *
   * @var \Drupal\Core\Language\LanguageManagerInterface
   */
  protected $languageManager;

  /**
   * The array of installed field storage definitions for the entity type, keyed
   * by field name.
   *
   * @var \Drupal\Core\Field\FieldStorageDefinitionInterface[]
   */
  protected $fieldStorageDefinitions;

  /**
   * Initializes an instance of the content translation controller.
   *
   * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
   *   The info array of the given entity type.
   * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager
   *   The language manager.
   * @param \Drupal\Core\Entity\EntityLastInstalledSchemaRepositoryInterface $entity_last_installed_schema_repository
   *   The entity last installed schema repository.
   */
  public function __construct(EntityTypeInterface $entity_type, LanguageManagerInterface $language_manager, EntityLastInstalledSchemaRepositoryInterface $entity_last_installed_schema_repository) {
    $this->entityTypeId = $entity_type
      ->id();
    $this->entityType = $entity_type;
    $this->languageManager = $language_manager;
    $this->fieldStorageDefinitions = $entity_last_installed_schema_repository
      ->getLastInstalledFieldStorageDefinitions($this->entityTypeId);
  }

  /**
   * {@inheritdoc}
   */
  public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) {
    return new static($entity_type, $container
      ->get('language_manager'), $container
      ->get('entity.last_installed_schema.repository'));
  }
  public function getFieldDefinitions() {
    $definitions = [];
    $definitions['lingotek_metadata'] = BaseFieldDefinition::create('entity_reference')
      ->setLabel(t('Lingotek metadata'))
      ->setComputed(TRUE)
      ->setClass(LingotekContentMetadataFieldItemList::class)
      ->setDescription(t('The Lingotek profile defining this translation.'))
      ->setSetting('target_type', 'lingotek_content_metadata')
      ->setDisplayConfigurable('form', FALSE)
      ->setDisplayConfigurable('view', FALSE)
      ->setReadOnly(FALSE);
    return $definitions;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DependencySerializationTrait::$_entityStorages protected property
DependencySerializationTrait::$_serviceIds protected property
DependencySerializationTrait::__sleep public function 2
DependencySerializationTrait::__wakeup public function 2
LingotekContentTranslationHandler::$entityType protected property Information about the entity type.
LingotekContentTranslationHandler::$entityTypeId protected property The type of the entity being translated.
LingotekContentTranslationHandler::$fieldStorageDefinitions protected property The array of installed field storage definitions for the entity type, keyed by field name.
LingotekContentTranslationHandler::$languageManager protected property The language manager.
LingotekContentTranslationHandler::createInstance public static function Instantiates a new instance of this entity handler. Overrides EntityHandlerInterface::createInstance
LingotekContentTranslationHandler::getFieldDefinitions public function Overrides LingotekContentTranslationHandlerInterface::getFieldDefinitions
LingotekContentTranslationHandler::__construct public function Initializes an instance of the content translation controller.