I am new to symfony, i was reading through the best practices guide here https://symfony.com/doc/3.4/best_practices/business-logic.html
I have a controller called Category and i have this action method to list down categories.
public function listCategory(Request $request, CategoryLogic $categoryLogic)
{
$categories = $categoryLogic->getAllCategory($this->getDoctrine());
return $this->render('listCategory.html.twig', ['categories' => $categories]);
}
As you can see all my business logic for controller goes to -> AppBundle\Utils\CategoryLogic
There i have this method to handle the logic and return the categories
use AppBundle\Entity\Category;
/**
* @param Registry $doctrine
* @return array
*/
public function getAllCategory(Registry $doctrine)
{
$repositoryCategory = $doctrine->getRepository(Category::class);
$category = $repositoryCategory->findAll();
return $category;
}
The purpose is to keep the controller clean. is this the best way to do it? i have a little concern about naming the logic class as CategoryLogic
instead i would like to name it as Category but then i have another problem because i am already importing use AppBundle\Entity\Category
in CategoryLogic class so there cant be two Category classes