Skip to content

Commit

Permalink
Pull upstream into master
Browse files Browse the repository at this point in the history
  • Loading branch information
PBXg33k committed Jul 14, 2016
2 parents c665820 + cfc0c05 commit 57535a3
Show file tree
Hide file tree
Showing 20 changed files with 272 additions and 38 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
phpunit.xml
.directory
.project
.idea
.buildpath
.settings
vendor
Expand Down
3 changes: 2 additions & 1 deletion Admin/EmailAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Knp\Menu\ItemInterface as MenuItemInterface;
use Lexik\Bundle\MailerBundle\Entity\Email;
use Lexik\Bundle\MailerBundle\Entity\EmailTranslation;
use Lexik\Bundle\MailerBundle\Form\Type\HeaderType;
use Sonata\AdminBundle\Admin\Admin;
use Sonata\AdminBundle\Admin\AdminInterface;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
Expand Down Expand Up @@ -87,7 +88,7 @@ protected function configureFormFields(FormMapper $formMapper)
'headers',
'sonata_type_native_collection',
array(
'type' => 'lexik_mailer_header',
'type' => HeaderType::class,
'allow_add' => true,
'allow_delete' => true,
)
Expand Down
4 changes: 2 additions & 2 deletions Entity/EmailTranslation.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ class EmailTranslation
/**
* @var string
*
* @ORM\Column(type="string", length=2)
* @ORM\Column(type="string", length=5)
* @Assert\NotBlank()
* @Assert\Length(max=2)
* @Assert\Length(max=5)
*/
protected $lang;

Expand Down
4 changes: 2 additions & 2 deletions Entity/LayoutTranslation.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ class LayoutTranslation
/**
* @var string
*
* @ORM\Column(type="string", length=2)
* @ORM\Column(type="string", length=5)
* @Assert\NotBlank()
* @Assert\Length(max=2)
* @Assert\Length(max=5)
*/
protected $lang;

Expand Down
5 changes: 2 additions & 3 deletions Form/Handler/EmailFormHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
namespace Lexik\Bundle\MailerBundle\Form\Handler;

use Doctrine\ORM\EntityManager;

use Lexik\Bundle\MailerBundle\Entity\Email;
use Lexik\Bundle\MailerBundle\Entity\EmailTranslation;
use Lexik\Bundle\MailerBundle\Form\Model\EntityTranslationModel;

use Lexik\Bundle\MailerBundle\Form\Type\EmailType;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpFoundation\Request;
Expand Down Expand Up @@ -75,7 +74,7 @@ public function createForm($email = null, $lang = null)

$model = new EntityTranslationModel($email, $translation);

