$container) { // ... $loader->load('forms.xml'); $loader->load('validation.xml'); $loader->load('twig.xml'); } } Separar las declaraciones de los servicios
public function findUserBy(array $criteria); public function findUserByUsername($username); public function findUserByEmail($email); public function findUserByUsernameOrEmail($usernameOrEmail); public function findUserByConfirmationToken($token); public function findUsers(); public function getClass(); public function reloadUser(UserInterface $user); public function updateUser(UserInterface $user); public function updateCanonicalFields(UserInterface $user); public function updatePassword(UserInterface $user); } FOSUserBundle - UserManagerInterface
event occurs when a player is added to a team * * The event listener method * receives a App\MmsfBundle\Event\TeamPlayerEvent * instance. * * @var string * */ const TEAMPLAYER_ADDED = 'app.mmsf.player.added'; } Nombre del evento
function saveComment(CommentInterface $comment) { if (null === $comment->getThread()) { throw new InvalidArgumentException('The comment must have a thread'); } $event = new CommentPersistEvent($comment); $this->dispatcher->dispatch(Events::COMMENT_PRE_PERSIST, $event); if ($event->isPersistenceAborted()) { return; } $this->doSaveComment($comment); $event = new CommentEvent($comment); $this->dispatcher->dispatch(Events::COMMENT_POST_PERSIST, $event); } }
!"" Model/ $"" Type/ Tip: Usar el campo intention para más seguridad (CSRF) public function setDefaultOptions(OptionsResolverInterface $resolver) { $resolver->setDefaults(array( 'data_class' => $this->class, 'intention' => 'change_password', )); }
'Nombre')) namespace Symfony\Component\Form\Extension\Core\Type; use ... class TextType extends AbstractType { public function setDefaultOptions(OptionsResolverInterface $resolver) { $resolver->setDefaults(array( 'compound' => false, )); } public function getParent() { return 'field'; } public function getName() { return 'text'; } }
$om) { $this->om = $om; } public function buildForm(FormBuilderInterface $builder, array $options) { $transformer = new PlayerToEmailTransformer($this->om); $builder->addModelTransformer($transformer); } public function setDefaultOptions(OptionsResolverInterface $resolver) { $resolver->setDefaults(array( 'invalid_message' => 'El email introducido no existe', )); } public function getParent() { return 'email'; } public function getName() { return 'player_selector'; } }
https://github.com/FriendsOfSymfony/FOSCommentBundle • 3 steps to Symfony2 Form Mastery - Bernhard Schussek https://speakerdeck.com/bschussek/3-steps-to-symfony2-form-mastery