diff --git a/local/media/images/content/tiramisu_banoffee-2.jpeg b/local/media/images/content/tiramisu_banoffee-2.jpeg deleted file mode 100644 index b0fb24f4..00000000 Binary files a/local/media/images/content/tiramisu_banoffee-2.jpeg and /dev/null differ diff --git a/local/modules/Recettes/Config/config.xml b/local/modules/Recettes/Config/config.xml index a4858f04..2e3e7aa1 100644 --- a/local/modules/Recettes/Config/config.xml +++ b/local/modules/Recettes/Config/config.xml @@ -25,5 +25,11 @@ + + + + + + diff --git a/local/modules/Recettes/EventListener/ContentListener.php b/local/modules/Recettes/EventListener/ContentListener.php new file mode 100644 index 00000000..c3fea7b5 --- /dev/null +++ b/local/modules/Recettes/EventListener/ContentListener.php @@ -0,0 +1,61 @@ +request = $request; + } + + + public static function getSubscribedEvents() + { + return [ + ContentEvent::PRE_DELETE => [ "deleteRecipeBeforeContent", 100 ] + ]; + } + + + public function deleteRecipeBeforeContent(ContentEvent $event) + { + $con = Propel::getConnection(); + + $contentId = $this->request->request->get('content_id'); + $recipeId = RecipeQuery::create() + ->findOneByContentId($contentId) + ->getId(); + + if ($recipeId) + { + RecipeStepsQuery::create() + ->filterByRecipeId($recipeId) + ->find($con) + ->delete(); + + RecipeProductsQuery::create() + ->filterByRecipeId($recipeId) + ->find($con) + ->delete(); + + RecipeQuery::create() + ->findOneByContentId($contentId) + ->delete(); + } + } + +}