Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- imports:
- - { resource: parameters.yml }
- - { resource: security.yml }
- - { resource: services.yml }
- fos_user:
- db_driver: orm
- firewall_name: main
- user_class: FLYUserBundleEntityUser
- use_listener: true
- #use_flash_notifications: true
- use_username_form_type: true
- model_manager_name: null # change it to the name of your entity/document manager if you don't want to use the default one.
- from_email:
- address: ++++++++@hotmail.fr
- sender_name: webmaster
- profile:
- form:
- type: fos_user_profile
- name: fos_user_profile_form
- validation_groups: [Profile, Default]
- change_password:
- form:
- type: fos_user_change_password
- name: fos_user_change_password_form
- validation_groups: [ChangePassword, Default]
- registration:
- confirmation:
- from_email: # Use this node only if you don't want the global email address for the confirmation email
- address: ++++++++@hotmail.fr
- sender_name: Webmaster
- enabled: true # change to true for required email confirmation
- template: FOSUserBundle:Registration:email.txt.twig
- form:
- type: fos_user_registration
- name: fos_user_registration_form
- validation_groups: [Registration, Default]
- resetting:
- token_ttl: 86400
- email:
- from_email: # Use this node only if you don't want the global email address for the resetting email
- address: ...
- sender_name: ...
- template: FOSUserBundle:Resetting:email.txt.twig
- form:
- type: fos_user_resetting
- name: fos_user_resetting_form
- validation_groups: [ResetPassword, Default]
- service:
- mailer: fos_user.mailer.default
- email_canonicalizer: fos_user.util.canonicalizer.default
- username_canonicalizer: fos_user.util.canonicalizer.default
- token_generator: fos_user.util.token_generator.default
- user_manager: fos_user.user_manager.default
- #group:
- #group_class: ~ # Required when using groups
- #group_manager: fos_user.group_manager.default
- #form:
- #type: fos_user_group
- #name: fos_user_group_form
- #validation_groups: [Registration, Default]
- <?php
- // src/FLY/UserBundle/Entity/User.php
- namespace FLYUserBundleEntity;
- use FOSUserBundleEntityUser as BaseUser;
- use DoctrineORMMapping as ORM;
- use SymfonyComponentValidatorConstraints as Assert;
- /**
- * @ORMEntity
- * @ORMTable(name="fos_user")
- */
- class User extends BaseUser
- {
- /**
- * @ORMId
- * @ORMColumn(type="integer")
- * @ORMGeneratedValue(strategy="AUTO")
- */
- protected $id;
- /**
- * @ORMColumn(name="name", type="string", length=255)
- *
- * @AssertNotBlank(message="Please enter your name.", groups={"Registration", "Profile"})
- * @AssertLength(
- * min=3,
- * max="255",
- * minMessage="The name is too short.",
- * maxMessage="The name is too long.",
- * groups={"Registration", "Profile"}
- * )
- */
- protected $name;
- public function __construct()
- {
- parent::__construct();
- // your own logic
- }
- }
- services:
- fos_user.registration.form.type:
- class: FOSUserBundleFormRegistrationFormType
- arguments: [%fos_user.model.user.class%]
- tags:
- - { name: form.type, alias: fos_user_registration }
- <?php
- /*
- * This file is part of the FOSUserBundle package.
- *
- * (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
- namespace FOSUserBundleFormType;
- use SymfonyComponentFormAbstractType;
- use SymfonyComponentFormFormBuilderInterface;
- use SymfonyComponentOptionsResolverOptionsResolver;
- use SymfonyComponentOptionsResolverOptionsResolverInterface;
- class RegistrationFormType extends AbstractType
- {
- private $class;
- /**
- * @param string $class The User class name
- */
- public function __construct($class)
- {
- $this->class = $class;
- }
- public function buildForm(FormBuilderInterface $builder, array $options)
- {
- $builder
- ->add('email', 'email', array('label' => 'form.email', 'translation_domain' => 'FOSUserBundle'))
- ->add('username', null, array('label' => 'form.username', 'translation_domain' => 'FOSUserBundle'))
- ->add('plainPassword', 'repeated', array(
- 'type' => 'password',
- 'options' => array('translation_domain' => 'FOSUserBundle'),
- 'first_options' => array('label' => 'form.password'),
- 'second_options' => array('label' => 'form.password_confirmation'),
- 'invalid_message' => 'fos_user.password.mismatch',
- ))
- ;
- }
- public function configureOptions(OptionsResolver $resolver)
- {
- $resolver->setDefaults(array(
- 'data_class' => $this->class,
- 'intention' => 'registration',
- ));
- }
- // BC for SF < 2.7
- public function setDefaultOptions(OptionsResolverInterface $resolver)
- {
- $this->configureOptions($resolver);
- }
- public function getName()
- {
- return 'fos_user_registration';
- }
- }
- fos_user:
- ........
- registration:
- form:
- ......
- type: your_form_type_id
- services:
- user.your_form_type.form.type:
- class: MyBundleFormMyRegistrationFormType
- arguments: [%fos_user.model.user.class%]
- tags:
- - { name: form.type, alias: your_form_type_id }
- namespace MyBundleFormType;
- use SymfonyComponentFormAbstractType;
- use SymfonyComponentFormFormBuilderInterface;
- use SymfonyComponentOptionsResolverOptionsResolverInterface;
- use FOSUserBundleFormRegistrationFormType as BaseType;
- class MyRegistrationFormType extends BaseType
- {
- private $class;
- /**
- * @param string $class The User class name
- */
- public function __construct($class)
- {
- parent::__construct($class);
- }
- public function buildForm(FormBuilderInterface $builder, array $options)
- {
- parent::buildForm(builder,$options);
- $builder
- ->add('addon_field1')
- ->add('addon_field2')
- ;
- }
- public function getName()
- {
- return 'your_form_type_id';
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement