public function register($rtPath, $callback, $rtHandle = null, $additionalAttributes = array())
 {
     // setup up standard concrete5 routing.
     $rtPathTrimmed = trim($rtPath, '/');
     if (!$rtHandle) {
         $rtHandle = preg_replace('/[^A-Za-z0-9\\_]/', '_', $rtPathTrimmed);
         $rtHandle = preg_replace('/\\_+/', '_', $rtHandle);
         $rtHandle = trim($rtHandle, '_');
     }
     $rtPath = '/' . $rtPathTrimmed . '/';
     $attributes = array();
     if ($callback instanceof \Closure) {
         $attributes = ClosureRouteCallback::getRouteAttributes($callback);
     } else {
         if ($callback == 'dispatcher') {
             $attributes = DispatcherRouteCallback::getRouteAttributes($callback);
         } else {
             $attributes = ControllerRouteCallback::getRouteAttributes($callback);
         }
     }
     $attributes['path'] = $rtPath;
     $route = new Route($rtPath, $attributes, $additionalAttributes);
     $this->collection->add($rtHandle, $route);
 }
Exemple #2
0
 /**
  * Register a symfony route with as little as a path and a callback.
  *
  * @param string $path The full path for the route
  * @param \Closure|string $callback `\Closure` or "dispatcher" or "\Namespace\Controller::action_method"
  * @param string|null $handle The route handle, if one is not provided the handle is generated from the path "/" => "_"
  * @param array $requirements The Parameter requirements, see Symfony Route constructor
  * @param array $options The route options, see Symfony Route constructor
  * @param string $host The host pattern this route requires, see Symfony Route constructor
  * @param array|string $schemes The schemes or scheme this route requires, see Symfony Route constructor
  * @param array|string $methods The HTTP methods this route requires, see see Symfony Route constructor
  * @param string $condition see Symfony Route constructor
  * @return \Symfony\Component\Routing\Route
  */
 public function register($path, $callback, $handle = null, array $requirements = array(), array $options = array(), $host = '', $schemes = array(), $methods = array(), $condition = null)
 {
     // setup up standard concrete5 routing.
     $trimmed_path = trim($path, '/');
     if (!$handle) {
         $handle = preg_replace('/[^A-Za-z0-9\\_]/', '_', $trimmed_path);
         $handle = preg_replace('/\\_+/', '_', $handle);
         $handle = trim($handle, '_');
     }
     $path = '/' . $trimmed_path . '/';
     if ($callback instanceof \Closure) {
         $attributes = ClosureRouteCallback::getRouteAttributes($callback);
     } else {
         if ($callback == 'dispatcher') {
             $attributes = DispatcherRouteCallback::getRouteAttributes($callback);
         } else {
             $attributes = ControllerRouteCallback::getRouteAttributes($callback);
         }
     }
     $attributes['path'] = $path;
     $route = new Route($path, $attributes, $requirements, $options, $host, $schemes, $methods, $condition);
     $this->collection->add($handle, $route);
     return $route;
 }