<commit_before><?php

class sfSympalConfiguration
{
  protected
    $_dispatcher,
    $_projectConfiguration,
    $_sympalContext,
    $_symfonyContext,
    $_doctrineManager,
    $_bootstrap,
    $_plugins = array(),
    $_modules = array(),
    $_layouts = array();

  public function __construct(sfEventDispatcher $dispatcher, ProjectConfiguration $projectConfiguration)
  {
    // We disable Symfony autoload again feature because it is too slow in dev mode
    // If you introduce a new class when using sympal you just must clear your
    // cache manually
    sfAutoloadAgain::getInstance()->unregister();

    $this->_dispatcher = $dispatcher;
    $this->_projectConfiguration = $projectConfiguration;
    $this->_doctrineManager = Doctrine_Manager::getInstance();

    $this->_initializeSymfonyConfig();

    sfOutputEscaper::markClassesAsSafe(array(
      'sfSympalContent',
      'sfSympalContentTranslation',
      'sfSympalContentSlot',
      'sfSympalContentSlotTranslation',
      'sfSympalMenuItem',
      'sfSympalMenuItemTranslation',
      'sfSympalContentRenderer',
      'sfSympalMenu',
      'sfParameterHolder',
      'sfSympalDataGrid',
      'sfSympalUpgradeFromWeb',
      'sfSympalServerCheckHtmlRenderer',
      'sfSympalSitemapGenerator'
    ));

    $this->_dispatcher->connect('context.load_factories', array($this, 'bootstrap'));
    $this->_dispatcher->connect('component.method_not_found', array(new sfSympalActions(), 'extend'));
    $this->_dispatcher->connect('controller.change_action', array($this, 'initializeTheme'));
    $this->_dispatcher->connect('template.filter_parameters', array($this, 'filterTemplateParameters'));
    $this->_dispatcher->connect('form.method_not_found', array(new sfSympalForm(), 'extend'));
    $this->_dispatcher->connect('form.post_configure', array('sfSympalForm', 'listenToFormPostConfigure'));
    $this->_dispatcher->connect('form.filter_values', array('sfSympalForm', 'listenToFormFilterValues'));
    $this->_dispatcher->connect('routing.load_configuration', array($this, 'listenToRoutingLoadConfiguration'));
    $this->_dispatcher->connect('routing.load_configuration', array($this, 'listenToRoutingLoadConfiguration'));

    if (sfSympalConfig::get('page_cache', 'super') && sfConfig::get('sf_cache'))
    {
      $superCache = new sfSympalSuperCache($this);
      $this->_dispatcher->connect('response.filter_content', array($superCache, 'listenToResponseFilterContent'));
    }

    $this->_dispatcher->connect('task.cache.clear', array($this, 'listenToTaskCacheClear'));

    $this->_doctrineManager->setAttribute(Doctrine_Core::ATTR_HYDRATE_OVERWRITE, false);
    $this->_doctrineManager->setAttribute(Doctrine_Core::ATTR_TABLE_CLASS, 'sfSympalDoctrineTable');
    $this->_doctrineManager->setAttribute(Doctrine_Core::ATTR_QUERY_CLASS, 'sfSympalDoctrineQuery');
    $this->_doctrineManager->setAttribute(Doctrine_Core::ATTR_COLLECTION_CLASS, 'sfSympalDoctrineCollection');
  }

  public function listenToTaskCacheClear(sfEvent $event)
  {
    $event->getSubject()->logSection('sympal', 'Clearing web cache folder');

    $cacheDir = sfConfig::get('sf_web_dir').'/cache';
    if (is_dir($cacheDir))
    {
      $event->getSubject()->getFilesystem()->remove(sfFinder::type('file')->ignore_version_control()->discard('.sf')->in($cacheDir));
    }
  }

