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


PHP sfRouting类代码示例

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


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

示例1: addRoute

 /**
  * addRoute - prepend a route to given routing object with abstraction of
  * symfony version
  *
  * @param  sfRouting $r
  * @param  string $routeName
  * @param  string $routeUrl
  * @param  array $routeParameters
  * @return void
  */
 protected static function addRoute(sfRouting $r, $routeName, $routePattern, $routeDefaults, $routeRequirements = array(), $routeOptions = array())
 {
     if (self::$newStyleRoutes) {
         $r->prependRoute(self::ROUTE . '_' . $routeName, new sfRoute($routePattern, $routeDefaults, $routeRequirements, $routeOptions));
     } else {
         $r->prependRoute(self::ROUTE . '_' . $routeName, $routePattern, $routeDefaults, $routeRequirements);
     }
 }
开发者ID:ericroge,项目名称:sfdynamicsplugin,代码行数:18,代码来源:sfDynamicsRouting.class.php

示例2: getInstance

 /**
  * Retrieve the singleton instance of this class.
  *
  * @return  sfRouting The sfRouting implementation instance
  */
 public static function getInstance()
 {
     if (!isset(self::$instance)) {
         self::$instance = new sfRouting();
     }
     return self::$instance;
 }
开发者ID:Daniel-Marynicz,项目名称:symfony1-legacy,代码行数:12,代码来源:sfRouting.class.php

示例3: loadConfiguration

 /**
  * @see sfRouting
  */
 public function loadConfiguration()
 {
     if (!is_null($this->cache) && ($routes = $this->cache->get('symfony.routing.configuration'))) {
         $this->routes = unserialize($routes);
         $this->routesFullyLoaded = false;
     } else {
         if ($this->options['load_configuration'] && ($config = sfContext::getInstance()->getConfigCache()->checkConfig('config/routing.yml', true))) {
             $this->setRoutes(include $config);
         }
         parent::loadConfiguration();
         if (!is_null($this->cache)) {
             if (!$this->options['lazy_routes_deserialize']) {
                 $this->cache->set('symfony.routing.configuration', serialize($this->routes));
             } else {
                 $lazyMap = array();
                 foreach ($this->routes as $name => $route) {
                     if (is_string($route)) {
                         $route = $this->loadRoute($name);
                     }
                     $lazyMap[$name] = serialize($route);
                 }
                 $this->cache->set('symfony.routing.configuration', serialize($lazyMap));
             }
         }
     }
 }
开发者ID:yasirgit,项目名称:afids,代码行数:29,代码来源:sfPatternRouting.class.php

示例4: setDefaultParameters

 /**
  * @see sfRouting
  */
 public function setDefaultParameters($parameters)
 {
     parent::setDefaultParameters($parameters);
     foreach ($this->routes as $route) {
         if (is_object($route)) {
             $route->setDefaultParameters($this->defaultParameters);
         }
     }
 }
开发者ID:Phennim,项目名称:symfony1,代码行数:12,代码来源:sfPatternRouting.class.php

示例5: loadConfiguration

 /**
  * @see sfRouting
  */
 public function loadConfiguration()
 {
     if ($this->options['load_configuration'] && ($config = sfContext::getInstance()->getConfigCache()->checkConfig('config/routing.yml', true))) {
         foreach (include $config as $name => $route) {
             $this->routes[$name] = $route;
         }
     }
     parent::loadConfiguration();
 }
开发者ID:bigcalm,项目名称:urlcatcher,代码行数:12,代码来源:sfPatternRouting.class.php

示例6: initializeSwitch

 /**
  * Initialize the vars for language switch
  *
  * @access protected
  * @param  void
  * @return void
  */
 protected function initializeSwitch()
 {
     if (method_exists($this->getContext(), 'getRouting')) {
         $this->routing = $this->getContext()->getRouting();
     } else {
         $this->routing = sfRouting::getInstance();
     }
     $this->request = $this->getContext()->getRequest();
     $this->languages_available = array('en' => array('title' => 'English', 'image' => '/sfLanguageSwitch/images/flag/gb.png'));
 }
开发者ID:net7,项目名称:Talia-CMS,代码行数:17,代码来源:BasesfLanguageSwitchComponents.class.php

示例7: execute

 /**
  * Executes this configuration handler.
  *
  * @param array An array of absolute filesystem path to a configuration file
  *
  * @return string Data to be written to a cache file
  *
  * @throws sfConfigurationException If a requested configuration file does not exist or is not readable
  * @throws sfParseException If a requested configuration file is improperly formatted
  */
 public function execute($configFiles)
 {
     // parse the yaml
     $config = $this->parseYamls($configFiles);
     // connect routes
     $routes = sfRouting::getInstance();
     foreach ($config as $name => $params) {
         $routes->connect($name, $params['url'] ? $params['url'] : '/', isset($params['param']) ? $params['param'] : array(), isset($params['requirements']) ? $params['requirements'] : array());
     }
     // compile data
     $retval = sprintf("<?php\n" . "// auto-generated by sfRoutingConfigHandler\n" . "// date: %s\n\$routes = sfRouting::getInstance();\n\$routes->setRoutes(\n%s\n);\n", date('Y/m/d H:i:s'), var_export($routes->getRoutes(), 1));
     return $retval;
 }
