Skip to content
Advertisement

Tag: symfony

Calling console command within command and get the output in Symfony2

I have a few console command in Symfony2 and I need to execute one command from another command with some parameters. After successfull execution of the second command I need to get the result (as an array for example), not the display output. How can I do that? Answer Here you can have a basic command inside a command. The

Doctrine – Add default time stamp to entity like NOW()

Following the Doctrine guidelines I understand how to set a default value for an Entity, but what if I wanted a date/time stamp? http://docs.doctrine-project.org/projects/doctrine-orm/en/2.1/reference/faq.html My problem is my database has a default of NOW() on a field but when I use Doctrine to insert a record the values are null or blank but the rest of the insert happened. Also

symfony2: how to access service from template

If I created a service is there a way to access it from twig, without creating a twig.extension? Answer You can set the service a twig global variable in config.yml, e.g And in your template.html.twig file you can invoke your service this way: See here.

Symfony2 Validating an optional field

In my form, I have a field with required option set to false, this field is optional. However, I would like to have a notBlank validation on this field when the field is used: Right now, I can’t use the validation constraint NotBlank because it will cause my form validation to fail when the field is unused. I tried something

Advertisement