Handling deletions
We have seen in the BO controllers that we use commands to delete each entity, the DeleteCategoryCommand
for the categories and the DeletePostCommand
for posts.
Each command is linked to its CommandHandler
. Now that we have mastered the command creation, we will focus on CommandHandlers
.
Let’s create the /modules/whblog/src/Domain/WHBlogCategory/CommandHandler/DeleteCategoryHandler.php
file to implement DeleteCategoryHandler
linked to DeleteCategoryCommand
. Its content can be seen in the following code:
//namespace and uses available in the GitHub repository class DeleteCategoryHandler { private $entityManager; private $categoryRepository; public function __construct($entityManager, $categoryRepository) { $this->entityManager = $entityManager; $this->categoryRepository = $categoryRepository; } public function handle...