I'd like to use a constructor in my Symfony2 controller, but I have this error:
ContextErrorException: Catchable Fatal Error: Argument 1 passed to Acme\ApplicationBundle\Controller\CalendarActivityController::__construct() must implement interface Symfony\Component\DependencyInjection\ContainerInterface, none given, called in /Users/root/Documents/projects/Acme/Symfony/app/cache/dev/classes.php on line 2374 and defined in /Users/root/Documents/projects/Test/Symfony/src/Acme/ApplicationBundle/Controller/CalendarActivityController.php line 16
My constructor:
public function __construct(Container $container) {
$this->container = $container;
}
I must use a constructor because sometimes I'm using my controller as a service, and in this case container is not defined.
(Container $container = null)?