public function ContentTranslationHandler::entityFormEntityBuild in Persian Date for Drupal 8 8.4
Entity builder method.
Parameters
string $entity_type: The type of the entity.
\Drupal\Core\Entity\EntityInterface $entity: The entity whose form is being built.
Overrides ContentTranslationHandler::entityFormEntityBuild
See also
\Drupal\content_translation\ContentTranslationHandler::entityFormAlter()
File
- src/
TranslationHandler/ ContentTranslationHandler.php, line 14
Class
Namespace
Drupal\persian_date\TranslationHandlerCode
public function entityFormEntityBuild($entity_type, EntityInterface $entity, array $form, FormStateInterface $form_state) {
parent::entityFormEntityBuild($entity_type, $entity, $form, $form_state);
if (!PersianLanguageDiscovery::isPersian()) {
return;
}
$values =& $form_state
->getValue('content_translation', []);
$metadata = $this->manager
->getTranslationMetadata($entity);
$created = preg_replace('/ \\+.*?$/', '', $values['created']);
$time = !empty($values['created']) ? PersianDrupalDateTime::createFromFormat('Y-m-d H:i:s', $created, null, [
'validate_format' => false,
])
->getTimestamp() : REQUEST_TIME;
$metadata
->setCreatedTime($time);
}