ikucheriavenko
7/19/2017 - 2:07 PM

Form and Rich model

Form and Rich model

public function setDefaultOptions(OptionsResolverInterface $resolver)
{
    $resolver->setDefaults(array(
        'empty_data' => function (FormInterface $form) {
            $post = Post::compose(
                $form->get('headline')->getData(),
                $form->get('text')->getData(),
                $form->get('tags')->getData()
            );
            $post->publish($form->get('publishAt')->getData());
            return $post;
        },
    ));
}

https://beberlei.de/2012/08/22/building_an_object_model__no_setters_allowed.html