  public function listenToRoutingLoadConfiguration(sfEvent $event)
  {
    // Append route at end to catch all
    $event->getSubject()->appendRoute('sympal_default', new sfRoute('/*', array(
      'module' => 'sympal_default',<commit_msg>[1.4][sfSympalPlugin][1.0] Removing duplicate line<commit_after><?php

class sfSympalConfiguration
{
  protected
    $_dispatcher,
    $_projectConfiguration,
    $_sympalContext,
    $_symfonyContext,
    $_doctrineManager,
    $_bootstrap,
    $_plugins = array(),
    $_modules = array(),
    $_layouts = array(),
    $_cache;

  public function __construct(sfEventDispatcher $dispatcher, ProjectConfiguration $projectConfiguration)
  {
    // We disable Symfony autoload again feature because it is too slow in dev mode
    // If you introduce a new class when using sympal you just must clear your
    // cache manually
    sfAutoloadAgain::getInstance()->unregister();

    $this->_dispatcher = $dispatcher;
    $this->_projectConfiguration = $projectConfiguration;
    $this->_doctrineManager = Doctrine_Manager::getInstance();

    $this->_initializeSymfonyConfig();

    sfOutputEscaper::markClassesAsSafe(array(
      'sfSympalContent',
      'sfSympalContentTranslation',
      'sfSympalContentSlot',
      'sfSympalContentSlotTranslation',
      'sfSympalMenuItem',
      'sfSympalMenuItemTranslation',
      'sfSympalContentRenderer',
      'sfSympalMenu',
      'sfParameterHolder',
      'sfSympalDataGrid',
      'sfSympalUpgradeFromWeb',
      'sfSympalServerCheckHtmlRenderer',
      'sfSympalSitemapGenerator'
    ));

    $this->_dispatcher->connect('context.load_factories', array($this, 'bootstrap'));
    $this->_dispatcher->connect('component.method_not_found', array(new sfSympalActions(), 'extend'));
    $this->_dispatcher->connect('controller.change_action', array($this, 'initializeTheme'));
    $this->_dispatcher->connect('template.filter_parameters', array($this, 'filterTemplateParameters'));
    $this->_dispatcher->connect('form.method_not_found', array(new sfSympalForm(), 'extend'));
    $this->_dispatcher->connect('form.post_configure', array('sfSympalForm', 'listenToFormPostConfigure'));
    $this->_dispatcher->connect('form.filter_values', array('sfSympalForm', 'listenToFormFilterValues'));
    $this->_dispatcher->connect('routing.load_configuration', array($this, 'listenToRoutingLoadConfiguration'));

    if (sfSympalConfig::get('page_cache', 'super') && sfConfig::get('sf_cache'))
    {
      $superCache = new sfSympalSuperCache($this);
      $this->_dispatcher->connect('response.filter_content', array($superCache, 'listenToResponseFilterContent'));
    }

    $this->_dispatcher->connect('task.cache.clear', array($this, 'listenToTaskCacheClear'));

    $this->_doctrineManager->setAttribute(Doctrine_Core::ATTR_HYDRATE_OVERWRITE, false);
    $this->_doctrineManager->setAttribute(Doctrine_Core::ATTR_TABLE_CLASS, 'sfSympalDoctrineTable');
    $this->_doctrineManager->setAttribute(Doctrine_Core::ATTR_QUERY_CLASS, 'sfSympalDoctrineQuery');
    $this->_doctrineManager->setAttribute(Doctrine_Core::ATTR_COLLECTION_CLASS, 'sfSympalDoctrineCollection');
  }

  public function listenToTaskCacheClear(sfEvent $event)
  {
    $event->getSubject()->logSection('sympal', 'Clearing web cache folder');

    $cacheDir = sfConfig::get('sf_web_dir').'/cache';
    if (is_dir($cacheDir))
    {
      $event->getSubject()->getFilesystem()->remove(sfFinder::type('file')->ignore_version_control()->discard('.sf')->in($cacheDir));
    }
  }

  public function listenToRoutingLoadConfiguration(sfEvent $event)
  {
    // Append route at end to catch all
    $event->getSubject()->appendRoute('sympal_default', new sfRoute('/*', array(
      'module' => 'sympal_default',
{'fraction_non_alphanumeric': 0.14408814804350897, 'fraction_numerical': 0.0005650515609549371, 'mean_word_length': 5.407239819004525, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 93, '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': '911556', 'n_tokens_mistral': 2026, 'n_tokens_neox': 2016, 'n_words': 310}