You are here

class PromotionTranslationHandler in Commerce Core 8.2

Defines the translation handler for promotions.

Hierarchy

Expanded class hierarchy of PromotionTranslationHandler

File

modules/promotion/src/PromotionTranslationHandler.php, line 12

Namespace

Drupal\commerce_promotion
View source
class PromotionTranslationHandler extends ContentTranslationHandler {

  /**
   * {@inheritdoc}
   */
  public function entityFormAlter(array &$form, FormStateInterface $form_state, EntityInterface $entity) {
    parent::entityFormAlter($form, $form_state, $entity);
    if (isset($form['content_translation'])) {
      $form['content_translation']['status']['#access'] = FALSE;
      $form['content_translation']['uid']['#access'] = FALSE;
      $form['content_translation']['created']['#access'] = FALSE;
    }
  }

  /**
   * {@inheritdoc}
   */
  public function entityFormEntityBuild($entity_type, EntityInterface $entity, array $form, FormStateInterface $form_state) {
    if ($form_state
      ->hasValue('content_translation')) {
      $translation =& $form_state
        ->getValue('content_translation');

      /** @var \Drupal\commerce_promotion\Entity\PromotionInterface $entity */
      $translation['status'] = $entity
        ->isEnabled();
      $translation['uid'] = 0;
    }
    parent::entityFormEntityBuild($entity_type, $entity, $form, $form_state);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ContentTranslationHandler::$currentUser protected property The current user.
ContentTranslationHandler::$dateFormatter protected property The date formatter service.
ContentTranslationHandler::$entityType protected property Information about the entity type.
ContentTranslationHandler::$entityTypeId protected property The type of the entity being translated.
ContentTranslationHandler::$entityTypeManager protected property The entity type manager.
ContentTranslationHandler::$fieldStorageDefinitions protected property The array of installed field storage definitions for the entity type, keyed by field name.
ContentTranslationHandler::$languageManager protected property The language manager.
ContentTranslationHandler::$manager protected property The content translation manager.
ContentTranslationHandler::$messenger protected property The messenger service.
ContentTranslationHandler::addTranslatabilityClue protected function Adds a clue about the form element translatability.
ContentTranslationHandler::checkFieldStorageDefinitionTranslatability protected function Checks the field storage definition for translatability support.
ContentTranslationHandler::createInstance public static function Instantiates a new instance of this entity handler. Overrides EntityHandlerInterface::createInstance
ContentTranslationHandler::entityFormDelete public function Form submission handler for ContentTranslationHandler::entityFormAlter().
ContentTranslationHandler::entityFormDeleteTranslation public function Form submission handler for ContentTranslationHandler::entityFormAlter().
ContentTranslationHandler::entityFormSharedElements public function Process callback: determines which elements get clue in the form.
ContentTranslationHandler::entityFormSourceChange public function Form submission handler for ContentTranslationHandler::entityFormAlter().
ContentTranslationHandler::entityFormSubmit public function Form submission handler for ContentTranslationHandler::entityFormAlter().
ContentTranslationHandler::entityFormTitle protected function Returns the title to be used for the entity form page. 3
ContentTranslationHandler::entityFormValidate public function Form validation handler for ContentTranslationHandler::entityFormAlter().
ContentTranslationHandler::getDefaultOwnerId public static function Default value callback for the owner base field definition.
ContentTranslationHandler::getFieldDefinitions public function Returns a set of field definitions to be used to store metadata items. Overrides ContentTranslationHandlerInterface::getFieldDefinitions
ContentTranslationHandler::getSourceLangcode public function Retrieves the source language for the translation being created. Overrides ContentTranslationHandlerInterface::getSourceLangcode
ContentTranslationHandler::getTranslationAccess public function Checks if the user can perform the given operation on translations of the wrapped entity. Overrides ContentTranslationHandlerInterface::getTranslationAccess
ContentTranslationHandler::hasAuthor protected function Checks whether the entity type supports author natively.
ContentTranslationHandler::hasChangedTime protected function Checks whether the entity type supports modification time natively.
ContentTranslationHandler::hasCreatedTime protected function Checks whether the entity type supports creation time natively. 1
ContentTranslationHandler::hasPublishedStatus protected function Checks whether the entity type supports published status natively. 1
ContentTranslationHandler::retranslate public function Marks translations as outdated. Overrides ContentTranslationHandlerInterface::retranslate
ContentTranslationHandler::__construct public function Initializes an instance of the content translation controller.
DependencySerializationTrait::$_entityStorages protected property An array of entity type IDs keyed by the property name of their storages.
DependencySerializationTrait::$_serviceIds protected property An array of service IDs keyed by property name used for serialization.
DependencySerializationTrait::__sleep public function 1
DependencySerializationTrait::__wakeup public function 2
EntityChangesDetectionTrait::getFieldsToSkipFromTranslationChangesCheck protected function Returns an array of field names to skip when checking for changes.
PromotionTranslationHandler::entityFormAlter public function Performs the needed alterations to the entity form. Overrides ContentTranslationHandler::entityFormAlter
PromotionTranslationHandler::entityFormEntityBuild public function Entity builder method. Overrides ContentTranslationHandler::entityFormEntityBuild
StringTranslationTrait::$stringTranslation protected property The string translation service. 1
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.