Esempio n. 1
0
 /**
  * {@inheritDoc}
  */
 protected function parse($path)
 {
     $matches = null;
     $parts = array();
     if ($path) {
         $parts = array_filter(explode($this->structureDelimiter, $path));
     }
     if ($parts) {
         $matches = array();
         $matches['controller'] = 'index';
         $term = array_shift($parts);
         if ('service' == $term) {
             $matches['controller'] = 'index';
             $matches['action'] = 'service';
             if ($parts) {
                 $matches['service'] = $parts[0];
             }
         } else {
             $matches['action'] = 'module';
             $matches['m'] = $term;
         }
         if ($parts) {
             $matches = array_merge((array) $matches, $this->parseParams($parts));
         }
     }
     if (null !== $matches) {
         $matches = array_merge($this->defaults, $matches);
     } else {
         //$path = $this->defaults['module'] . $this->structureDelimiter . $path;
         $path = $this->prefix . $this->structureDelimiter . $path;
         $matches = parent::parse($path);
     }
     return $matches;
 }
Esempio n. 2
0
 /**
  * {@inheritDoc}
  */
 public function assemble(array $params = array(), array $options = array())
 {
     if (!$params) {
         return $this->prefix;
     }
     $url = null;
     // Transform uid to id
     if (isset($params[$this->paramId]) && 'id' != $this->paramId) {
         $params['id'] = $params[$this->paramId];
         unset($params[$this->paramId]);
     }
     $controller = isset($params['controller']) ? $params['controller'] : '';
     $action = isset($params['action']) ? $params['action'] : '';
     // /logout
     if ('logout' == $action) {
         $url = 'logout';
         // /<...>
     } elseif ('' == $controller || 'index' == $controller) {
         $url = '';
         // /home/<...>
     } elseif ('home' == $controller) {
         if ('' == $action || 'index' == $action || 'view' == $action) {
             // /home
             $url = 'home';
             // /home/<id>
             if (!empty($params['id'])) {
                 $url .= $this->paramDelimiter . $params['id'];
                 unset($params['id']);
             }
         }
         // /profile/<...>
     } elseif ('profile' == $controller) {
         if ('' == $action || 'index' == $action || 'view' == $action) {
             // /profile
             $url = 'profile';
             // /profile/<id>
             if (!empty($params['id'])) {
                 $url .= $this->paramDelimiter . $params['id'];
                 unset($params['id']);
             }
         }
     }
     if (null !== $url) {
         $part = $this->assembleParams($params);
         $url .= $part ? $this->paramDelimiter . $part : '';
         $url = $url ? $this->prefix . $this->paramDelimiter . $url : $this->prefix;
     } else {
         $params['module'] = $this->defaults['module'];
         $url = parent::assemble($params, $options);
         $urlPrefix = $this->prefix . $this->paramDelimiter . $this->defaults['module'];
         $urlSuffix = substr($url, strlen($urlPrefix));
         $url = $this->prefix . $urlSuffix;
     }
     return $url;
 }
Esempio n. 3
0
 /**
  * {@inheritDoc}
  */
 public function assemble(array $params = array(), array $options = array())
 {
     $mergedParams = array_merge($this->defaults, $params);
     $url = '';
     if (!empty($mergedParams['slug'])) {
         $url = $this->encode($mergedParams['slug']);
     } elseif (!empty($mergedParams['name'])) {
         $url = $this->encode($mergedParams['name']);
     } elseif (!empty($mergedParams['id'])) {
         $url = (int) $mergedParams['id'];
     }
     if (empty($url)) {
         return $this->prefix;
     }
     $params = array();
     $prefix = $this->prefix;
     $this->prefix .= $this->paramDelimiter . $url;
     $url = parent::assemble($params, $options);
     $this->prefix = $prefix;
     return $url;
 }
Esempio n. 4
0
 /**
  * assemble(): Defined by Route interface.
  *
  * @see    Route::assemble()
  * @param  array $params
  * @param  array $options
  * @return string
  */
 public function assemble(array $params = array(), array $options = array())
 {
     if (!$params) {
         return $this->prefix;
     }
     $url = null;
     $controller = isset($params['controller']) ? $params['controller'] : '';
     $action = isset($params['action']) ? $params['action'] : '';
     // /list/<root-id>
     if ('list' == $controller) {
         if ('' == $action || 'root' == $action) {
             if (!empty($params['root'])) {
                 $url .= 'list' . $this->paramDelimiter . $params['root'];
                 unset($params['root']);
             }
         }
         // /post/<post-id>
     } elseif ('post' == $controller) {
         if ('' == $action || 'index' == $action) {
             if (!empty($params['id'])) {
                 $url .= 'post' . $this->paramDelimiter . $params['id'];
                 unset($params['id']);
             }
         }
     }
     if ($url) {
         $part = $this->assembleParams($params);
         $url .= $part ? $this->paramDelimiter . $part : '';
         $url = $this->prefix . $this->paramDelimiter . $url;
     } else {
         $params['module'] = $this->defaults['module'];
         $url = parent::assemble($params, $options);
         $urlPrefix = $this->prefix . $this->paramDelimiter . $this->defaults['module'];
         $urlSuffix = substr($url, strlen($urlPrefix));
         $url = $this->prefix . $urlSuffix;
     }
     return $url;
 }