PromotionTranslationHandler.php in Commerce Core 8.2
File
modules/promotion/src/PromotionTranslationHandler.php
View source
<?php
namespace Drupal\commerce_promotion;
use Drupal\content_translation\ContentTranslationHandler;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Form\FormStateInterface;
class PromotionTranslationHandler extends ContentTranslationHandler {
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;
}
}
public function entityFormEntityBuild($entity_type, EntityInterface $entity, array $form, FormStateInterface $form_state) {
if ($form_state
->hasValue('content_translation')) {
$translation =& $form_state
->getValue('content_translation');
$translation['status'] = $entity
->isEnabled();
$translation['uid'] = 0;
}
parent::entityFormEntityBuild($entity_type, $entity, $form, $form_state);
}
}