开发者ID:taryono,项目名称:school,代码行数:23,代码来源:sfRoutingConfigHandler.class.php

示例8: executeLogin

 public function executeLogin()
 {
     if ($this->getRequest()->getMethod() != sfRequest::POST) {
         $r = sfRouting::getInstance();
         if ($r->getCurrentRouteName() == 'login') {
             $this->getRequest()->setAttribute('referer', $this->getRequest()->getReferer());
         } else {
             $this->getRequest()->setAttribute('referer', $r->getCurrentInternalUri());
         }
     } else {
         $this->redirect($this->getRequestParameter('referer', '@homepage'));
     }
 }
开发者ID:noose,项目名称:Planeta,代码行数:13,代码来源:actions.class.php

示例9: loadConfiguration

 /**
  * @see sfRouting
  */
 public function loadConfiguration()
 {
     if (!is_null($this->cache) && ($routes = $this->cache->get('symfony.routing.configuration'))) {
         $this->routes = unserialize($routes);
     } else {
         if ($this->options['load_configuration'] && ($config = sfContext::getInstance()->getConfigCache()->checkConfig('config/routing.yml', true))) {
             include $config;
         }
         parent::loadConfiguration();
         if (!is_null($this->cache)) {
             $this->cache->set('symfony.routing.configuration', serialize($this->routes));
         }
     }
 }
开发者ID:ajith24,项目名称:ajithworld,代码行数:17,代码来源:sfPatternRouting.class.php

示例10: executeList

 public function executeList()
 {
     $type = $this->getRequestParameter('type', 'all');
     $c = $this->{'list' . $type}();
     $c->addDescendingOrderByColumn(PostPeer::CREATED_AT);
     $c->add(PostPeer::DELETED, false);
     $pager = new sfPropelPager('Post', sfConfig::get('app_post_per_page', 7));
     $pager->setCriteria($c);
     $pager->setPage($this->getRequestParameter('page', 1));
     $pager->setPeerMethod('doSelectJoinAll');
     $pager->init();
     $this->pager = $pager;
     $r = sfRouting::getInstance();
     $this->iuri = $r->getCurrentRouteName() == 'homepage' ? '@posts?page=1' : $r->getCurrentInternalUri(true);
 }
开发者ID:noose,项目名称:Planeta,代码行数:15,代码来源:actions.class.php

示例11: execute

  public function execute ($filterChain)
  {
    // execute next filter
    $filterChain->execute();

    $response = $this->getContext()->getResponse();

    // execute this filter only if cache is set and no GET or POST parameters
    // execute this filter not in debug mode, only if no_script_name and for 200 response code
    if (
      (!sfConfig::get('sf_cache') || count($_GET) || count($_POST))
      ||
      (sfConfig::get('sf_debug') || !sfConfig::get('sf_no_script_name') || $response->getStatusCode() != 200)
    )
    {
      return;
    }

    // only if cache is set for the entire page
    $cacheManager = $this->getContext()->getViewCacheManager();
    $uri = sfRouting::getInstance()->getCurrentInternalUri();
    if ($cacheManager->isCacheable($uri) && $cacheManager->withLayout($uri))
    {
      // save super cache
      $request = $this->getContext()->getRequest();
      $pathInfo = $request->getPathInfo();
      $file = sfConfig::get('sf_web_dir').'/'.$this->getParameter('cache_dir', 'cache').'/'.$request->getHost().('/' == $pathInfo[strlen($pathInfo) - 1] ? $pathInfo.'index.html' : $pathInfo);
      $current_umask = umask();
      umask(0000);
      $dir = dirname($file);
      if (!is_dir($dir))
      {
        mkdir($dir, 0777, true);
      }
      file_put_contents($file, $this->getContext()->getResponse()->getContent());
      chmod($file, 0666);
      umask($current_umask);
    }
  }
开发者ID:jonphipps,项目名称:Metadata-Registry,代码行数:39,代码来源:sfSuperCacheFilter.class.php

示例12: stop

 /**
  * Stops the fragment cache.
  *
  * @param string Unique fragment name
  *
  * @return boolean true, if success otherwise false
  */
 public function stop($name)
 {
     $data = ob_get_clean();
     // save content to cache
     $internalUri = sfRouting::getInstance()->getCurrentInternalUri();
     try {
         $this->set($data, $internalUri . (strpos($internalUri, '?') ? '&' : '?') . '_sf_cache_key=' . $name);
     } catch (Exception $e) {
     }
     return $data;
 }
