当前位置: 首页>>代码示例>>PHP>>正文


PHP Route::cache方法代码示例

本文整理汇总了PHP中Route::cache方法的典型用法代码示例。如果您正苦于以下问题:PHP Route::cache方法的具体用法?PHP Route::cache怎么用?PHP Route::cache使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Route的用法示例。


在下文中一共展示了Route::cache方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: cache

 public static function cache($save = FALSE, $append = FALSE)
 {
     if ($save === TRUE) {
         try {
             JsonApiApplication::cache('Route::cache()', Route::$_routes);
         } catch (Exception $e) {
             throw new JsonApiApplication_Exception('One or more routes could not be cached (:message)', array(':message' => $e->getMessage()), 0, $e);
         }
     } else {
         if ($routes = JsonApiApplication::cache('Route::cache()')) {
             if ($append) {
                 Route::$_routes += $routes;
             } else {
                 Route::$_routes = $routes;
             }
             return Route::$cache = TRUE;
         } else {
             return Route::$cache = FALSE;
         }
     }
 }
开发者ID:benshez,项目名称:DreamWeddingCeremomies,代码行数:21,代码来源:Route.php

示例2: Kohana_Log_File

Kohana::$log->attach(new Kohana_Log_File(APPPATH . 'logs'));
/**
 * Attach a file reader to config. Multiple readers are supported.
 */
Kohana::$config->attach(new Kohana_Config_File());
/**
 * Enable modules. Modules are referenced by a relative or absolute path.
 */
Kohana::modules(array());
/**
 * Set the routes. Each route must have a minimum of a name, a URI and a set of
 * defaults for the URI.
 */
// if ( ! Route::cache())
// {
Route::set('cron', 'cron/injest')->defaults(array('controller' => 'cron', 'action' => 'injest'));
Route::set('default', '(<controller>(/<action>(/<id>)))')->defaults(array('controller' => 'front', 'action' => 'index'));
// Save the routes to cache
Route::cache(TRUE);
// }
/**
 * Execute the main request. A source of the URI can be passed, eg: $_SERVER['PATH_INFO'].
 * If no source is specified, the URI will be automatically detected.
 */
if (!defined('SUPPRESS_REQUEST')) {
    try {
        echo Request::instance($_SERVER['PATH_INFO'])->execute()->send_headers()->body();
    } catch (Exception $e) {
        throw $e;
    }
}
开发者ID:samsoir,项目名称:twongo,代码行数:31,代码来源:bootstrap.php

示例3: Log_File

    Kohana::$log->attach(new Log_File(APPPATH . 'logs'));
}
/**
 * Default path for uploads directory.
 * Path are referenced by a relative or absolute path.
 */
Upload::$default_directory = APPPATH . 'uploads';
/**
 * Set the routes
 *
 * Each route must have a minimum of a name,
 * a URI and a set of defaults for the URI.
 *
 * Example:
 * ~~~
 *	Route::set('frontend/page', 'page(/<action>)')
 *		->defaults(array(
 *			'controller' => 'page',
 *			'action' => 'view',
 *	));
 * ~~~
 *
 * @uses  Path::lookup
 * @uses  Route::cache
 * @uses  Route::set
 */
if (!Route::cache()) {
    Route::set('default', '(<controller>(/<action>(/<id>)))')->filter('Path::lookup')->defaults(array('controller' => 'welcome', 'action' => 'index'));
    // Cache the routes in production
    Route::cache(Kohana::$environment === Kohana::PRODUCTION);
}
开发者ID:MenZil-Team,项目名称:cms,代码行数:31,代码来源:bootstrap.php

示例4: cache

 /**
  * Saves or loads the route cache. If your routes will remain the same for
  * a long period of time, use this to reload the routes from the cache
  * rather than redefining them on every page load.
  *
  *     if ( ! Route::cache())
  *     {
  *         // Set routes here
  *         Route::cache(TRUE);
  *     }
  *
  * @param   boolean $save   cache the current routes
  * @param   boolean $append append, rather than replace, cached routes when loading
  * @return  void    when saving routes
  * @return  boolean when loading routes
  * @uses    Kohana::cache
  */
 public static function cache($save = FALSE, $append = FALSE)
 {
     if ($save === TRUE) {
         try {
             // Cache all defined routes
             Kohana::cache('Route::cache()', Route::$_routes);
         } catch (Exception $e) {
             // We most likely have a lambda in a route, which cannot be cached
             throw new Kohana_Exception('One or more routes could not be cached (:message)', array(':message' => $e->getMessage()), 0, $e);
         }
     } else {
         if ($routes = Kohana::cache('Route::cache()')) {
             if ($append) {
                 // Append cached routes
                 Route::$_routes += $routes;
             } else {
                 // Replace existing routes
                 Route::$_routes = $routes;
             }
             // Routes were cached
             return Route::$cache = TRUE;
         } else {
             // Routes were not cached
             return Route::$cache = FALSE;
         }
     }
 }
