src/Controller/SuccessStoriesController.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use Pimcore\Controller\FrontendController;
  4. use Symfony\Component\HttpFoundation\Request;
  5. use Pimcore\Model\DataObject;
  6. use Symfony\Component\Messenger\MessageBusInterface;
  7. class SuccessStoriesController extends FrontendController
  8. {
  9.     public function defaultAction(Request $request)
  10.     {
  11.         $slug trim($request->get('slug'), '/');
  12.         if(str_contains($slug'ssid-')){
  13.             $successStory DataObject\SuccessStories::getById(str_replace('ssid-'''$slug), 1);
  14.         }else{
  15.             $successStory DataObject\SuccessStories::getByURL($slug1);
  16.         }
  17.         if(is_null($successStory->getSnipped())){
  18.             throw new \Pimcore\Model\Element\ValidationException("This is your custom error message"1234);
  19.         }
  20.         $this->document->setValue('title'$successStory->getMetaTitle());
  21.         $this->document->setValue('description'$successStory->getMetaDescription());
  22.         return $this->render('digitalwandler/DocumentType/snippedPage.html.twig', ['snipped' => $successStory->getSnipped()->getId()]);
  23.     }
  24.     public function menuAction(Request $request)
  25.     {
  26.         $successStories DataObject\SuccessStories::getList([
  27.             'order' => 'desc'
  28.         ]);
  29.         foreach ($successStories as $successStory){
  30.             foreach (explode('|'$successStory->getTags()) as $tag){
  31.                 if(isset($tags[$tag])){
  32.                     $tags[$tag]++;
  33.                 }else{
  34.                     $tags[$tag] = 1;
  35.                 }
  36.             }
  37.         }
  38.         return $this->render('digitalwandler/DocumentType/menuSnippet.html.twig', ['tags' => $tags'page' => $request->get('page')]);
  39.     }
  40. }