/** * {@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; }
/** * {@inheritDoc} */ protected function parse($path) { $matches = null; $parts = array_filter(explode($this->structureDelimiter, $path)); //$count = count($parts); if ($parts) { $term = array_shift($parts); // /list/<root-id> if ('list' == $term) { if ($parts && is_numeric($parts[0])) { $matches = array('controller' => 'list', 'action' => 'root', 'root' => (int) array_shift($parts)); } // /post/<post-id> } elseif ('post' == $term) { if ($parts && is_numeric($parts[0])) { $matches = array('controller' => 'post', 'action' => 'index', 'id' => (int) array_shift($parts)); } } if ($matches && $parts) { $matches = array_merge($matches, $this->parseParams($parts)); } } if (null !== $matches) { $matches = array_merge($this->defaults, $matches); } else { $path = $this->defaults['module'] . $this->structureDelimiter . $path; $matches = parent::parse($path); } return $matches; }
/** * {@inheritDoc} */ protected function parse($path) { $matches = null; $parts = array(); if ($path) { $parts = array_filter(explode($this->structureDelimiter, $path)); } if ($parts) { $matches = array(); $term = array_shift($parts); switch ($term) { // /home/<...> case 'home': $matches['controller'] = 'home'; $matches['action'] = 'index'; if ($parts) { // /home/<uid> if (is_numeric($parts[0])) { $matches['action'] = 'view'; $matches[$this->paramId] = (int) array_shift($parts); // /home/identity/<...> } elseif ($this->paramIdentity == $parts[0] || $this->paramName == $parts[0]) { $matches['action'] = 'view'; } else { // Do nothing but leave to user own page } } break; // /profile/<...> // /profile/<...> case 'profile': $matches['controller'] = 'profile'; $matches['action'] = 'index'; if ($parts) { // /profile/<id> if (is_numeric($parts[0])) { $matches['action'] = 'view'; $matches[$this->paramId] = (int) array_shift($parts); // /profile/identity/<...> } elseif ($this->paramIdentity == $parts[0] || $this->paramName == $parts[0]) { $matches['action'] = 'view'; // /profile/<action>/<...> } else { $matches['action'] = array_shift($parts); } } break; // /logout // /logout case 'logout': $matches['controller'] = 'login'; $matches['action'] = 'logout'; break; default: $matches = null; break; } if (null !== $matches && $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; $matches = parent::parse($path); } // Transform id to uid if (isset($matches['id']) && 'id' != $this->paramId) { $matches[$this->paramId] = $matches['id']; unset($matches['id']); } return $matches; }