Jump to content

How to load symfony services in module front controller?


stifler97
 Share

Recommended Posts

Is there a way to load symfony services inside module front controller?

Like this:

$importer = $this->get('prestashop.core.import.importer');

When I use this line inside a module front controller I get to this line:

throw new ServiceNotFoundException($id, null, null, $alternatives);

which means that this service does not exist in this container. So we come to this point that these services are only added to admin controllers.

So can we create a controller called "FrameworkBundleFrontController" just like "FrameworkBundleAdminController"?

Share this post


Link to post
Share on other sites

@Prestachamps thanks for the fast reply.
Please take a look at this:

I have tested and I it kind of works. But the issue is that the importer class requires the employee access and it does not work. It seems like that the implementation of import is coupled with admin access for employee. So it is not possible to reuse the symfony services of admin in front end controllers.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More