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
In the day 6, with SF 4, we could extend ServiceEntityRepository for the repositories as per the symfony doc
It allows you to use autowiring and thus less boiler plate.
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Common\Persistence\ManagerRegistry;
class CategoryRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, Category::class);
}
...
}
and then in the JobController
use App\Repository\CategoryRepository;
...
public function list(CategoryRepository $categoryRepository) : Response
{
$categories = $categoryRepository->findWithActiveJobs();
return $this->render('job/list.html.twig', [
'categories' => $categories,
]);
}
Anyway it also works with EntityRepository.
Thanks for the great Job.
The text was updated successfully, but these errors were encountered:
In the day 6, with SF 4, we could extend ServiceEntityRepository for the repositories as per the symfony doc
It allows you to use autowiring and thus less boiler plate.
and then in the JobController
Anyway it also works with EntityRepository.
Thanks for the great Job.
The text was updated successfully, but these errors were encountered: