Unable to use the sylius services

85
February 12, 2019, at 6:00 PM

Service "sylius.repository.product" not found: even though it exists in the app's container, the container inside "App\Controller\Shop\SubscribeBoxController" is a smaller service locator that only knows about the "doctrine", "form.factory", "http_kernel", "parameter_bag", "request_stack", "router", "security.authorization_checker", "security.csrf.token_manager", "security.token_storage", "serializer", "session", "templating" and "twig" services. Try using dependency injection instead.

I got this error when I am trying to use the sylius services on my controller:

public function index(Request $request)
{
    $subscribed = new Subscribed();
    $subscribeForm = $this->createForm(SubscribeType::class, $subscribed);
    $subscribeForm->handleRequest($request);
    if ($subscribeForm->isSubmitted() && $subscribeForm->isValid()) {
        $entityManager = $this->getDoctrine()->getManager();
        $entityManager->persist($subscribed);
        $entityManager->flush();
        return $this->redirectToRoute('subscribe_details');
    }
    /** @var ProductRepository $productRepository */
    $productRepository = $this->get('sylius.repository.product');
    $product = $productRepository->findAll();
    return $this->render('@SyliusShop/Subscribe/plan.html.twig', [
        'form' => $subscribeForm->createView(),
        'product' => $product,
    ]);
}

So if anyone knows about this error let me know! :)

READ ALSO
Weird problem in .htacess occurring after server change

Weird problem in .htacess occurring after server change

I have a site with 3 scripts, namely viewgamesphp, play

35
I want to create a delete button for date ,start time and end time but not getting how to do it

I want to create a delete button for date ,start time and end time but not getting how to do it

// I tried to do it but it didn't workI tried using echo statement but it didn't work as well

64
Office365 standalone php app authorization

Office365 standalone php app authorization

I have a standalone PHP webapp that I am tasked with adding Office365 authorization to in order for only authorized users to access

44
pdf to byte array conversion in php

pdf to byte array conversion in php

I need to convert Pdf file to byte array conversion in phpI am looking for like this result

52