Add more than one parameter in Twig path
You can pass as many arguments as you want, separating them by commas: {{ path(‘_files_manage’, {project: project.id, user: user.id}) }}
You can pass as many arguments as you want, separating them by commas: {{ path(‘_files_manage’, {project: project.id, user: user.id}) }}
Symfony 4.0 This process hasn’t changed from Symfony 3 to 4 but here is an example using the newly recommended AbstractController. Both the security.token_storage and the session services are registered in the parent getSubscribedServices method so you don’t have to add those in your controller. use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use YourNameSpace\UserBundle\Entity\User; class LoginController extends AbstractController{ … Read more
This can be nearly done by setting a new variable as a flag to break iterating: {% set break = false %} {% for post in posts if not break %} <h2>{{ post.heading }}</h2> {% if post.id == 10 %} {% set break = true %} {% endif %} {% endfor %} An uglier, but … Read more
Use the JoinColumn annotation on your ManyToOne relation: /** * @ORM\ManyToOne(targetEntity=”Package”, inversedBy=”users”) * @ORM\JoinColumn(name=”package_id”, referencedColumnName=”id”, nullable=false) */ private $package; The ManyToOne itself cannot be nullable, because it doesn’t relate to a specific column. The JoinColumn on the other hand identifies the column in the database. Thus, you can use “normal” attributes like nullable or unique!
You can use ~ or null. You should read documentation of YAML and you can read Symfony Yaml Format as well title: 1: String 2: String2 3: ~
UPDATE 2018-10-21: As of this week, getRootDir() was deprecated. Please use getProjectDir() instead, as suggested in the comment section by Muzaraf Ali. —- Use this: $this->get(‘kernel’)->getRootDir(); And if you want the web root: $this->get(‘kernel’)->getRootDir() . ‘/../web’ . $this->getRequest()->getBasePath(); this will work from controller action method… EDIT: As for the services, I think the way you … Read more
Tilde means next significant release. In your case, it is equivalent to >= 2.0, < 3.0. The full explanation is at Tilde Version Range docs page: The ~ operator is best explained by example: ~1.2 is equivalent to >=1.2 <2.0.0, while ~1.2.3 is equivalent to >=1.2.3 <1.3.0. Another way of looking at it is that … Read more
As @Lighthart as shown, yes it’s possible, although it adds significant fat to the controller and isn’t DRY. You should really define your own query in the entity repository, it’s simple and best practice. use Doctrine\ORM\EntityRepository; class UserRepository extends EntityRepository { public function findAll() { return $this->findBy(array(), array(‘username’ => ‘ASC’)); } } Then you must … Read more
I have faced same problem. I had to supply ‘public’ headers my cdn. By default when gateway caching is enabled in prod mode, it returns 200 OK with private, nocache must validate headers. I solved problem this way. In app.php, before I send response to user ($respond->send), I have overwritten the cache control header to … Read more
you can set the default value with empty_data $builder->add(‘myField’, ‘number’, [’empty_data’ => ‘Default value’])