public function match($params) { if (!$this->_match($params)) { return false; } if (isset($params[0])) { $id = $params[0]; $slugs = $this->_read(); if (isset($slugs[$id])) { $slug = $slugs[$id]; } elseif ($this->_validateType($this->_getModel(), $id) && ($result = $this->_lookup(array($this->lookup => $id)))) { $slug = $result[$this->_getModel()->alias][$this->display]; } if (isset($slug)) { $params[$this->named] = $this->_urlencode ? rawurlencode($slug) : $slug; unset($params[0]); $params = $this->_normalizePass($params); return parent::match($params); } } return false; }
public function parse($url) { $params = parent::parse($url); // get cake standard if (empty($params) || !$this->_match($params)) { return false; } $slugs = array(); foreach ($this->_slugOptions as $slug => $options) { if (!isset($params[$slug])) { return false; } $slugs[$slug] = $params[$slug]; unset($params[$slug]); $callbacks = $this->getOption('callbacks', $options); if ($callbacks['parse'] !== false) { $slugs[$slug] = $callbacks['parse']($slugs[$slug]); } } if (!($id = $this->mapped($slugs))) { $result = $this->_lookup($this->_generateScope($slugs)); if (!$result) { return false; } $id = $result[$this->_getModel()->alias][$this->_getModel()->primaryKey]; $this->map($id, $slugs); } if (empty($params['pass'])) { $params['pass'] = array(); } $params['pass'][] = $id; return $params; }