I have a problem when I try to create a service in Symfony2.
This is my services.yml
services:
Menu:
class: My\WebBundle\Classes\System\Menu
arguments: [@service_container]
This is my service Menu:
namespace My\WebBundle\Classes\System;
use Symfony\Component\DependencyInjection\ContainerInterface as Container;
Class Menu{
private $container;
public function __construct(Container $container) {
$this->container = $container;
}
public function getMenu($section) {
return "hello";
}
}
When in a controller I do:
$menu = $this->get('Menu');
I get:
FatalErrorException: Error: Cannot instantiate interface My\WebBundle\Classes\System\Menu in ...\cache\dev\appDevDebugProjectContainer.php line 1522
Of course I cleaned cache.