Search code examples
fat-free-framework

See if route exists Fat-Free-Framework


I am currently creating a pluggable website, but is there a way to see if a certain route has been made ? Like this :

  • I initiate all plugins
  • A plugin want's to know if the home (GET /) has already been taken by another plugin.

How can I verify a route ? $f3->exists('something'); maybe ?


Solution

  • The ROUTES variable contains the list of defined routes indexed by URI.

    So to check if a URI has been used, just check if it exists as a key of ROUTES:

    if (array_key_exists('/',$f3->ROUTES)) {
      // already used
    } else {
      // not used
    }