RouterPath - lddefensor/SimpleAI GitHub Wiki

Namespace and Path

  • namespace: Ulap\Helpers
  • path: LIB . DS . 'Helpers' . DS . 'RoutePath.php'

The RouterPath Class is a helper class that transforms delimited string (assuming to be the path that follows after Application's URL) into the following:

  • Controller Name
  • Method name
  • Array of Parameters for Method
  • Url Params (_GET) (the name=value pair after ? in a url)

Constructor

  • accepts a string. Parses the string using php's native function parse_url and assigns this as the class's queryString property. The queryString expects two associative keys from this, namely path and query. Path is the string before ? and query is the list of name=value pairs that follows after ? and is separated by &.

  • if path is set on queryString, the property actions is assigned as the list of strings separated by / in the value of path, else this is default to an empty array.

getController

  • returns the name of the first string in queryString path property, or the first value of actions property. If not set, returns the value defined by constant DEFAULT_ACTION

getMethod

  • returns the name of the second string in queryString path property, or the second value of actions. If not set, returns the value defined by constant DEFAULT_METHOD

getParameters

  • returns the rest of the string in in queryString path property, after method, or the rest of the values in the actions array. Defaults to an empty array.