<commit_before><?php
/**
 * sfSslPatternRouting class controls the generation of urls of routes of actions 
 * with generate_ssl security parameter set.
 *
 *
 * @package    symfony
 * @subpackage routing
 * @author     basos <noxelia 4t gmailcom>
 * @version    SVN: $Id: sfPatternRouting.class.php 24061 2009-11-16 22:35:03Z FabianLange $
 */
class sfSslPatternRouting extends sfPatternRouting
{ 
	protected 
	  $appName = null ;

  /**
   * Initializes this Routing.
   *
   * Available options:
   *
   *  * application: [optional]   The application that this routing is located at 
   *           (to generate ssl urls based on generate_ssl security.yml entry) 
   *           When not specified sf_app configuration variable is used
   *
   * @see sfPatternRouting
   */
  public function initialize(sfEventDispatcher $dispatcher, sfCache $cache = null, $options = array())
  {
    $options = array_merge(array(
      'application'                => null,
    ), $options);
    
    $this->appName = ($options['application'] ? $options['application'] : sfConfig::get('sf_app', null)) ;
    if (!is_readable(sfConfig::get('sf_apps_dir'). '/'. $this->appName))
    {
    	throw new sfConfigurationException('Invalid application ('.$this->appName.') specified in routing params');
    }

    parent::initialize($dispatcher, $cache, $options);

  }
  
  /**
   * Copied from sfPatternRouting and slighty modified (MOD marks)
   * TODO: Maybe change ABI and simplify this subclass (see note on MOD comment below)
   * Extention for the sfSslRequirementPlugin
   *   When using absolute urls it is ensured that routes which correspond
   *   to module/action with require_ssl = true and generate_ssl = true, url will be 
   *   generated with https prefix irrelevant of the current request protocol,
   *   when allow_ssl = false and generate_ssl = true, url will be generated with http
   *   prefix, irrelevant of the current request protocol
   *   when not absolute an sfConfigurationException is thrown
   * For more info 
   * @see sfRouting 
   */
  public function generate($name, $params = array(), $absolute = false)
  {
    // fetch from cache
    if (null !== $this->cache)
    {
      $cacheKey = 'generate_'.$name.'_'.md5(serialize(array_merge($this->defaultParameters, $params))).'_'.md5(serialize($this->options['context']));
      if ($this->options['lookup_cache_dedicated_keys'] && $url = $this->cache->get('symfony.routing.data.'.$cacheKey))
      {
        return $this->fixGeneratedUrl($url, $absolute);
      }
      elseif (isset($this->cacheData[$cacheKey]))
      {
        return $this->fixGeneratedUrl($this->cacheData[$cacheKey], $absolute);
      }
    }

    if ($name)
    {
      // named route
      $route = $this->getRoute($name);
    }
    else
    {
      // find a matching route
      if (false === $route = $this->getRouteThatMatchesParameters($params, $this->options['context']))
      {
        throw new sfConfigurationException(sprintf('Unable to find a matching route to generate url for params "%s".', is_object($params) ? 'Object('.get_class($params).')' : str_replace("\n", '', var_export($params, true))));
      }
    }

    $url = $route->generate($params, $this->options['context'], $absolute);

    // store in cache
    if (null !== $this->cache)
    {
      if ($this->options['lookup_cache_dedicated_keys'])
      {
        $this->cache->set('symfony.routing.data.'.$cacheKey, $url);
      }
      else
      {
        $this->cacheChanged = true;
        $this->cacheData[$cacheKey] = $url;
      }
    }
    /*MOD:: We had better to pass $route to the modified version of this subclass
     * or else we would have the serious overhead of calculating it again.
     * Maybe in future the fixGeneratedUrl prototype can change (it is a protected method anyway)
     */ 
    
    return $this->fixGeneratedUrl2($url, $route, $params, $absolute);
  }
  <commit_msg>Fix getRouteThatMatchesParameters() call<commit_after><?php
/**
 * sfSslPatternRouting class controls the generation of urls of routes of actions 
 * with generate_ssl security parameter set.
 *
 *
 * @package    symfony
 * @subpackage routing
 * @author     basos <noxelia 4t gmailcom>
 * @version    SVN: $Id: sfPatternRouting.class.php 24061 2009-11-16 22:35:03Z FabianLange $
 */
class sfSslPatternRouting extends sfPatternRouting
{ 
	protected 
	  $appName = null ;

