]> Raphaël G. Git Repositories - blogbundle/commitdiff
Add form files
authorRaphaël Gertz <git@rapsys.eu>
Sun, 25 Feb 2018 05:04:49 +0000 (06:04 +0100)
committerRaphaël Gertz <git@rapsys.eu>
Sun, 25 Feb 2018 05:04:49 +0000 (06:04 +0100)
Form/ArticleType.php [new file with mode: 0644]
Form/AuthorType.php [new file with mode: 0644]
Form/ContactType.php [new file with mode: 0644]
Form/KeywordType.php [new file with mode: 0644]
Form/LanguageType.php [new file with mode: 0644]
Form/SiteType.php [new file with mode: 0644]

diff --git a/Form/ArticleType.php b/Form/ArticleType.php
new file mode 100644 (file)
index 0000000..346ae88
--- /dev/null
@@ -0,0 +1,36 @@
+<?php
+
+namespace Rapsys\BlogBundle\Form;
+
+use Symfony\Component\Form\AbstractType;
+use Symfony\Component\Form\FormBuilderInterface;
+use Symfony\Component\OptionsResolver\OptionsResolver;
+
+class ArticleType extends AbstractType
+{
+    /**
+     * {@inheritdoc}
+     */
+    public function buildForm(FormBuilderInterface $builder, array $options)
+    {
+        $builder->add('created')->add('updated')->add('site')->add('author')->add('keywords');
+    }
+    
+    /**
+     * {@inheritdoc}
+     */
+    public function configureOptions(OptionsResolver $resolver)
+    {
+        $resolver->setDefaults(array(
+            'data_class' => 'Rapsys\BlogBundle\Entity\Article'
+        ));
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function getBlockPrefix()
+    {
+        return 'rapsys_blogbundle_article';
+    }
+}
diff --git a/Form/AuthorType.php b/Form/AuthorType.php
new file mode 100644 (file)
index 0000000..9a908a4
--- /dev/null
@@ -0,0 +1,36 @@
+<?php
+
+namespace Rapsys\BlogBundle\Form;
+
+use Symfony\Component\Form\AbstractType;
+use Symfony\Component\Form\FormBuilderInterface;
+use Symfony\Component\OptionsResolver\OptionsResolver;
+
+class AuthorType extends AbstractType
+{
+    /**
+     * {@inheritdoc}
+     */
+    public function buildForm(FormBuilderInterface $builder, array $options)
+    {
+        $builder->add('name')->add('slug')->add('created')->add('updated');
+    }
+    
+    /**
+     * {@inheritdoc}
+     */
+    public function configureOptions(OptionsResolver $resolver)
+    {
+        $resolver->setDefaults(array(
+            'data_class' => 'Rapsys\BlogBundle\Entity\Author'
+        ));
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function getBlockPrefix()
+    {
+        return 'rapsys_blogbundle_author';
+    }
+}
diff --git a/Form/ContactType.php b/Form/ContactType.php
new file mode 100644 (file)
index 0000000..07c8eb0
--- /dev/null
@@ -0,0 +1,40 @@
+<?php
+
+namespace Rapsys\BlogBundle\Form;
+
+use Symfony\Component\Form\AbstractType;
+use Symfony\Component\Form\FormBuilderInterface;
+use Symfony\Component\OptionsResolver\OptionsResolver;
+use Symfony\Component\Form\Extension\Core\Type\TextType;
+use Symfony\Component\Form\Extension\Core\Type\TextareaType;
+use Symfony\Component\Form\Extension\Core\Type\EmailType;
+use Symfony\Component\Form\Extension\Core\Type\SubmitType;
+use Symfony\Component\Validator\Constraints\Email;
+use Symfony\Component\Validator\Constraints\NotBlank;
+
+class ContactType extends AbstractType {
+       /**
+        * {@inheritdoc}
+        */
+       public function buildForm(FormBuilderInterface $builder, array $options) {
+               return $builder->add('name', TextType::class, array('attr' => array('placeholder' => 'Your name'), 'constraints' => array(new NotBlank(array("message" => "Please provide your name")))))
+                       ->add('subject', TextType::class, array('attr' => array('placeholder' => 'Subject'), 'constraints' => array(new NotBlank(array("message" => "Please give a Subject")))))
+                       ->add('email', EmailType::class, array('attr' => array('placeholder' => 'Your email address'), 'constraints' => array(new NotBlank(array("message" => "Please provide a valid email")), new Email(array("message" => "Your email doesn't seems to be valid")))))
+                       ->add('message', TextareaType::class, array('attr' => array('placeholder' => 'Your message here', 'cols' => 50, 'rows' => 15), 'constraints' => array(new NotBlank(array("message" => "Please provide a message here")))))
+                       ->add('submit', SubmitType::class, array('label' => 'Send', 'attr' => array('class' => 'submit')));
+       }
+
+       /**
+        * {@inheritdoc}
+        */
+       public function setDefaultOptions(OptionsResolver $resolver) {
+               $resolver->setDefaults(array('error_bubbling' => true));
+       }
+
+       /**
+        * {@inheritdoc}
+        */
+       public function getName() {
+               return 'contact_form';
+       }
+}
diff --git a/Form/KeywordType.php b/Form/KeywordType.php
new file mode 100644 (file)
index 0000000..895842b
--- /dev/null
@@ -0,0 +1,36 @@
+<?php
+
+namespace Rapsys\BlogBundle\Form;
+
+use Symfony\Component\Form\AbstractType;
+use Symfony\Component\Form\FormBuilderInterface;
+use Symfony\Component\OptionsResolver\OptionsResolver;
+
+class KeywordType extends AbstractType
+{
+    /**
+     * {@inheritdoc}
+     */
+    public function buildForm(FormBuilderInterface $builder, array $options)
+    {
+        $builder->add('created')->add('updated')->add('articles');
+    }
+    
+    /**
+     * {@inheritdoc}
+     */
+    public function configureOptions(OptionsResolver $resolver)
+    {
+        $resolver->setDefaults(array(
+            'data_class' => 'Rapsys\BlogBundle\Entity\Keyword'
+        ));
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function getBlockPrefix()
+    {
+        return 'rapsys_blogbundle_keyword';
+    }
+}
diff --git a/Form/LanguageType.php b/Form/LanguageType.php
new file mode 100644 (file)
index 0000000..5b4d153
--- /dev/null
@@ -0,0 +1,36 @@
+<?php
+
+namespace Rapsys\BlogBundle\Form;
+
+use Symfony\Component\Form\AbstractType;
+use Symfony\Component\Form\FormBuilderInterface;
+use Symfony\Component\OptionsResolver\OptionsResolver;
+
+class LanguageType extends AbstractType
+{
+    /**
+     * {@inheritdoc}
+     */
+    public function buildForm(FormBuilderInterface $builder, array $options)
+    {
+        $builder->add('iso6391')->add('iso6393')->add('created')->add('updated');
+    }
+    
+    /**
+     * {@inheritdoc}
+     */
+    public function configureOptions(OptionsResolver $resolver)
+    {
+        $resolver->setDefaults(array(
+            'data_class' => 'Rapsys\BlogBundle\Entity\Language'
+        ));
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function getBlockPrefix()
+    {
+        return 'rapsys_blogbundle_language';
+    }
+}
diff --git a/Form/SiteType.php b/Form/SiteType.php
new file mode 100644 (file)
index 0000000..5e7cc1b
--- /dev/null
@@ -0,0 +1,36 @@
+<?php
+
+namespace Rapsys\BlogBundle\Form;
+
+use Symfony\Component\Form\AbstractType;
+use Symfony\Component\Form\FormBuilderInterface;
+use Symfony\Component\OptionsResolver\OptionsResolver;
+
+class SiteType extends AbstractType
+{
+    /**
+     * {@inheritdoc}
+     */
+    public function buildForm(FormBuilderInterface $builder, array $options)
+    {
+        $builder->add('domain')->add('created')->add('updated');
+    }
+    
+    /**
+     * {@inheritdoc}
+     */
+    public function configureOptions(OptionsResolver $resolver)
+    {
+        $resolver->setDefaults(array(
+            'data_class' => 'Rapsys\BlogBundle\Entity\Site'
+        ));
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function getBlockPrefix()
+    {
+        return 'rapsys_blogbundle_site';
+    }
+}