Answer the question
In order to leave comments, you need to log in
How to design the following logic?
there is a search page displayed by SearchControllerom
there is a search service itself SearchService::search( $params ) inside which the logic of sorting, pagination and much more other logic is implemented that will be the same for all projects
, the base search parameters will change from project to project
now it's something like this
class SearchController extends Controller
{
private function getParameterForSearchQuery()
{
return [ "type"=>["post","folder","group"], "subtree"=>"events" ];
}
public function indexAction()
{
. . .
. . .
$this->render('::index.html.twig', $this->searchService->search( $this->getParameterForSearchQuery() ) );
}
}
Answer the question
In order to leave comments, you need to log in
You can put it in a separate bundle, implement it as a service, and put the parameters in the config. Even if some of the functionality in some derivative project is more specific, you can provide for specifying your classes (again in the config) that are inherited from the base controller service.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question