return $this->factory->create('mailer_email', $model, array(
return $this->factory->create(EmailType::class, $model, array(
'data_translation' => $translation,
'edit' => $edit,
));
Expand Down
5 changes: 2 additions & 3 deletions Form/Handler/LayoutFormHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
namespace Lexik\Bundle\MailerBundle\Form\Handler;

use Doctrine\ORM\EntityManager;

use Lexik\Bundle\MailerBundle\Entity\Layout;
use Lexik\Bundle\MailerBundle\Entity\LayoutTranslation;
use Lexik\Bundle\MailerBundle\Form\Model\EntityTranslationModel;

use Lexik\Bundle\MailerBundle\Form\Type\LayoutType;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpFoundation\Request;
Expand Down Expand Up @@ -75,7 +74,7 @@ public function createForm($layout = null, $lang = null)

$model = new EntityTranslationModel($layout, $translation);

return $this->factory->create('mailer_layout', $model, array(
return $this->factory->create(LayoutType::class, $model, array(
'data_translation' => $translation,
'edit' => $edit,
));
Expand Down
12 changes: 7 additions & 5 deletions Form/Type/EmailTranslationType.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
namespace Lexik\Bundle\MailerBundle\Form\Type;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\LanguageType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

Expand All @@ -18,7 +20,7 @@ class EmailTranslationType extends AbstractType
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('subject', 'text', array(
->add('subject', TextType::class, array(
'label' => 'lexik_mailer.translations.subject',
))
->add('body', null, array(
Expand All @@ -29,16 +31,16 @@ public function buildForm(FormBuilderInterface $builder, array $options)
'attr' => array('rows' => 20),
'label' => 'lexik_mailer.translations.body_text',
))
->add('fromAddress', 'text', array(
->add('fromAddress', TextType::class, array(
'label' => 'lexik_mailer.translations.from_address',
))
->add('fromName', 'text', array(
->add('fromName', TextType::class, array(
'label' => 'lexik_mailer.translations.from_name',
))
;

if ($options['with_language']) {
$builder->add('lang', 'language', array(
$builder->add('lang', LanguageType::class, array(
'preferred_choices' => $options['preferred_languages'],
'label' => 'lexik_mailer.translations.language',
));
Expand All @@ -61,7 +63,7 @@ public function configureOptions(OptionsResolver $resolver)
/**
* {@inheritdoc}
*/
public function getName()
public function getBlockPrefix()
{
return 'mailer_email_translation';
}
Expand Down
22 changes: 13 additions & 9 deletions Form/Type/EmailType.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@

namespace Lexik\Bundle\MailerBundle\Form\Type;

use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

Expand All @@ -23,41 +28,40 @@ public function buildForm(FormBuilderInterface $builder, array $options)
'property_path' => 'entity.reference',
'label' => 'lexik_mailer.email.reference',
))
->add('layout', 'entity', array(
->add('layout', EntityType::class, array(
'required' => false,
'empty_value' => '',
'class' => $options['layout_entity'],
'property_path' => 'entity.layout',
'label' => 'lexik_mailer.email.layout',
))
->add('headers', 'collection', array(
'type' => 'lexik_mailer_header',
->add('headers', CollectionType::class, array(
'type' => HeaderType::class,
'allow_add' => true,
'allow_delete' => true,
'property_path' => 'entity.headers',
'label' => 'lexik_mailer.email.headers',
))
->add('description', 'textarea', array(
->add('description', TextareaType::class, array(
'property_path' => 'entity.description',
'required' => false,
'label' => 'lexik_mailer.email.description',
))
->add('bcc', 'text', array(
->add('bcc', TextType::class, array(
'property_path' => 'entity.bcc',
'required' => false,
'label' => 'lexik_mailer.email.bcc',
))
->add('spool', 'checkbox', array(
'required' => false,
->add('spool', CheckboxType::class, array(
'property_path' => 'entity.spool',
'label' => 'lexik_mailer.email.spool',
))
->add('useFallbackLocale', 'checkbox', array(
'required' => false,
'property_path' => 'entity.useFallbackLocale',
'label' => 'lexik_mailer.email.use_fallback_locale'
))
->add('translation', 'mailer_email_translation', array(
->add('useFallbackLocale', 'checkbox', array(
'data' => $options['data_translation'],
'with_language' => $options['edit'],
'label' => 'lexik_mailer.email.translation',
Expand All @@ -83,7 +87,7 @@ public function configureOptions(OptionsResolver $resolver)
/**
* {@inheritdoc}
*/
public function getName()
public function getBlockPrefix()
{
return 'mailer_email';
}
Expand Down
8 changes: 5 additions & 3 deletions Form/Type/HeaderType.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
namespace Lexik\Bundle\MailerBundle\Form\Type;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Validator\Constraints\NotBlank;
Expand Down Expand Up @@ -33,13 +35,13 @@ public function __construct(array $allowedHeaders)
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('key', 'choice', array(
->add('key', ChoiceType::class, array(
'required' => true,
'choices' => $options['key_choices'],
'multiple' => false,
'expanded' => false,
))
->add('value', 'text', array(
->add('value', TextType::class, array(
'required' => true,
'constraints' => array(
new NotBlank(),
Expand All @@ -61,7 +63,7 @@ public function configureOptions(OptionsResolver $resolver)
/**
* {@inheritdoc}
*/
public function getName()
public function getBlockPrefix()
{
return 'lexik_mailer_header';
}
Expand Down
5 changes: 3 additions & 2 deletions Form/Type/LayoutTranslationType.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Lexik\Bundle\MailerBundle\Form\Type;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\LanguageType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

Expand All @@ -22,7 +23,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
));

if ($options['with_language']) {
$builder->add('lang', 'language', array(
$builder->add('lang', LanguageType::class, array(
'preferred_choices' => $options['preferred_languages'],
'label' => 'lexik_mailer.translations.subject',
));
Expand All @@ -45,7 +46,7 @@ public function configureOptions(OptionsResolver $resolver)
/**
* {@inheritdoc}
*/
public function getName()
public function getBlockPrefix()
{
return 'mailer_layout_translation';
}
Expand Down
8 changes: 5 additions & 3 deletions Form/Type/LayoutType.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
namespace Lexik\Bundle\MailerBundle\Form\Type;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

Expand All @@ -17,12 +19,12 @@ class LayoutType extends AbstractType
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('reference', 'text', array(
->add('reference', TextType::class, array(
'read_only' => $options['edit'],
'property_path' => 'entity.reference',
'label' => 'lexik_mailer.layout.reference',
))
->add('description', 'textarea', array(
->add('description', TextareaType::class, array(
'property_path' => 'entity.description',
'required' => false,
'label' => 'lexik_mailer.layout.description',
Expand Down Expand Up @@ -57,7 +59,7 @@ public function configureOptions(OptionsResolver $resolver)
/**
* {@inheritdoc}
*/
public function getName()
public function getBlockPrefix()
{
return 'mailer_layout';
}
Expand Down
10 changes: 5 additions & 5 deletions Resources/config/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -95,23 +95,23 @@
<!-- Form Types -->
<service id="lexik_mailer.form.type.header" class="%lexik_mailer.form.type.header.class%">
<argument>%lexik_mailer.allowed_headers%</argument>
<tag name="form.type" alias="lexik_mailer_header" />
<tag name="form.type" />
</service>

<service id="lexik_mailer.form.type.mailer_email" class="%lexik_mailer.form.type.mailer_email.class%">
<tag name="form.type" alias="mailer_email" />
<tag name="form.type" />
</service>

<service id="lexik_mailer.form.type.mailer_email_translation" class="%lexik_mailer.form.type.mailer_email_translation.class%">
<tag name="form.type" alias="mailer_email_translation" />
<tag name="form.type" />
</service>

<service id="lexik_mailer.form.type.mailer_layout" class="%lexik_mailer.form.type.mailer_layout.class%">
<tag name="form.type" alias="mailer_layout" />
<tag name="form.type" />
</service>

<service id="lexik_mailer.form.type.mailer_layout_translation" class="%lexik_mailer.form.type.mailer_layout_translation.class%">
<tag name="form.type" alias="mailer_layout_translation" />
<tag name="form.type" />
</service>

<!-- Form handler -->
Expand Down
21 changes: 21 additions & 0 deletions Resources/translations/EmailAdmin.zh_CN.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
list:
label_reference: 参考
label_layout: 布局
label_description: 描述
label__action: 行动

filter:
label_reference: 参考
label_layout: 布局

breadcrumb:
link_email_list: 电子邮件

form:
label_layout: 布局
label_description: 描述
label_reference: 参考
label_bcc: 密件抄送
label_spool: 电子邮件阀芯

create_translation: 新翻译
11 changes: 11 additions & 0 deletions Resources/translations/EmailTranslationAdmin.zh_CN.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
breadcrumb:
link_email_translation_list: 翻译
link_email_translation_create:

form:
label_lang: 语言
label_from_address: 发件人地址
label_from_name: 从名字
label_subject: 学科
label_body : 内容(HTML)
label_body_text: 内容(纯文本)
18 changes: 18 additions & 0 deletions Resources/translations/LayoutAdmin.zh_CN.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
list:
label_reference: 参考
label_description: 描述
label__action: 行动

filter:
label_reference: 参考

breadcrumb:
link_layout_list: 设计

form:
label_description: 描述
label_reference: 参考
label_bcc: 密件抄送
label_spool:

create_translation: 新翻译
7 changes: 7 additions & 0 deletions Resources/translations/LayoutTranslationAdmin.zh_CN.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
breadcrumb:
link_layout_translation_list: 翻译
link_layout_translation_create:

form:
label_lang: 语言
label_body: 内容
Loading

0 comments on commit 57535a3

Please sign in to comment.