You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have created my own controller for a news overview page and would like to display the latest news paginated here. What is the intended way to access news in the controller?
"App\Controller\Website\NewsController::getSubscribedServices()" must return valid PHP types for service "App\Controller\Website\NewsController" key "sulu_news.repository", "sulu_news.repository" returned.
Cannot autowire service "App\Controller\Website\NewsController": argument "$newsRepository" of method "__construct()" references class "TheCadien\Bundle\SuluNewsBundle\Repository\NewsRepository" but no such service exists. You should maybe alias this class to one of these existing services: "sulu_news.repository", "sulu.repository.news".
Because I am a bit under time pressure in the current project, I have added the following alias in services.xml
This guide is primarily intended for creating your own controllers in the PHPCR context.
That is, within the webspace bundle.
You will not need this for the most part within the NewsBundle . This is based on a Doctrine entity.
Please take a look at the controller of the NewsBundle and copy and adapt it as you need it.
I looked at your controller, I don't think it answers my question. I'm not trying to customize the view of a single news item, I'm trying to access the repository to create a list view.
I am also trying to work out the best way to approach getting news posts to the front end.
I'd like, for example, to be able to do something similar to the following:
example.com/news shows an index of all news posts
example.com/news/1 shows an individual post page
In Symfony itself this is pretty straightforward using a Controller extending AbstractController but the Sulu documents don't seem to show much info on standalone controllers that don't have a connection to a specific page template.
Is there perhaps an example project somewhere that has the news integrated into the front end? You mention looking at the controller from the bundle, but what is required to get the autowired services connected as @FlorianBoe mentions?
Hi there!
I have created my own controller for a news overview page and would like to display the latest news paginated here. What is the intended way to access news in the controller?
I have tried the following variant recommended in the SULU documentation to pass additional data to the template, unfortunately without success.
Leads to the following error message:
I have tried to access the repository directly
But get the following error message
Because I am a bit under time pressure in the current project, I have added the following alias in services.xml
Would it make sense to introduce an alias for the repository or is there a better way with SULU that I'm overlooking here?
The text was updated successfully, but these errors were encountered: