Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2015
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.64 KB | None | 0 0
  1. imports:
  2. - { resource: parameters.yml }
  3. - { resource: security.yml }
  4. - { resource: services.yml }
  5. fos_user:
  6. db_driver: orm
  7. firewall_name: main
  8. user_class: FLYUserBundleEntityUser
  9. use_listener: true
  10. #use_flash_notifications: true
  11. use_username_form_type: true
  12. model_manager_name: null # change it to the name of your entity/document manager if you don't want to use the default one.
  13. from_email:
  14. address: ++++++++@hotmail.fr
  15. sender_name: webmaster
  16. profile:
  17. form:
  18. type: fos_user_profile
  19. name: fos_user_profile_form
  20. validation_groups: [Profile, Default]
  21. change_password:
  22. form:
  23. type: fos_user_change_password
  24. name: fos_user_change_password_form
  25. validation_groups: [ChangePassword, Default]
  26. registration:
  27. confirmation:
  28. from_email: # Use this node only if you don't want the global email address for the confirmation email
  29. address: ++++++++@hotmail.fr
  30. sender_name: Webmaster
  31. enabled: true # change to true for required email confirmation
  32. template: FOSUserBundle:Registration:email.txt.twig
  33. form:
  34. type: fos_user_registration
  35. name: fos_user_registration_form
  36. validation_groups: [Registration, Default]
  37. resetting:
  38. token_ttl: 86400
  39. email:
  40. from_email: # Use this node only if you don't want the global email address for the resetting email
  41. address: ...
  42. sender_name: ...
  43. template: FOSUserBundle:Resetting:email.txt.twig
  44. form:
  45. type: fos_user_resetting
  46. name: fos_user_resetting_form
  47. validation_groups: [ResetPassword, Default]
  48. service:
  49. mailer: fos_user.mailer.default
  50. email_canonicalizer: fos_user.util.canonicalizer.default
  51. username_canonicalizer: fos_user.util.canonicalizer.default
  52. token_generator: fos_user.util.token_generator.default
  53. user_manager: fos_user.user_manager.default
  54. #group:
  55. #group_class: ~ # Required when using groups
  56. #group_manager: fos_user.group_manager.default
  57. #form:
  58. #type: fos_user_group
  59. #name: fos_user_group_form
  60. #validation_groups: [Registration, Default]
  61.  
  62. <?php
  63. // src/FLY/UserBundle/Entity/User.php
  64.  
  65. namespace FLYUserBundleEntity;
  66.  
  67. use FOSUserBundleEntityUser as BaseUser;
  68. use DoctrineORMMapping as ORM;
  69. use SymfonyComponentValidatorConstraints as Assert;
  70.  
  71. /**
  72. * @ORMEntity
  73. * @ORMTable(name="fos_user")
  74. */
  75. class User extends BaseUser
  76. {
  77. /**
  78. * @ORMId
  79. * @ORMColumn(type="integer")
  80. * @ORMGeneratedValue(strategy="AUTO")
  81. */
  82. protected $id;
  83.  
  84. /**
  85. * @ORMColumn(name="name", type="string", length=255)
  86. *
  87. * @AssertNotBlank(message="Please enter your name.", groups={"Registration", "Profile"})
  88. * @AssertLength(
  89. * min=3,
  90. * max="255",
  91. * minMessage="The name is too short.",
  92. * maxMessage="The name is too long.",
  93. * groups={"Registration", "Profile"}
  94. * )
  95. */
  96.  
  97. protected $name;
  98.  
  99.  
  100. public function __construct()
  101. {
  102. parent::__construct();
  103. // your own logic
  104. }
  105. }
  106.  
  107. services:
  108. fos_user.registration.form.type:
  109. class: FOSUserBundleFormRegistrationFormType
  110. arguments: [%fos_user.model.user.class%]
  111. tags:
  112. - { name: form.type, alias: fos_user_registration }
  113.  
  114. <?php
  115. /*
  116. * This file is part of the FOSUserBundle package.
  117. *
  118. * (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
  119. *
  120. * For the full copyright and license information, please view the LICENSE
  121. * file that was distributed with this source code.
  122. */
  123. namespace FOSUserBundleFormType;
  124. use SymfonyComponentFormAbstractType;
  125. use SymfonyComponentFormFormBuilderInterface;
  126. use SymfonyComponentOptionsResolverOptionsResolver;
  127. use SymfonyComponentOptionsResolverOptionsResolverInterface;
  128. class RegistrationFormType extends AbstractType
  129. {
  130. private $class;
  131. /**
  132. * @param string $class The User class name
  133. */
  134. public function __construct($class)
  135. {
  136. $this->class = $class;
  137. }
  138. public function buildForm(FormBuilderInterface $builder, array $options)
  139. {
  140. $builder
  141. ->add('email', 'email', array('label' => 'form.email', 'translation_domain' => 'FOSUserBundle'))
  142. ->add('username', null, array('label' => 'form.username', 'translation_domain' => 'FOSUserBundle'))
  143. ->add('plainPassword', 'repeated', array(
  144. 'type' => 'password',
  145. 'options' => array('translation_domain' => 'FOSUserBundle'),
  146. 'first_options' => array('label' => 'form.password'),
  147. 'second_options' => array('label' => 'form.password_confirmation'),
  148. 'invalid_message' => 'fos_user.password.mismatch',
  149. ))
  150. ;
  151. }
  152. public function configureOptions(OptionsResolver $resolver)
  153. {
  154. $resolver->setDefaults(array(
  155. 'data_class' => $this->class,
  156. 'intention' => 'registration',
  157. ));
  158. }
  159. // BC for SF < 2.7
  160. public function setDefaultOptions(OptionsResolverInterface $resolver)
  161. {
  162. $this->configureOptions($resolver);
  163. }
  164. public function getName()
  165. {
  166. return 'fos_user_registration';
  167. }
  168. }
  169.  
  170. fos_user:
  171. ........
  172. registration:
  173. form:
  174. ......
  175. type: your_form_type_id
  176.  
  177. services:
  178. user.your_form_type.form.type:
  179. class: MyBundleFormMyRegistrationFormType
  180. arguments: [%fos_user.model.user.class%]
  181. tags:
  182. - { name: form.type, alias: your_form_type_id }
  183.  
  184. namespace MyBundleFormType;
  185.  
  186. use SymfonyComponentFormAbstractType;
  187. use SymfonyComponentFormFormBuilderInterface;
  188. use SymfonyComponentOptionsResolverOptionsResolverInterface;
  189. use FOSUserBundleFormRegistrationFormType as BaseType;
  190.  
  191. class MyRegistrationFormType extends BaseType
  192. {
  193. private $class;
  194.  
  195. /**
  196. * @param string $class The User class name
  197. */
  198. public function __construct($class)
  199. {
  200. parent::__construct($class);
  201. }
  202.  
  203. public function buildForm(FormBuilderInterface $builder, array $options)
  204. {
  205. parent::buildForm(builder,$options);
  206. $builder
  207. ->add('addon_field1')
  208. ->add('addon_field2')
  209. ;
  210. }
  211.  
  212. public function getName()
  213. {
  214. return 'your_form_type_id';
  215. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement