The class Twig_Extension has been deprecated with message: since Twig 2.7, use "Twig\Extension\AbstractExtension" instead
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the type will be
removed from the class and what other constant to use instead.
Loading history...
10
{
11
/**
12
* @var EntityManager
13
*/
14
protected $em;
15
16
41
public function __construct(EntityManager $entityManager)
You have injected the EntityManager via parameter $entityManager. This is generally not recommended as it might get closed and become unusable. Instead, it is recommended to inject the ManagerRegistry and retrieve the EntityManager via getManager() each time you need it.
The EntityManager might become unusable for example if a transaction is
rolled back and it gets closed. Let’s assume that somewhere in your application,
or in a third-party library, there is code such as the following:
functionsomeFunction(ManagerRegistry$registry){$em=$registry->getManager();$em->getConnection()->beginTransaction();try{// Do something.$em->getConnection()->commit();}catch(\Exception$ex){$em->getConnection()->rollback();$em->close();throw$ex;}}
If that code throws an exception and the EntityManager is closed. Any other
code which depends on the same instance of the EntityManager during this
request will fail.
On the other hand, if you instead inject the ManagerRegistry, the getManager()
method guarantees that you will always get a usable manager instance.
Loading history...
17
{
18
41
$this->em = $entityManager;
19
41
}
20
21
23
public function getFunctions()
22
{
23
return array(
24
23
new TwigFunction('allTagsAsString', array($this, 'allTagsAsString')),
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.