defaultRouteClass() public static method

Set the default route class to use or return the current one
public static defaultRouteClass ( string $routeClass = null ) : string | null
$routeClass string The route class to set as default.
return string | null The default route class.
コード例 #1
0
ファイル: RouterTest.php プロジェクト: nabeelio/CakePHP-Base
 /**
  * Test that class must exist
  *
  * @expectedException RouterException
  * @return void
  */
 public function testSettingNonExistentDefaultRouteException()
 {
     Router::defaultRouteClass('NonExistentClass');
 }
コード例 #2
0
ファイル: routes.php プロジェクト: pkdevboxy/zumba.github.com
<?php

App::uses('ZumbaRoute', 'Routing/Route');
Router::defaultRouteClass('ZumbaRoute');
$routesFile = __DIR__ . '/routes.connect.php';
$routesHash = sha1_file($routesFile);
$cacheFile = TMP . '/routes-' . $routesHash . '.php';
if (file_exists($cacheFile)) {
    include $cacheFile;
} else {
    include $routesFile;
    // Prepare for cache
    foreach (Router::$routes as $i => $route) {
        $route->compile();
    }
    $tmpCacheFile = TMP . '/routes-' . uniqid('tmp-', true) . '.php';
    file_put_contents($tmpCacheFile, '<?php
		Router::$initialized = true;
		Router::$routes = ' . var_export(Router::$routes, true) . ';
	');
    rename($tmpCacheFile, $cacheFile);
}
Router::connectNamed(true);
コード例 #3
0
ファイル: CommonRouter.php プロジェクト: gourmet/common
 public static function reload()
 {
     $defaultRouteClass = parent::defaultRouteClass();
     parent::reload();
     parent::defaultRouteClass($defaultRouteClass);
 }
コード例 #4
0
 /**
  * Creates REST resource routes for the given controller(s).
  *
  * @param string|array $controller string or array of controller names
  * @return array Array of mapped resources
  * @see Router::mapResources()
  */
 public static function mapResources($controller, $options = array())
 {
     $options = array_merge(array('routeClass' => 'ApiRoute'), $options);
     static $defaultRouteClass;
     if (empty($defaultRouteClass)) {
         $defaultRouteClass = Router::defaultRouteClass();
     }
     Router::defaultRouteClass('ApiRoute');
     $routes = Router::mapResources($controller, $options);
     Router::defaultRouteClass($defaultRouteClass);
     return $routes;
 }
コード例 #5
0
 * @since         CakePHP(tm) v 0.2.9
 * @license       http://www.opensource.org/licenses/mit-license.php MIT License
 */
/**
 * Here, we are connecting '/' (base path) to controller called 'Pages',
 * its action called 'display', and we pass a param to select the view file
 * to use (in this case, /app/View/Pages/home.ctp)...
 */
/**
 * ...and connect the rest of 'Pages' controller's URLs.
 */
Router::connect('/docs/budget_spendings', array('controller' => 'docs', 'action' => 'save_budget_spendings'));
Router::connect('/pages/*', array('controller' => 'pages', 'action' => 'display'));
Router::connect('/docs/:id', array('controller' => 'docs', 'action' => 'save_document', '[method]' => 'POST'));
Router::connect('/docs/:id', array('controller' => 'docs', 'action' => 'view'));
Router::connect('/docs/attachments/:id', array('controller' => 'docs', 'action' => 'doc_id_from_attach'));
Router::connect('/docs/bookmarks/:id', array('controller' => 'docs', 'action' => 'bookmarks'));
Router::connect('/docs/:id/html/:package', array('controller' => 'docs', 'action' => 'html'));
/**
 * Load all plugin routes. See the CakePlugin documentation on
 * how to customize the loading of plugin routes.
 */
// load plugin routes using ApiRoute routing
App::uses('ApiRoute', 'Routing/Route');
Router::defaultRouteClass('ApiRoute');
CakePlugin::routes();
/**
 * Load the CakePHP default routes. Only remove this if you do not want to use
 * the built-in default routes.
 */
require CAKE . 'Config' . DS . 'routes.php';
コード例 #6
0
ファイル: bootstrap.php プロジェクト: gourmet/common
Configure::load('Common.config', Configure::read('Common.reader.id'));
try {
    Configure::load('config', Configure::read('Common.reader.id'));
} catch (ConfigureException $e) {
    $configPath = APP . DS . 'Config' . DS . 'config';
    if (file_exists($configPath) || file_exists($configPath . '.' . Configure::read('Common.reader.id'))) {
        throw new ConfigureException($e->getMessage());
    }
    unset($configPath);
}
/**
 * Configure routing default class.
 */
if (CakePlugin::loaded('I18n')) {
    App::uses('I18nRoute', 'I18n.Routing/Route');
    Router::defaultRouteClass('I18nRoute');
    Configure::write('Config.language', Configure::read('L10n.language'));
    Configure::write('Config.languages', Configure::read('L10n.languages'));
    if (!defined('DEFAULT_LANGUAGE')) {
        define('DEFAULT_LANGUAGE', Configure::read('L10n.language'));
    }
}
/**
 * Configure `CakeNumber` currencies.
 */
if (class_exists('CakeNumber')) {
    CakeNumber::defaultCurrency(Common::read('L10n.currency', 'USD'));
    foreach (Common::read('L10n.currencies', array()) as $currencyName => $currencyFormat) {
        CakeNumber::addFormat($currencyName, $currencyFormat);
    }
}