New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SF4] Container is null into Builder.php #388
Comments
Are you implementing the ContainerAwareInterface ? Using the trait is not what is detected by the bundle (as traits don't exist at runtime). The trait is handy to implement the needed method of the interface for you, but you still need to mark your class as implementing the interface. |
@stof Yes, i'm using it exactly as the doc says : use Knp\Menu\FactoryInterface;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
class Builder implements ContainerAwareInterface
{
use ContainerAwareTrait;
// ...
} Note that for quick fixing it, i just pass container interface to the service, but it still not according the documentation :
|
hmm, for builders defined as a service, the bundle does not implement any special support for ContainerAwareInterface (all the instantiation is handled by the service definition). And in your case, you are trying to inject the container in the constructor, not through |
In fact, we can only use the bundle through a service in V4. PS : I don't know the "setContainer" method. |
well, the trait you are using is precisely here to define a Regarding updating the doc, I'm changing the main way to define menus in #392, moving the convention-based one to a separate chapter, as it is indeed not compatible with Flex. |
Hello,
I installed knp_menu_bundle as described in the doc.
I use it as service as it's needed in SF4.
I
use ContainerAwareTrait;
But if i try to call container as described in the doc for geting entityManager, i get :
Did i forgot something or is ContainerAwareTrait incompatible with SF4 ?
The text was updated successfully, but these errors were encountered: