Twig: render vs include

Each render call spawns a new request, with the performance degradation issue that you are describing. I don’t think there is much you can do about that but using esi caching, so that single fragments coming from render calls can be cached. Otherwise you could try to revise your logic to reduce the usage of … Read more

Build a form having a checkbox for each entity in a doctrine collection

I think this will answer your question. Forget the FooEntitySelectionType. Add a property_path field option to FooEntitySelectByIdentityType and set the data_class option to null: class FooEntitySelectByIdentityType extends AbstractType { public function buildForm(FormBuilderInterface $builder, array $options) { $builder->add(‘foo_id’, ‘entity’, array( ‘required’ => false, ‘class’ => ‘MeMyBundle:FooEntity’, ‘property’ => ‘id’, ‘property_path’ => ‘[id]’, # in square brackets! … Read more

How to convert this to Doctrine 2 QueryBuilder format?

try this : 1) create your subquery $subquery = $this->_em->createQueryBuilder() ->select(‘t.id’) ->from(‘yourBundle:Task’, ‘t’) ->innerjoin(‘t.user’,’u’) ->where(‘u.id = 1’) ->getDQL(); 2) after create your query $query = $this->_em->createQueryBuilder(); $query->select(‘l’) ->from(‘yourBundle:Layer’, ‘l’) ->where($query->expr()->notIn(‘l.id’, $subquery)) ….; I tested it and it works 🙂

Extends parent blocks from embed template

As said in the comment, includes/embeds can’t alter blocks from their includer. That said there is an extension available that could solve your problem. This Deferred Twig Extension can be found here Basically the node postpones the execution of a said block. This way you can create a variable that holds all of your javascript … Read more

Doctrine – A new entity was found through the relationship

I had the same problem and it was the same EntityManager. I wanted to insert an object related ManyToOne. And I don’t want a cascade persist. Example : $category = $em->find(“Category”, 10); $product = new Product(); $product->setCategory($category) $em->persist($product); $em->flush(); This throws the same exception for me. So the solution is : $category = $em->find(“Category”, 10); … Read more

The method name must start with either findBy or findOneBy. Undefined method Symfony?

Make sure that you have modified your entity class: // src/Blogger/BlogBundle/Entity/Blog.php /** * @ORM\Entity(repositoryClass=”Blogger\BlogBundle\Repository\BlogRepository”) * @ORM\Table(name=”blog”) * @ORM\HasLifecycleCallbacks() */ class Blog { // .. } the annotation @ORM\Entity(repositoryClass=”Blogger\BlogBundle\Repository\BlogRepository”) is required. And don’t forget to regenerate entities: php app/console doctrine:generate:entities Blogger UPDATE Remove annotation @ORM\Entity. It overrides correct annotation @ORM\Entity(repositoryClass=”Blogger\BlogBundle\Repository\BlogRepository”)

How to check if a user is logged in Symfony2 inside a controller?

Warning: Checking for ‘IS_AUTHENTICATED_FULLY’ alone will return false if the user has logged in using “Remember me” functionality. According to Symfony 2 documentation, there are 3 possibilities: IS_AUTHENTICATED_ANONYMOUSLY – automatically assigned to a user who is in a firewall protected part of the site but who has not actually logged in. This is only possible … Read more