开发者ID:BenjaminRomeo,项目名称:KohanaTest,代码行数:44,代码来源:Route.php

示例5: defined

<?php

defined('SYSPATH') or die('No direct script access.');
if (!Route::cache()) {
    Route::set('b_settings', ADMIN . '/settings(/<action>)', ['action' => 'i18n'])->defaults(['directory' => 'Settings/Backend', 'controller' => 'page', 'action' => 'edit']);
}
开发者ID:eok8177,项目名称:shopCMS,代码行数:6,代码来源:init.php

示例6: cache

 /**
  * Saves or loads the route cache. If your routes will remain the same for
  * a long period of time, use this to reload the routes from the cache
  * rather than redefining them on every page load.
  *
  *     if ( ! Route::cache())
  *     {
  *         // Set routes here
  *         Route::cache(TRUE);
  *     }
  *
  * @param   boolean   cache the current routes
  * @return  void      when saving routes
  * @return  boolean   when loading routes
  * @uses    Kohana::cache
  */
 public static function cache($save = FALSE)
 {
     if ($save === TRUE) {
         // Cache all defined routes
         Kohana::cache('Route::cache()', Route::$_routes);
     } else {
         if ($routes = Kohana::cache('Route::cache()')) {
             Route::$_routes = $routes;
             // Routes were cached
             return Route::$cache = TRUE;
         } else {
             // Routes were not cached
             return Route::$cache = FALSE;
         }
     }
 }
开发者ID:gilyaev,项目名称:framework-bench,代码行数:32,代码来源:route.php

示例7: test_cache_returns_false_if_cache_dnx

 /**
  * Route::cache() should return FALSE if cached routes could not be found
  *
  * The cache is cleared before and after each test in setUp tearDown
  * by cleanCacheDir()
  *
  * @test
  * @covers Route::cache
  */
 public function test_cache_returns_false_if_cache_dnx()
 {
     $this->assertSame(FALSE, Route::cache(), 'Route cache was not empty');
     // Check the route cache flag
     $this->assertFalse(Route::$cache);
 }
开发者ID:robert-kampas,项目名称:games-collection-manager,代码行数:15,代码来源:RouteTest.php

示例8: test_cache_returns_false_if_cache_dnx

 /**
  * Route::cache() should return FALSE if cached routes could not be found
  *
  * The cache is cleared before and after each test in setUp tearDown 
  * by clean_cache_dir()
  * 
  * @test
  * @covers Route::cache
  */
 public function test_cache_returns_false_if_cache_dnx()
 {
     $this->assertSame(FALSE, Route::cache(), 'Route cache was not empty');
 }
开发者ID:joelpittet,项目名称:core,代码行数:13,代码来源:RouteTest.php

示例9: define

if (!defined('REST_URL_FORMAT_RESOURCE')) {
    define('REST_URL_FORMAT_RESOURCE', '[a-zA-Z][a-zA-Z0-9_\\./]*');
}
if (!defined('REST_LOG_DIR')) {
    define('REST_LOG_DIR', Arr::get($_SERVER, 'REST_LOG_DIR', LOG_TMP_DIR));
}
if (!defined('REST_METRIC_NAMESPACE')) {
    define('REST_METRIC_NAMESPACE', Arr::get($_SERVER, 'REST_METRIC_NAMESPACE', null));
}
if (!defined('REST_PRODUCT_CONFIG_DIR')) {
    define('REST_PRODUCT_CONFIG_DIR', Arr::get($_SERVER, 'REST_PRODUCT_CONFIG_DIR', null));
}
if (!defined('RESOURCE_QUERY_LIMIT_DEFAULT')) {
    define('RESOURCE_QUERY_LIMIT_DEFAULT', Arr::get($_SERVER, 'RESOURCE_QUERY_LIMIT_DEFAULT', 10));
}
if (!defined('RESOURCE_QUERY_LIMIT_MAX')) {
    define('RESOURCE_QUERY_LIMIT_MAX', Arr::get($_SERVER, 'RESOURCE_QUERY_LIMIT_MAX', 100));
}
if (!Kohana::$errors && 'cli' !== php_sapi_name()) {
    set_exception_handler(array('Rest_Exception', 'handler'));
    set_error_handler(array('Rest_Error', 'handler'));
    register_shutdown_function(array('Rest_Error', 'shutdown_handler'));
}
/**
 * Cache Routes.
 */
if (!Route::cache()) {
    include __DIR__ . DIRECTORY_SEPARATOR . 'routes.php';
    // Cache the routes in Production
    Route::cache(Kohana::PRODUCTION === Kohana::$environment || Kohana::STAGING === Kohana::$environment);
}
开发者ID:gianebao,项目名称:kohana-rest,代码行数:31,代码来源:init.php


注:本文中的Route::cache方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。