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

namespace CampaignChain\CoreBundle\Composer;

use CampaignChain\CoreBundle\Util\SystemUtil;
use Symfony\Component\Filesystem\Filesystem;
use Composer\Script\CommandEvent;
use Sensio\Bundle\DistributionBundle\Composer\ScriptHandler as SensioScriptHandler;

class ScriptHandler extends SensioScriptHandler
{
    public static function enableInstallMode(CommandEvent $event)
    {
        SystemUtil::enableInstallMode();

        $event->getIO()->write('Enabled CampaignChain install mode.');
    }

    /**
     * Asks if the new directory structure should be used, installs the structure if needed.
     *
     * @param CommandEvent $event
     */
    public static function initApp(CommandEvent $event)
    {
        SystemUtil::initApp();
    }

    public static function registerModules(CommandEvent $event)
    {
        $options = self::getOptions($event);
        $consoleDir = self::getConsoleDir($event, 'register modules');

        if (null === $consoleDir) {
            return;
        }

        self::executeCommand($event, $consoleDir, 'campaignchain:module:update --class-only', $options['process-timeout']);
        self::executeCommand($event, $consoleDir, 'campaignchain:module:update --config-only', $options['process-timeout']);
        self::executeCommand($event, $consoleDir, 'campaignchain:module:update --routing-only', $options['process-timeout']);
    }

    public static function initPlatformsh(CommandEvent $event)
    {
        $isPlatformsh = getenv("PLATFORM_RELATIONSHIPS");
        if (!$isPlatformsh) {
            return;
        }

        $paramsFile = SystemUtil::getRootDir().'app/config/parameters.yml';

        $paramsContent = file_get_contents($paramsFile);
        $paramsContent .= "\$imports:";
        $paramsContent .= "\$\xA- { resource: parameters_platformsh.php }";

        $fs = new Filesystem();
        $fs->dumpFile($paramsFile, $paramsContent);

        $event->getIO()->write('Initialized Platform.sh configuration.');
    }
}<commit_msg>CampaignChain/campaignchain#170 Add configuration files to run with Platform.sh<commit_after><?php
/*
 * This file is part of the CampaignChain package.
 *
 * (c) CampaignChain, Inc. <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace CampaignChain\CoreBundle\Composer;

use CampaignChain\CoreBundle\Util\SystemUtil;
use Symfony\Component\Filesystem\Filesystem;
use Composer\Script\CommandEvent;
use Sensio\Bundle\DistributionBundle\Composer\ScriptHandler as SensioScriptHandler;

class ScriptHandler extends SensioScriptHandler
{
    public static function enableInstallMode(CommandEvent $event)
    {
        SystemUtil::enableInstallMode();

        $event->getIO()->write('Enabled CampaignChain install mode.');
    }

    /**
     * Asks if the new directory structure should be used, installs the structure if needed.
     *
     * @param CommandEvent $event
     */
    public static function initApp(CommandEvent $event)
    {
        SystemUtil::initApp();
    }

    public static function registerModules(CommandEvent $event)
    {
        $options = self::getOptions($event);
        $consoleDir = self::getConsoleDir($event, 'register modules');

        if (null === $consoleDir) {
            return;
        }

        self::executeCommand($event, $consoleDir, 'campaignchain:module:update --class-only', $options['process-timeout']);
        self::executeCommand($event, $consoleDir, 'campaignchain:module:update --config-only', $options['process-timeout']);
        self::executeCommand($event, $consoleDir, 'campaignchain:module:update --routing-only', $options['process-timeout']);
    }

    public static function initPlatformsh(CommandEvent $event)
    {
        $isPlatformsh = getenv("PLATFORM_RELATIONSHIPS");
        if (!$isPlatformsh) {
            return;
        }

        $orig = SystemUtil::getRootDir().'app/config/parameters_platformsh.yml.dist';
        $target = SystemUtil::getRootDir().'app/config/parameters.yml';

        $fs = new Filesystem();
        $fs->copy($orig, $target, true);

        $event->getIO()->write('Initialized Platform.sh configuration.');
    }
}
{'fraction_non_alphanumeric': 0.12430011198208286, 'fraction_numerical': 0.0006718924972004479, 'mean_word_length': 3.502016129032258, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 17, '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': '1277843', 'n_tokens_mistral': 1214, 'n_tokens_neox': 1193, 'n_words': 280}