<commit_before><?php

class sfSympalEventListTask extends sfSympalBaseTask
{
  protected function configure()
  {
    $this->addArguments(array(
      new sfCommandArgument('url', sfCommandArgument::OPTIONAL, 'The url to check for available events'),
    ));

    $this->addOptions(array(
      new sfCommandOption('all', null, sfCommandOption::PARAMETER_NONE, 'Show a list of every single notified event name and where it is in the code.', null),
      new sfCommandOption('event', null, sfCommandOption::PARAMETER_OPTIONAL, 'The event name to inspect', null),
      new sfCommandOption('show-connected', null, sfCommandOption::PARAMETER_NONE, 'Only show events that have been connected to', null),
    ));

    $this->aliases = array();
    $this->namespace = 'sympal';
    $this->name = 'event-list';
    $this->briefDescription = 'List of available events for a given url.';

    $this->detailedDescription = <<<EOF
EOF;
  }

  /**
   * @see sfTask
   */
  protected function execute($arguments = array(), $options = array())
  {
    if (isset($options['all']) && $options['all'])
    {
      $dirs = $this->configuration->getPluginPaths();
      $dirs[] = sfConfig::get('sf_symfony_lib_dir');
      $dirs[] = sfConfig::get('sf_lib_dir');

      $files = sfFinder::type('file')->name('*.php')->in($dirs);

      foreach ($files as $file)
      {
        $code = file_get_contents($file);
        $lines = explode("\n", $code);
        foreach ($lines as $key => $line)
        {
          $lineNumber = $key + 1;
          preg_match_all("/([notify, filter, notifyUntil]+)\(new sfEvent\((.*)\)\)/", $line, $matches);

          if (isset($matches[0][0]))
          {
            $e = explode(', ', $matches[2][0]);
            $subject = $e[0];
            $name = trim($e[1], "')(");
            $type = $matches[1][0];
            if ($name == 'application.log' || $name == 'command.log')
            {
              continue;
            }
            $path = str_replace(sfConfig::get('sf_symfony_lib_dir').'/', '', $file);
            $lineNumber = $this->formatter->format('L#'.$lineNumber, 'INFO');
            $name = $this->formatter->format(str_pad($name, 40, ' ', STR_PAD_RIGHT), 'COMMENT');
            $type = $this->formatter->format(str_pad($type, 15, ' ', STR_PAD_RIGHT), 'INFO');
            $this->log($type.' '.$name.' ('.$path.') '.$lineNumber);
          }
        }
      }
    } else {
      $dispatcher = new sfSympalEventListerDispatcher();
      $configuration = ProjectConfiguration::getApplicationConfiguration('sympal', 'dev', true, null, $dispatcher);
      $context = sfContext::createInstance($configuration);

      $user = Doctrine_Core::getTable(sfSympalConfig::get('user_model'))->findOneByIsSuperAdmin(true);
      $browser = new sfSympalEventListerBrowser(null, null, null, $context);
      $browser->getUser()->setAuthenticated(true);<commit_msg>[1.0][sfSympalPlugin] Fixing event list task<commit_after><?php

class sfSympalEventListTask extends sfSympalBaseTask
{
  protected function configure()
  {
    $this->addArguments(array(
      new sfCommandArgument('application', sfCommandArgument::REQUIRED, 'The application.'),
      new sfCommandArgument('url', sfCommandArgument::OPTIONAL, 'The url to check for available events'),
    ));

    $this->addOptions(array(
      new sfCommandOption('all', null, sfCommandOption::PARAMETER_NONE, 'Show a list of every single notified event name and where it is in the code.', null),
      new sfCommandOption('event', null, sfCommandOption::PARAMETER_OPTIONAL, 'The event name to inspect', null),
      new sfCommandOption('show-connected', null, sfCommandOption::PARAMETER_NONE, 'Only show events that have been connected to', null),
    ));

    $this->aliases = array();
    $this->namespace = 'sympal';
    $this->name = 'event-list';
    $this->briefDescription = 'List of available events for a given url.';

    $this->detailedDescription = <<<EOF
EOF;
  }

  /**
   * @see sfTask
   */
  protected function execute($arguments = array(), $options = array())
  {
    if (isset($options['all']) && $options['all'])
    {
      $dirs = $this->configuration->getPluginPaths();
      $dirs[] = sfConfig::get('sf_symfony_lib_dir');
      $dirs[] = sfConfig::get('sf_lib_dir');

      $files = sfFinder::type('file')->name('*.php')->in($dirs);

      foreach ($files as $file)
      {
        $code = file_get_contents($file);
        $lines = explode("\n", $code);
        foreach ($lines as $key => $line)
        {
          $lineNumber = $key + 1;
          preg_match_all("/([notify, filter, notifyUntil]+)\(new sfEvent\((.*)\)\)/", $line, $matches);

          if (isset($matches[0][0]))
          {
            $e = explode(', ', $matches[2][0]);
            $subject = $e[0];
            $name = trim($e[1], "')(");
            $type = $matches[1][0];
            if ($name == 'application.log' || $name == 'command.log')
            {
              continue;
            }
            $path = str_replace(sfConfig::get('sf_symfony_lib_dir').'/', '', $file);
            $lineNumber = $this->formatter->format('L#'.$lineNumber, 'INFO');
            $name = $this->formatter->format(str_pad($name, 40, ' ', STR_PAD_RIGHT), 'COMMENT');
            $type = $this->formatter->format(str_pad($type, 15, ' ', STR_PAD_RIGHT), 'INFO');
            $this->log($type.' '.$name.' ('.$path.') '.$lineNumber);
          }
        }
      }
    } else {
      $dispatcher = new sfSympalEventListerDispatcher();
      $configuration = ProjectConfiguration::getApplicationConfiguration($arguments['application'], 'dev', true, null, $dispatcher);
      $context = sfContext::createInstance($configuration);

      $user = Doctrine_Core::getTable(sfSympalConfig::get('user_model'))->findOneByIsSuperAdmin(true);
      $browser = new sfSympalEventListerBrowser(null, null, null, $context);
      $browser->getUser()->setAuthenticated(true);
{'fraction_non_alphanumeric': 0.17739483020780536, 'fraction_numerical': 0.004730528805541477, 'mean_word_length': 3.0997229916897506, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 47, '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': '4810565', 'n_tokens_mistral': 1791, 'n_tokens_neox': 1774, 'n_words': 372}