本文整理汇总了PHP中CakeRoute::parse方法的典型用法代码示例。如果您正苦于以下问题:PHP CakeRoute::parse方法的具体用法?PHP CakeRoute::parse怎么用?PHP CakeRoute::parse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CakeRoute
的用法示例。
在下文中一共展示了CakeRoute::parse方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: beforeDispatch
/**
* Handles current transaction
*
* @param CakeEvent $event Dispatch event
* @return true
*/
public function beforeDispatch(CakeEvent $event)
{
$request = $event->data['request'];
$response = $event->data['response'];
if (!$this->hasNewRelic()) {
return true;
}
// Set NewRelic appName
$appName = Configure::read('NewRelic.appName');
if (!empty($appName)) {
$this->setAppName($appName);
}
$ignored = Configure::read('NewRelic.ignoreRoutes');
$url = '/' . $event->data['request']->url;
if (!empty($ignored)) {
foreach ($ignored as $ignoreTest) {
$cakeRoute = new CakeRoute($ignoreTest);
if ($cakeRoute->parse($url) !== false) {
$this->ignoreTransaction();
continue;
}
}
}
$this->nameTransaction($request->controller . '/' . $request->action);
return true;
}
示例2: parse
/**
* Checks to see if the given URL can be parsed by this route.
* If the route can be parsed an array of parameters will be returned; if
* not `false` will be returned.
*
* @param string $url The url to attempt to parse.
* @return mixed Boolean false on failure, otherwise an array or parameters
*/
public function parse($url)
{
$conditionResult = $callbackFunction = null;
if (isset($this->options['condition'])) {
$conditionFunctions = !is_array($this->options['condition']) ? array($this->options['condition']) : $this->options['condition'];
foreach ($conditionFunctions as $conditionFunction) {
$tempResult = call_user_func($conditionFunction, $url, $this);
if ($tempResult == false) {
$conditionResult = false;
break;
}
}
}
if (isset($this->options['callback']) && is_callable($this->options['callback'])) {
$callbackFunction = $this->options['callback'];
unset($this->options['callback']);
}
$params = parent::parse($url);
if (!$params) {
return false;
}
if ($conditionResult === false) {
return false;
}
if (!is_null($callbackFunction)) {
$params = call_user_func($callbackFunction, $params);
}
return $params;
}
示例3: parse
public function parse($url)
{
$params = parent::parse($url);
if (empty($params)) {
return false;
}
$path = realpath(implode(DS, $params['pass']));
if (empty($path)) {
return false;
}
$thumb = str_replace(array('/', '\\', '\\\\'), DS, WWW_ROOT . $url);
$config = realpath(APP . 'Config/thumbs.php') ? include realpath(APP . 'Config/thumbs.php') : (include realpath(APP . 'Plugin/Thumbs/Config/thumbs.php'));
switch ($params['action']) {
case "crop":
$image = $this->_crop($config, $path, $params, $thumb);
break;
case "resize":
$image = $this->_resize($config, $path, $params, $thumb);
break;
case "fill":
$image = $this->_fill($config, $path, $params, $thumb);
break;
}
if (empty($image)) {
return false;
}
$params['image'] = $image;
return $params;
}
示例4: parse
/**
* Parses a string url into an array. Parsed urls will result in an automatic
* redirection
*
* @param string $url The url to parse
* @return boolean False on failure
*/
public function parse($url)
{
$params = parent::parse($url);
if (!$params) {
return false;
}
if (!$this->response) {
$this->response = new CakeResponse();
}
$redirect = $this->defaults;
if (count($this->defaults) == 1 && !isset($this->defaults['controller'])) {
$redirect = $this->defaults[0];
}
if (isset($this->options['persist']) && is_array($redirect)) {
$argOptions['context'] = array('action' => $redirect['action'], 'controller' => $redirect['controller']);
$args = Router::getArgs($params['_args_'], $argOptions);
$redirect += $args['pass'];
$redirect += $args['named'];
}
$status = 301;
if (isset($this->options['status']) && ($this->options['status'] >= 300 && $this->options['status'] < 400)) {
$status = $this->options['status'];
}
$this->response->header(array('Location' => Router::url($redirect, true)));
$this->response->statusCode($status);
$this->response->send();
}
示例5: parse
/**
* Parses a string url into an array. Parsed urls will result in an automatic
* redirection
*
* @param string $url The url to parse
* @return boolean False on failure
*/
public function parse($url)
{
$params = parent::parse($url);
if ($params === false) {
return false;
}
$Domains = new Domains();
$subdomain = $Domains->getSubdomain();
$masterDomain = Configure::read('Domain.Master');
$defaultRoute = Configure::read('Domain.DefaultRoute');
$Tenant = new Tenant();
if (!$Tenant->domainExists($subdomain) && $params != $defaultRoute) {
if (!$this->response) {
$this->response = new CakeResponse();
}
debug($this->response);
die;
$status = 307;
$redirect = $defaultRoute;
$this->response->header(array('Location' => Router::url($redirect, true)));
$this->response->statusCode($status);
$this->response->send();
$this->_stop();
}
return $subdomain;
}
示例6: parse
/**
* Override the parsing function to find an id based on a slug
*
* @param string $url Url string
* @return boolean
*/
public function parse($url)
{
$params = parent::parse($url);
if (empty($params)) {
return false;
}
if (!empty($this->models) && !empty($params['pass'])) {
foreach ($this->models as $modelName => $options) {
list($paramType, $paramName) = $this->params($options);
$slugSet = $this->getSlugs($modelName);
if (empty($slugSet)) {
continue;
}
$slugSet = array_flip($slugSet);
foreach ($params['pass'] as $key => $param) {
if (isset($slugSet[$param])) {
unset($params['pass'][$key]);
if ($paramType == 'pass' && !is_numeric($paramName)) {
$params[$paramName] = $slugSet[$param];
$params[$paramType][$key] = $slugSet[$param];
} else {
$params[$paramType][$paramName] = $slugSet[$param];
}
}
}
}
return $params;
}
return false;
}
示例7: parse
/**
* Override the parsing function to find an id based on a slug
*
* @param string $url Url string
* @return boolean
*/
public function parse($url)
{
$params = parent::parse($url);
if (empty($params)) {
return false;
}
if (isset($this->options['models']) && !empty($params['pass'])) {
foreach ($this->options['models'] as $checkNamed => $slugField) {
if (is_numeric($checkNamed)) {
$checkNamed = $slugField;
$slugField = null;
}
$slugSet = $this->getSlugs($checkNamed, $slugField);
if (empty($slugSet)) {
continue;
}
$slugSet = array_flip($slugSet);
foreach ($params['pass'] as $key => $pass) {
if (isset($slugSet[$pass])) {
unset($params['pass'][$key]);
$params['named'][$checkNamed] = $slugSet[$pass];
}
}
}
return $params;
}
return false;
}
示例8: parse
/**
* Parses a string url into an array. Parsed urls will result in an automatic
* redirection
*
* @param string $url The url to parse
* @return boolean False on failure
*/
public function parse($url)
{
$params = parent::parse($url);
if (!$params) {
return false;
}
if (!$this->response) {
$this->response = new CakeResponse();
}
$redirect = $this->redirect;
if (count($this->redirect) == 1 && !isset($this->redirect['controller'])) {
$redirect = $this->redirect[0];
}
if (isset($this->options['persist']) && is_array($redirect)) {
$redirect += array('named' => $params['named'], 'pass' => $params['pass'], 'url' => array());
$redirect = Router::reverse($redirect);
}
$status = 301;
if (isset($this->options['status']) && ($this->options['status'] >= 300 && $this->options['status'] < 400)) {
$status = $this->options['status'];
}
$this->response->header(array('Location' => Router::url($redirect, true)));
$this->response->statusCode($status);
$this->response->send();
$this->_stop();
}
示例9: parse
public function parse($url)
{
if (defined('MYDOMAIN')) {
$subdomain = substr(env("HTTP_HOST"), 0, strpos(env("HTTP_HOST"), "." . MYDOMAIN));
$url = '/' . $subdomain . $url;
}
return $subdomain == 'www' ? false : parent::parse($url);
}
示例10: parse
public function parse($url)
{
$params = parent::parse($url);
if (empty($params)) {
return false;
}
return false;
}
示例11: parse
/**
* Parses a string URL into an array. If a plugin key is found, it will be copied to the
* controller parameter
*
* @param string $url The URL to parse
* @return mixed false on failure, or an array of request parameters
*/
public function parse($url) {
$params = parent::parse($url);
if (!$params) {
return false;
}
$params['controller'] = $params['plugin'];
return $params;
}
示例12: parse
/**
* Checks wether URL is an API route
*
* If the route is not an API route, we return false and let the next parser
* to handle it.
*
* @param string $url The URL to attempt to parse.
* @return mixed Boolean false on failure, otherwise an array or parameters
* @see CakeRoute::parse()
*/
public function parse($url)
{
$parsed = parent::parse($url);
if (!isset($parsed['api']) || !isset($parsed['prefix'])) {
return false;
}
$parsed['prefix'] = str_replace('.', '_', $parsed['prefix']);
return $parsed;
}
示例13: parse
public function parse($url)
{
$params = parent::parse($url);
if (empty($params)) {
return false;
}
//break up the url into pieces
$parsed_url = parse_url($_SERVER['REQUEST_URI']);
$url_p = explode("/", $parsed_url['path']);
die(print_r($params));
return false;
}
示例14: parse
public function parse($url)
{
$params = parent::parse($url);
if (!empty($params['plugin'])) {
$plugin = Inflector::camelize($params['plugin']);
$data = current(EventCore::trigger($this, $plugin . '.routeParse', $params));
if (isset($data[$plugin]) && $data[$plugin] !== null) {
return $data[$plugin];
}
}
return $params;
}
示例15: parse
function parse($url)
{
$params = parent::parse($url);
if (empty($params)) {
return false;
}
App::import('Component', 'Session');
$Session = new SessionComponent();
if ($Session->check('Auth.User.slug')) {
return $params;
}
return false;
}