开发者ID:Daniel-Marynicz,项目名称:symfony1-legacy,代码行数:18,代码来源:sfViewCacheManager.class.php

示例13: array

<?php

// Adding polls routes if option has not been disabled in app.yml
// @see http://www.symfony-project.com/book/trunk/09-Links-and-the-Routing-System#Creating%20Rules%20Without%20routing.yml
if (sfConfig::get('app_sfPropelPollsPlugin_routes_register', true) && in_array('sfPolls', sfConfig::get('sf_enabled_modules'))) {
    $r = sfRouting::getInstance();
    # Polls list route
    $r->prependRoute('sf_propel_polls_list', '/polls', array('module' => 'sfPolls', 'action' => 'list'), array('id' => '\\d+'));
    # Poll detail (form) route
    $r->prependRoute('sf_propel_polls_detail', '/poll_detail/:id', array('module' => 'sfPolls', 'action' => 'detail'), array('id' => '\\d+'));
    # Poll results route
    $r->prependRoute('sf_propel_polls_results', '/poll_results/:id', array('module' => 'sfPolls', 'action' => 'results'), array('id' => '\\d+'));
    # Poll vote route
    $r->prependRoute('sf_propel_polls_vote', '/poll_vote', array('module' => 'sfPolls', 'action' => 'vote'), array('id' => '\\d+'));
}
开发者ID:sgrove,项目名称:cothinker,代码行数:15,代码来源:config.php

示例14: sfGeoFeedItem

<?php

$feedItem = new sfGeoFeedItem();
$i18n = $item['ArticleI18n'][0];
$feedItem->setTitle($i18n['name']);
$id = $item['id'];
$lang = $i18n['culture'];
$feedItem->setLink("@document_by_id_lang_slug?module=articles&id={$id}&lang={$lang}&slug=" . make_slug($i18n['name']));
$feedItem->setUniqueId(sfRouting::getInstance()->getCurrentInternalUri() . '_' . $id);
$feedItem->setAuthorName($item['creator']);
$feedItem->setPubdate(strtotime($item['creation_date']));
$data = array();
$data[] = get_paginated_value_from_list($item['categories'], 'mod_articles_categories_list');
if (isset($item['activities']) && is_string($item['activities'])) {
    $data[] = get_paginated_activities($item['activities'], true);
}
$data[] = get_paginated_value($item['article_type'], 'mod_articles_article_types_list');
$feedItem->setDescription(implode(' - ', $data));
$feed->addItem($feedItem);
开发者ID:snouhaud,项目名称:camptocamp.org,代码行数:19,代码来源:_rss_item.php

示例15: getItemFeedLink

 private static function getItemFeedLink($item, $routeName = '', $fallback_url = '')
 {
     if ($routeName) {
         if (method_exists('sfRouting', 'getInstance')) {
             $route = sfRouting::getInstance()->getRouteByName($routeName);
             $url = $route[0];
             $paramNames = $route[2];
             $defaults = $route[4];
         } else {
             $routes = sfContext::getInstance()->getRouting()->getRoutes();
             $route = $routes[substr($routeName, 1)];
             if ($route instanceof sfRoute) {
                 $url = $route->getPattern();
                 $paramNames = array_keys($route->getVariables());
                 $defaults = $route->getDefaults();
             } else {
                 $url = $route[0];
                 $paramNames = array_keys($route[2]);
                 $defaults = $route[3];
             }
         }
         // we get all parameters
         $params = array();
         foreach ($paramNames as $paramName) {
             $value = null;
             $name = ucfirst(sfInflector::camelize($paramName));
             $found = false;
             foreach (array('getFeed' . $name, 'get' . $name) as $methodName) {
                 if (method_exists($item, $methodName)) {
                     $value = $item->{$methodName}();
                     $found = true;
                     break;
                 }
             }
             if (!$found) {
                 if (array_key_exists($paramName, $defaults)) {
                     $value = $defaults[$paramName];
                 } else {
                     $error = 'Cannot find a "getFeed%s()" or "get%s()" method for object "%s" to generate URL with the "%s" route';
                     $error = sprintf($error, $name, $name, get_class($item), $routeName);
                     throw new sfException($error);
                 }
             }
             $params[] = $paramName . '=' . $value;
         }
         return sfContext::getInstance()->getController()->genUrl($routeName . ($params ? '?' . implode('&', $params) : ''), true);
     }
     foreach (array('getFeedLink', 'getLink', 'getUrl') as $methodName) {
         if (method_exists($item, $methodName)) {
             return sfContext::getInstance()->getController()->genUrl($item->{$methodName}(), true);
         }
     }
     if ($fallback_url) {
         return sfContext::getInstance()->getController()->genUrl($fallback_url, true);
     } else {
         return sfContext::getInstance()->getController()->genUrl('/', true);
     }
 }
开发者ID:runopencode,项目名称:diem-extended,代码行数:58,代码来源:sfFeedPeer.class.php


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