Example #1
0
 /**
  * Initializes this Routing.
  *
  * Available options:
  *
  *  * suffix:                           The default suffix
  *  * variable_prefixes:                An array of characters that starts a variable name (: by default)
  *  * segment_separators:               An array of allowed characters for segment separators (/ and . by default)
  *  * variable_regex:                   A regex that match a valid variable name ([\w\d_]+ by default)
  *  * generate_shortest_url:            Whether to generate the shortest URL possible (true by default)
  *  * extra_parameters_as_query_string: Whether to generate extra parameters as a query string
  *  * lookup_cache_dedicated_keys:      Whether to use dedicated keys for parse/generate cache (false by default)
  *                                      WARNING: When this option is activated, do not use sfFileCache; use a fast access
  *                                      cache backend (like sfAPCCache).
  *
  * @see sfRouting
  */
 public function initialize(sfEventDispatcher $dispatcher, sfCache $cache = null, $options = array())
 {
     $options = array_merge(array('variable_prefixes' => array(':'), 'segment_separators' => array('/', '.'), 'variable_regex' => '[\\w\\d_]+', 'load_configuration' => false, 'suffix' => '', 'generate_shortest_url' => true, 'extra_parameters_as_query_string' => true, 'lookup_cache_dedicated_keys' => false), $options);
     // for BC
     if ('.' == $options['suffix']) {
         $options['suffix'] = '';
     }
     parent::initialize($dispatcher, $cache, $options);
     if (null !== $this->cache && !$options['lookup_cache_dedicated_keys'] && ($cacheData = $this->cache->get('symfony.routing.data'))) {
         $this->cacheData = unserialize($cacheData);
     }
 }
 /**
  * Initializes this Routing.
  *
  * Available options:
  *
  *  * suffix:             The default suffix
  *  * variable_prefixes:  An array of characters that starts a variable name (: by default)
  *  * segment_separators: An array of allowed characters for segment separators (/ and . by default)
  *  * variable_regex:     A regex that match a valid variable name ([\w\d_]+ by default)
  *
  * @see sfRouting
  */
 public function initialize(sfEventDispatcher $dispatcher, sfCache $cache = null, $options = array())
 {
     if (!isset($options['variable_prefixes'])) {
         $options['variable_prefixes'] = array(':');
     }
     if (!isset($options['segment_separators'])) {
         $options['segment_separators'] = array('/', '.');
     }
     if (!isset($options['variable_regex'])) {
         $options['variable_regex'] = '[\\w\\d_]+';
     }
     $options['variable_prefix_regex'] = '(?:' . implode('|', array_map(create_function('$a', 'return preg_quote($a, \'#\');'), $options['variable_prefixes'])) . ')';
     $options['segment_separators_regex'] = '(?:' . implode('|', array_map(create_function('$a', 'return preg_quote($a, \'#\');'), $options['segment_separators'])) . ')';
     $options['variable_content_regex'] = '[^' . implode('', array_map(create_function('$a', 'return str_replace(\'-\', \'\\-\', preg_quote($a, \'#\'));'), $options['segment_separators'])) . ']+';
     if (!isset($options['load_configuration'])) {
         $options['load_configuration'] = false;
     }
     $this->setDefaultSuffix(isset($options['suffix']) ? $options['suffix'] : '');
     parent::initialize($dispatcher, $cache, $options);
     if (!is_null($this->cache) && ($cacheData = $this->cache->get('symfony.routing.data'))) {
         $this->cacheData = unserialize($cacheData);
     }
 }