本文整理汇总了PHP中CakeRoute类的典型用法代码示例。如果您正苦于以下问题:PHP CakeRoute类的具体用法?PHP CakeRoute怎么用?PHP CakeRoute使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CakeRoute类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:jeremyharris,项目名称:cakephp-newrelic,代码行数:32,代码来源:NewRelicFilter.php
示例2: __construct
/**
* Constructor for a Route.
*
* @param string $template Template string with parameter placeholders
* @param array $defaults Array of defaults for the route.
* @param array $options Array of parameters and additional options for the Route
*
* @return \CakeRoute
*/
public function __construct($template, $defaults = array(), $options = array())
{
if (strpos($template, ':current_tenant') === false && empty($options['disableAutoNamedLang'])) {
Router::connect($template, $defaults + array('current_tenant' => Configure::read('Config.current_tenant')), array('routeClass' => $this->name) + $options);
$options += array('__promote' => true);
$template = '/:current_tenant' . $template;
}
$options = array_merge((array) $options, array('current_tenant' => '[a-z]{1,10}'));
if ($template == '/:current_tenant/') {
$template = '/:current_tenant';
}
parent::__construct($template, $defaults, $options);
}
开发者ID:waldemarnt,项目名称:cake-multi-tenant,代码行数:22,代码来源:MultiTenantRouter.php
示例3: match
/**
* Checks if an URL array matches this route instance
*
* @param array $url An array of parameters to check matching with.
* @return mixed Either a string URL for the parameters if they match or false.
* @see CakeRoute::match()
*/
public function match($url)
{
if (isset($url['prefix']) && isset($url['action'])) {
$prefix = $url['prefix'];
$url['prefix'] = str_replace('_', '.', $url['prefix']);
$url['action'] = str_replace($prefix . '_', '', $url['action']);
}
$match = parent::match($url);
if ($match && isset($url['action']) && $url['action'] == 'index') {
$match = str_replace('/index', '', $match);
}
return $match;
}
开发者ID:saydulk,项目名称:croogo,代码行数:20,代码来源:ApiRoute.php
示例4: testParseTrailingUTF8
/**
* Test the /** special type on parsing - UTF8.
*
* @return void
*/
public function testParseTrailingUTF8()
{
$route = new CakeRoute('/category/**', array('controller' => 'categories', 'action' => 'index'));
$result = $route->parse('/category/%D9%85%D9%88%D8%A8%D8%A7%DB%8C%D9%84');
$expected = array('controller' => 'categories', 'action' => 'index', 'pass' => array('موبایل'), 'named' => array());
$this->assertEquals($expected, $result);
}
开发者ID:pritten,项目名称:SmartCitizen.me,代码行数:12,代码来源:CakeRouteTest.php
示例5: testUTF8PatternOnSection
/**
* test that utf-8 patterns work for :section
*
* @return void
*/
public function testUTF8PatternOnSection()
{
$route = new CakeRoute('/:section', array('plugin' => 'blogs', 'controller' => 'posts', 'action' => 'index'), array('persist' => array('section'), 'section' => 'آموزش|weblog'));
$result = $route->parse('/%D8%A2%D9%85%D9%88%D8%B2%D8%B4');
$expected = array('section' => 'آموزش', 'plugin' => 'blogs', 'controller' => 'posts', 'action' => 'index', 'pass' => array(), 'named' => array());
$this->assertEquals($expected, $result);
$result = $route->parse('/weblog');
$expected = array('section' => 'weblog', 'plugin' => 'blogs', 'controller' => 'posts', 'action' => 'index', 'pass' => array(), 'named' => array());
$this->assertEquals($expected, $result);
}
开发者ID:jgera,项目名称:orangescrum,代码行数:15,代码来源:CakeRouteTest.php
示例6: testPatternOnAction
/**
* Testing that patterns on the :action param work properly.
*
* @return void
*/
public function testPatternOnAction()
{
$route = new CakeRoute('/blog/:action/*', array('controller' => 'blog_posts'), array('action' => 'other|actions'));
$result = $route->match(array('controller' => 'blog_posts', 'action' => 'foo'));
$this->assertFalse($result);
$result = $route->match(array('controller' => 'blog_posts', 'action' => 'actions'));
$this->assertEquals('/blog/actions/', $result);
$result = $route->parse('/blog/other');
$expected = array('controller' => 'blog_posts', 'action' => 'other', 'pass' => array(), 'named' => array());
$this->assertEquals($expected, $result);
$result = $route->parse('/blog/foobar');
$this->assertFalse($result);
}
开发者ID:nabeelio,项目名称:CakePHP-Base,代码行数:18,代码来源:RouterTest.php
示例7: 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;
}
开发者ID:bmilesp,项目名称:multi-tenancy,代码行数:33,代码来源:DomainRoute.php
示例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();
}
开发者ID:MrGrigorev,项目名称:reserva-de-salas,代码行数:33,代码来源:RedirectRoute.php
示例9: 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;
}
开发者ID:andrecavallari,项目名称:thumbs,代码行数:29,代码来源:ThumbsRoute.php
示例10: 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();
}
开发者ID:no2key,项目名称:Web-Framework-Benchmark,代码行数:34,代码来源:redirect_route.php
示例11: parse
public function parse($url)
{
$params = parent::parse($url);
if (empty($params)) {
return false;
}
return false;
}
开发者ID:josephbergdoll,项目名称:berrics,代码行数:8,代码来源:CanteenRoute.php
示例12: match
/**
* Reverse route plugin shortcut URLs. If the plugin and controller
* are not the same the match is an auto fail.
*
* @param array $url Array of parameters to convert to a string.
* @return mixed either false or a string URL.
*/
public function match($url) {
if (isset($url['controller']) && isset($url['plugin']) && $url['plugin'] != $url['controller']) {
return false;
}
$this->defaults['controller'] = $url['controller'];
$result = parent::match($url);
unset($this->defaults['controller']);
return $result;
}
开发者ID:hungnt88,项目名称:5stars-1,代码行数:16,代码来源:PluginShortRoute.php
示例13: match
public function match($params)
{
$subdomain = isset($params['subdomain']) ? $params['subdomain'] : '';
unset($params['subdomain']);
$path = parent::match($params);
$domain = $this->_getDomain();
if ($subdomain) {
$path = 'http://' . $subdomain . '.' . $domain . $path;
}
return $path;
}
开发者ID:beyondkeysystem,项目名称:testone,代码行数:11,代码来源:SubdomainRoute.php
示例14: _writeUrl
public function _writeUrl($params)
{
print_r($params);
$params['subdomain'] = isset($params['subdomain']) ? strtolower($params['subdomain']) : 'www';
$out = parent::_writeUrl($params);
if (!defined('MYDOMAIN')) {
return $out;
}
$out = substr($out, strpos($out, '/') + 1);
$out = substr($out, strpos($out, '/'));
return $params['subdomain'] == 'www' ? false : 'http://' . $params['subdomain'] . '.' . MYDOMAIN . $out;
}
开发者ID:beyondkeysystem,项目名称:testone,代码行数:12,代码来源:SubdomainRoute+copy.php
示例15: match
/**
* Skips pattern checking if invoked with Router::url(array(..., 'skipPatterns' => true));
*
* @param array $url
* @return mixed|void
*/
public function match($url)
{
if ($this->skipPatterns) {
$originalOptions = $this->options;
$this->options = array();
$res = parent::match($url);
$this->options = $originalOptions;
return $res;
} else {
return parent::match($url);
}
}
开发者ID:slachiewicz,项目名称:_mojePanstwo-API-Server,代码行数:18,代码来源:ApiRoute.php
示例16: 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;
}
开发者ID:josephbergdoll,项目名称:berrics,代码行数:12,代码来源:ProfilesRoute.php
示例17: 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;
}
开发者ID:RobertWHurst,项目名称:Telame,代码行数:13,代码来源:slug_route.php
示例18: _writeUrl
/**
* Writes out full url with protocol and subdomain
*
* @param $params
* @return string
*/
protected function _writeUrl($params)
{
$protocol = $this->options['protocol'];
// $subdomain = AuthComponent::user('subdomain');
$subdomain = isset($params['subdomain']) ? $params['subdomain'] : null;
unset($params['subdomain']);
if (empty($subdomain)) {
$subdomain = 'www';
}
$domain = $this->_getDomain();
$url = parent::_writeUrl($params);
return "{$protocol}://{$subdomain}.{$domain}{$url}";
}
开发者ID:beyondkeysystem,项目名称:testone,代码行数:19,代码来源:UserSubdomainRoute+GOOD.php
示例19: parse
function parse($url)
{
// import the session controller so we can check if they're logged in or not
App::import('Component', 'Session');
$Session = new SessionComponent();
// check the login
if ($Session->check('Auth.User.email')) {
// logged in, parse params and return
return parent::parse($url);
} else {
// not logge in, return false
return false;
}
}
开发者ID:RobertWHurst,项目名称:Telame,代码行数:14,代码来源:home_route.php
示例20: parse
public function parse($url)
{
$params = parent::parse($url);
App::import("Model", "Dailyop");
$Dailyop = new Dailyop();
if (count($params['pass']) <= 0 && !isset($params['named']['datein'])) {
//$params['named']['datein'] = $Dailyop->getNewsDate();
//return $params;
}
if (isset($params['named']['datein']) && !preg_match('/([0-9]{4})(\\-)([0-9]{2})(\\-)([0-9]{2})/', $params['named']['datein'])) {
throw new NotFoundException("Invalid News Date");
}
//validate the date
//$params['named']['datein'] = $Dailyop->validateNewsDateRoute($params['named']['datein']);
return $params;
}
开发者ID:josephbergdoll,项目名称:berrics,代码行数:16,代码来源:NewsRoute.php
注:本文中的CakeRoute类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论