src/CoreBundle/Controller/RecipeController.php line 25

Open in your IDE?
  1. <?php
  2. namespace CoreBundle\Controller;
  3. use Pimcore\Tool;
  4. use Symfony\Component\HttpFoundation\Request;
  5. use Pimcore\Model\DataObject\Recipe;
  6. class RecipeController extends AbstractController
  7. {
  8.     public function listAction(Request $request)
  9.     {
  10.         $channel $this->document->getProperty('applicationChannel');
  11.         $recipesList = new Recipe\Listing();
  12.         $recipesList->setCondition('channels like "%,' $channel->getId() . ',%"');
  13.         $recipesList->load();
  14.         foreach ($recipesList as $recipe) {
  15.             $recipe->urlTitle = \Pimcore\File::getValidFilename($recipe->getTitle());
  16.         }
  17.         $this->view->recipes $recipesList;
  18.         return $this->render('Recipe/list.html.twig'$this->view->getAllParameters());
  19.     }
  20.     public function showByIdAction(Request $request)
  21.     {
  22.         $recipeId $request->get('rezeptid'0);
  23.         $recipe Recipe::getById($recipeId);
  24.         if ($recipe instanceof Recipe) {
  25.             $this->view->error false;
  26.             $this->view->recipe $recipe;
  27.         } else {
  28.             $this->view->error 'recipe not found';
  29.         }
  30.         // Set SEO title and description if available
  31.         $this->view->seoTitle $recipe->getTitle() ?? null;
  32.         $this->view->seoDescription $recipe->getTeaserText() ?? null;
  33.         return $this->render('Recipe/showById.html.twig'$this->view->getAllParameters());
  34.     }
  35. }