I use symfony2 (2.6) and I have class to global variable to twig. For Example, class menu:
namespace Cms\PageBundle\Twig;
use Doctrine\ORM\EntityManager;
class Menu {
protected $em;
public function __construct(EntityManager $em)
{
$this->em = $em;
}
public function show(){
/******/
}
}
and services.yml
services:
class_menu:
class: Cms\PageBundle\Twig\Menu
arguments: ['@doctrine.orm.entity_manager']
twig_menu:
class: Cms\PageBundle\Twig\Menu
See:
ContextErrorException in Menu.php line 9: Catchable Fatal Error: Argument 1 passed to Cms\PageBundle\Twig\Menu::__construct() must be an instance of Doctrine\ORM\EntityManager, none given, called in /home/cms/public_html/app/cache/dev/appDevDebugProjectContainer.php on line 3834 and defined
General, any class (outside) have problem with the constructor and (argument) doctrine. Why?
arguments: [@doctrine.orm.entity_manager]
– Matteopublic function __construct( $em)
– MatteoWarning: Missing argument 1 for Cms\PageBundle\Twig\Menu::__construct(), called in /home/cms/public_html/app/cache/dev/appDevDebugProjectContainer.php on line 3834 and defined
– viko