<commit_before><?php

class sfSympalCreatePlugin extends sfBaseTask
{
  protected function configure()
  {
    $this->addArguments(array(
      new sfCommandArgument('name', sfCommandArgument::REQUIRED, 'The name of the functionality. i.e. sfSympal#NAME#Plugin'),
    ));

    $this->addOptions(array(
      new sfCommandOption('entity-type', null, sfCommandOption::PARAMETER_OPTIONAL, 'The name of the entity type to create', null),
      new sfCommandOption('re-generate', null, sfCommandOption::PARAMETER_NONE, 'Re-generate the plugin. Will remove it if it exists already and re-generate everything.')
    ));

    $this->aliases = array();
    $this->namespace = 'sympal';
    $this->name = 'create-plugin';
    $this->briefDescription = 'Create the skeleton for a sympal plugin';

    $this->detailedDescription = <<<EOF
The [sympal:create-plugin|INFO] is a task to help you with creating a skeleton sympal plugin.
EOF;
  }

  protected function execute($arguments = array(), $options = array())
  {
    $name = $arguments['name'];
    $pluginName = 'sfSympal'.Doctrine_Inflector::classify($name).'Plugin';
    $path = sfConfig::get('sf_plugins_dir').'/'.$pluginName;

    if (!$this->askConfirmation(array('This command will create a new plugin named '.$pluginName, 'Are you sure you want to proceed? (y/N)'), null, false))
    {
      $this->logSection('doctrine', 'Plugin creation aborted');

      return 1;
    }

    if (is_dir($path))
    {
      if (isset($options['re-generate']))
      {
        $this->getFilesystem()->remove(sfFinder::type('file')->in($path));
        $this->getFilesystem()->remove(sfFinder::type('dir')->in($path));
        $this->getFilesystem()->remove($path);
      } else {
        throw new sfException('A plugin with the name '.$pluginName.' already exists!');
      }
    }

    mkdir($path);

    $entityType = isset($options['entity-type']) ? $options['entity-type']:$name;
    $pluginYamlSchema = <<<EOF
---
$entityType:
  actAs: [sfSympalEntityType]
  columns:
    name: string(255)
EOF;

    $pluginConfigurationClassCode = <<<EOF
<?php
class %s extends sfPluginConfiguration
{
  public 
    \$dependencies = array(
      'sfSympalPlugin'
    );

  public function initialize()
  {
    \$this->dispatcher->connect('sympal.load_settings_form', array(\$this, 'loadSettings'));
    \$this->dispatcher->connect('sympal.load_admin_bar', array(\$this, 'loadAdminBar'));
  }

  public function loadAdminBar(sfEvent \$event)
  {
    \$menu = \$event['menu'];

    \$menu->->addNode('$name', '@sympal_entity_type_%s');
  }

  public function loadSettings(sfEvent \$event)<commit_msg>[1.0] sfSympalPlugin: Fix to parse error in generated config code<commit_after><?php

class sfSympalCreatePlugin extends sfBaseTask
{
  protected function configure()
  {
    $this->addArguments(array(
      new sfCommandArgument('name', sfCommandArgument::REQUIRED, 'The name of the functionality. i.e. sfSympal#NAME#Plugin'),
    ));

    $this->addOptions(array(
      new sfCommandOption('entity-type', null, sfCommandOption::PARAMETER_OPTIONAL, 'The name of the entity type to create', null),
      new sfCommandOption('re-generate', null, sfCommandOption::PARAMETER_NONE, 'Re-generate the plugin. Will remove it if it exists already and re-generate everything.')
    ));

    $this->aliases = array();
    $this->namespace = 'sympal';
    $this->name = 'create-plugin';
    $this->briefDescription = 'Create the skeleton for a sympal plugin';

    $this->detailedDescription = <<<EOF
The [sympal:create-plugin|INFO] is a task to help you with creating a skeleton sympal plugin.
EOF;
  }

  protected function execute($arguments = array(), $options = array())
  {
    $name = $arguments['name'];
    $pluginName = 'sfSympal'.Doctrine_Inflector::classify($name).'Plugin';
    $path = sfConfig::get('sf_plugins_dir').'/'.$pluginName;

    if (!$this->askConfirmation(array('This command will create a new plugin named '.$pluginName, 'Are you sure you want to proceed? (y/N)'), null, false))
    {
      $this->logSection('doctrine', 'Plugin creation aborted');

      return 1;
    }

    if (is_dir($path))
    {
      if (isset($options['re-generate']))
      {
        $this->getFilesystem()->remove(sfFinder::type('file')->in($path));
        $this->getFilesystem()->remove(sfFinder::type('dir')->in($path));
        $this->getFilesystem()->remove($path);
      } else {
        throw new sfException('A plugin with the name '.$pluginName.' already exists!');
      }
    }

    mkdir($path);

    $entityType = isset($options['entity-type']) ? $options['entity-type']:$name;
    $pluginYamlSchema = <<<EOF
---
$entityType:
  actAs: [sfSympalEntityType]
  columns:
    name: string(255)
EOF;

    $pluginConfigurationClassCode = <<<EOF
<?php
class %s extends sfPluginConfiguration
{
  public 
    \$dependencies = array(
      'sfSympalPlugin'
    );

  public function initialize()
  {
    \$this->dispatcher->connect('sympal.load_settings_form', array(\$this, 'loadSettings'));
    \$this->dispatcher->connect('sympal.load_admin_bar', array(\$this, 'loadAdminBar'));
  }

  public function loadAdminBar(sfEvent \$event)
  {
    \$menu = \$event['menu'];

    \$menu->addNode('$name', '@sympal_entity_type_%s');
  }

  public function loadSettings(sfEvent \$event)
{'fraction_non_alphanumeric': 0.1613146958821307, 'fraction_numerical': 0.0018889308651303363, 'mean_word_length': 3.911873840445269, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 48, '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': '922763', 'n_tokens_mistral': 1643, 'n_tokens_neox': 1604, 'n_words': 372}