  /**
   * Initializes this Routing.
   *
   * Available options:
   *
   *  * application: [optional]   The application that this routing is located at 
   *           (to generate ssl urls based on generate_ssl security.yml entry) 
   *           When not specified sf_app configuration variable is used
   *
   * @see sfPatternRouting
   */
  public function initialize(sfEventDispatcher $dispatcher, sfCache $cache = null, $options = array())
  {
    $options = array_merge(array(
      'application'                => null,
    ), $options);
    
    $this->appName = ($options['application'] ? $options['application'] : sfConfig::get('sf_app', null)) ;
    if (!is_readable(sfConfig::get('sf_apps_dir'). '/'. $this->appName))
    {
    	throw new sfConfigurationException('Invalid application ('.$this->appName.') specified in routing params');
    }

    parent::initialize($dispatcher, $cache, $options);

  }
  
  /**
   * Copied from sfPatternRouting and slighty modified (MOD marks)
   * TODO: Maybe change ABI and simplify this subclass (see note on MOD comment below)
   * Extention for the sfSslRequirementPlugin
   *   When using absolute urls it is ensured that routes which correspond
   *   to module/action with require_ssl = true and generate_ssl = true, url will be 
   *   generated with https prefix irrelevant of the current request protocol,
   *   when allow_ssl = false and generate_ssl = true, url will be generated with http
   *   prefix, irrelevant of the current request protocol
   *   when not absolute an sfConfigurationException is thrown
   * For more info 
   * @see sfRouting 
   */
  public function generate($name, $params = array(), $absolute = false)
  {
    // fetch from cache
    if (null !== $this->cache)
    {
      $cacheKey = 'generate_'.$name.'_'.md5(serialize(array_merge($this->defaultParameters, $params))).'_'.md5(serialize($this->options['context']));
      if ($this->options['lookup_cache_dedicated_keys'] && $url = $this->cache->get('symfony.routing.data.'.$cacheKey))
      {
        return $this->fixGeneratedUrl($url, $absolute);
      }
      elseif (isset($this->cacheData[$cacheKey]))
      {
        return $this->fixGeneratedUrl($this->cacheData[$cacheKey], $absolute);
      }
    }

    if ($name)
    {
      // named route
      $route = $this->getRoute($name);
    }
    else
    {
      // find a matching route
      if (false === $route = $this->getRouteThatMatchesParameters($params))
      {
        throw new sfConfigurationException(sprintf('Unable to find a matching route to generate url for params "%s".', is_object($params) ? 'Object('.get_class($params).')' : str_replace("\n", '', var_export($params, true))));
      }
    }

    $url = $route->generate($params, $this->options['context'], $absolute);

    // store in cache
    if (null !== $this->cache)
    {
      if ($this->options['lookup_cache_dedicated_keys'])
      {
        $this->cache->set('symfony.routing.data.'.$cacheKey, $url);
      }
      else
      {
        $this->cacheChanged = true;
        $this->cacheData[$cacheKey] = $url;
      }
    }
    /*MOD:: We had better to pass $route to the modified version of this subclass
     * or else we would have the serious overhead of calculating it again.
     * Maybe in future the fixGeneratedUrl prototype can change (it is a protected method anyway)
     */ 
    
    return $this->fixGeneratedUrl2($url, $route, $params, $absolute);
  }
  
{'fraction_non_alphanumeric': 0.12732840010206686, 'fraction_numerical': 0.005868844092880837, 'mean_word_length': 3.0553543714433524, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 56, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1677689', 'n_tokens_mistral': 2306, 'n_tokens_neox': 2241, 'n_words': 651}