Quantcast
Channel: Active questions tagged symfony4 - Stack Overflow
Viewing all articles
Browse latest Browse all 3925

how to avoid creating a slug that already exists as a Route "Symfony 4"

$
0
0

I have the entity Page identified by slug. Also I have the action to view a page in the Page controler :

class PageController extends AbstractController
{
   /**
    * @Route("/{slug}", name="fronend_page")
    */
   public function show(Page $page)
   {
       return $this->render("font_end/page/show.html.twig", [
           "page" => $page,
       ]);
   }
}

I am looking for good practice to validate the slug ( check if exist in routes) before save it in the database without use prefixes Example :

route exist : @route ("/blog")

check if blog exist before create slug : /{slug} = /blog

thanks


Viewing all articles
Browse latest Browse all 3925

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>