Development

Changeset 12968

You must first sign up to be able to contribute.

Changeset 12968

Show
Ignore:
Timestamp:
11/13/08 11:56:43 (8 months ago)
Author:
fabien
Message:

[1.2] fixed sfRoute tokenizer to ease extensions

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.2/lib/routing/sfRoute.class.php

    r12661 r12968  
    453453    while (strlen($buffer)) 
    454454    { 
    455       if ($afterASeparator && preg_match('#^'.$this->options['variable_prefix_regex'].'('.$this->options['variable_regex'].')#', $buffer, $match)) 
     455      if (false !== $this->tokenizeBufferBefore($buffer, $tokens, $afterASeparator, $currentSeparator)) 
     456      { 
     457      } 
     458      else if ($afterASeparator && preg_match('#^'.$this->options['variable_prefix_regex'].'('.$this->options['variable_regex'].')#', $buffer, $match)) 
    456459      { 
    457460        // a variable 
     
    480483        $afterASeparator = true; 
    481484      } 
     485      else if (false !== $this->tokenizeBufferAfter($buffer, $tokens, $afterASeparator, $currentSeparator)) 
     486      { 
     487      } 
    482488      else 
    483489      { 
    484         if (false === $this->tokenizeBuffer($buffer, $tokens, $afterASeparator, $currentSeparator)) 
    485         { 
    486           // parsing problem 
    487           throw new InvalidArgumentException(sprintf('Unable to parse "%s" route near "%s".', $this->pattern, $buffer)); 
    488         } 
    489       } 
    490     } 
    491   } 
    492  
    493   protected function tokenizeBuffer(&$buffer, &$tokens, &$afterASeparator, &$currentSeparator) 
     490        // parsing problem 
     491        throw new InvalidArgumentException(sprintf('Unable to parse "%s" route near "%s".', $this->pattern, $buffer)); 
     492      } 
     493    } 
     494  } 
     495 
     496  protected function tokenizeBufferBefore(&$buffer, &$tokens, &$afterASeparator, &$currentSeparator) 
     497  { 
     498    return false; 
     499  } 
     500 
     501  protected function tokenizeBufferAfter(&$buffer, &$tokens, &$afterASeparator, &$currentSeparator) 
    494502  { 
    495503    return false; 

The Sensio Labs Network

Since 1998, Sensio Labs has been promoting the Open-Source software movement by providing quality web application development, training, consulting, and supporting several large Open-Source projects.