<commit_before><?php

/*
 * This file is part of the Yodler package.
 *
 * (c) aes3xs <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Aes3xs\Yodler\Console;

use Aes3xs\Yodler\Common\CallableHelper;
use Aes3xs\Yodler\Deploy\DeployBuilder;
use Aes3xs\Yodler\Event\ConsoleRunEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

/**
 * Builds console commands from configured scenarios and deploys.
 */
class CommandBuilder implements EventSubscriberInterface
{
    /**
     * @var DeployBuilder
     */
    protected $deployBuilder;

    /**
     * @var array
     */
    protected $deploys;

    /**
     * Constructor.
     *
     * @param DeployBuilder $deployBuilder
     * @param array $deploys
     */
    public function __construct(DeployBuilder $deployBuilder, array $deploys)
    {
        $this->deployBuilder = $deployBuilder;
        $this->deploys = $deploys;
    }

    /**
     * @param ConsoleRunEvent $event
     */
    public function onConsoleRun(ConsoleRunEvent $event)
    {
        foreach ($this->deploys as $name => $data) {

            $deploy = $this->deployBuilder->build($name, $data);

            $command = new DeployCommand($deploy);

            if ($initializer = $deploy->getScenario()->getInitializer()) {
                CallableHelper::call($initializer, [
                    'command'     => $command,
                    'deploy'      => $deploy,
                    'application' => $event->getApplication(),
                    'input'       => $event->getInput(),
                    'output'      => $event->getOutput(),
                ]);
            }

            $event->getApplication()->add($command);
        }
    }

    /**
     * {@inheritdoc}
     */
    public static function getSubscribedEvents()
    {
        return [
            ConsoleRunEvent::NAME => ['onConsoleRun', 255],
        ];
    }
}<commit_msg>Add deploy parameters while processing initializer<commit_after><?php

/*
 * This file is part of the Yodler package.
 *
 * (c) aes3xs <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Aes3xs\Yodler\Console;

use Aes3xs\Yodler\Common\CallableHelper;
use Aes3xs\Yodler\Deploy\DeployBuilder;
use Aes3xs\Yodler\Event\ConsoleRunEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

/**
 * Builds console commands from configured scenarios and deploys.
 */
class CommandBuilder implements EventSubscriberInterface
{
    /**
     * @var DeployBuilder
     */
    protected $deployBuilder;

    /**
     * @var array
     */
    protected $deploys;

    /**
     * Constructor.
     *
     * @param DeployBuilder $deployBuilder
     * @param array $deploys
     */
    public function __construct(DeployBuilder $deployBuilder, array $deploys)
    {
        $this->deployBuilder = $deployBuilder;
        $this->deploys = $deploys;
    }

    /**
     * @param ConsoleRunEvent $event
     */
    public function onConsoleRun(ConsoleRunEvent $event)
    {
        foreach ($this->deploys as $name => $data) {

            $deploy = $this->deployBuilder->build($name, $data);

            $command = new DeployCommand($deploy);

            if ($initializer = $deploy->getScenario()->getInitializer()) {
                CallableHelper::call($initializer, [
                    'command'     => $command,
                    'deploy'      => $deploy,
                    'application' => $event->getApplication(),
                    'input'       => $event->getInput(),
                    'output'      => $event->getOutput(),
                ] + $deploy->getParameters()->all());
            }

            $event->getApplication()->add($command);
        }
    }

    /**
     * {@inheritdoc}
     */
    public static function getSubscribedEvents()
    {
        return [
            ConsoleRunEvent::NAME => ['onConsoleRun', 255],
        ];
    }
}
{'fraction_non_alphanumeric': 0.125030765444253, 'fraction_numerical': 0.0039379768643859215, 'mean_word_length': 2.1406491499227203, 'pattern_counts': {'":': 0, '<': 9, '<?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': '4867746', 'n_tokens_mistral': 1188, 'n_tokens_neox': 1128, 'n_words': 246}