Skip to content

Comments

feat(translatable): translatable email#122

Open
Artahs wants to merge 12 commits intomainfrom
feature/translatable_email
Open

feat(translatable): translatable email#122
Artahs wants to merge 12 commits intomainfrom
feature/translatable_email

Conversation

@Artahs
Copy link

@Artahs Artahs commented Feb 19, 2026

Add translatable email template with Gedmo Translatable

Comment on lines 297 to 372
public function getLibelleFromLocale(string $locale): string
{
foreach ($this->getTranslations() as $translation) {
if ($translation->getLocale() === $locale && $translation->getField() === 'libelle') {
return $translation->getContent();
}
}

return $this->getLibelle();
}

public function getSubjectFromLocale(string $locale): string
{
foreach ($this->getTranslations() as $translation) {
if ($translation->getLocale() === $locale && $translation->getField() === 'subject') {
return $translation->getContent();
}
}

return $this->getSubject();
}

public function getSenderNameFromLocale(string $locale): ?string
{
foreach ($this->getTranslations() as $translation) {
if ($translation->getLocale() === $locale && $translation->getField() === 'senderName') {
return $translation->getContent();
}
}

return $this->getSenderName();
}

public function getSenderEmailFromLocale(string $locale): string
{
foreach ($this->getTranslations() as $translation) {
if ($translation->getLocale() === $locale && $translation->getField() === 'senderEmail') {
return $translation->getContent();
}
}

return $this->getSenderEmail();
}

public function getTextFromLocale(string $locale): ?string
{
foreach ($this->getTranslations() as $translation) {
if ($translation->getLocale() === $locale && $translation->getField() === 'text') {
return $translation->getContent();
}
}

return $this->getText();
}

public function getHtmlFromLocale(string $locale): ?string
{
foreach ($this->getTranslations() as $translation) {
if ($translation->getLocale() === $locale && $translation->getField() === 'html') {
return $translation->getContent();
}
}

return $this->getHtml();
}

public function getMjmlFromLocale(string $locale): ?string
{
foreach ($this->getTranslations() as $translation) {
if ($translation->getLocale() === $locale && $translation->getField() === 'mjml') {
return $translation->getContent();
}
}

return $this->getMjml();
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests unitaires ?

#[ORM\Column(type: 'text', nullable: true)]
protected ?string $mjml = null;

#[ORM\Column(type: 'text', nullable: false)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

En mettant nullable à false, tu dis au SQL que la colonne ne peut pas être null. Sauf qu'on a potentiellement déjà des mails en base de données.

namespace Lle\HermesBundle\Form;

use Lle\CruditBundle\Form\Type\CKEditorType;
use FOS\CKEditorBundle\Form\Type\CKEditorType;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sûr de ça ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oups... je change

public function prepend(ContainerBuilder $container): void
{
$hasDoctrineTranslatable = false;
$hasStofDoctrine_extensions = false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hasStofDoctrineExtensions

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes my bad

}
}

if (!$hasDoctrineTranslatable) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sûr de toi ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

non en effet

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants