Exemple #1
0
 /** @return MergeRule */
 private function createMergeRule($ruleLine)
 {
     if (is_array($ruleLine)) {
         if (!isset($ruleLine[ParserConstants::KEY_MERGE_FILE]) || !isset($ruleLine[ParserConstants::KEY_MERGE_GITPATH])) {
             throw new RuleParsingException($this->yaml->dump($ruleLine));
         }
         return new MergeRule($ruleLine[ParserConstants::KEY_MERGE_FILE], $ruleLine[ParserConstants::KEY_MERGE_GITPATH]);
     } else {
         return new MergeRule($ruleLine);
     }
 }
 /**
  * Writes a settings file.
  *
  * @param  string $file     The file name
  * @param  array  $settings Settings to write to the file.
  * @return void
  */
 public function write($file, $settings)
 {
     $file = '/settings/' . $file;
     /**
      * @todo validate that $file is a string
      * @todo validate that $settings is a string
      */
     $settings = json_decode(json_encode($settings), true);
     $settings = $this->yaml->dump($settings);
     $this->source_filesystem->put($file . '.yml', $settings);
 }
 public function testParseAndDump()
 {
     $data = array('lorem' => 'ipsum', 'dolor' => 'sit');
     $yml = Yaml::dump($data);
     $parsed = Yaml::parse($yml);
     $this->assertEquals($data, $parsed);
 }
Exemple #4
0
 /**
  * Convert an array to a Yaml string.
  *
  * {@inheritDoc}
  */
 public static function encode($array)
 {
     if (count($array) < 1) {
         return "";
     }
     return SymfonyYaml::dump($array);
 }
 public function processFile(array $config)
 {
     $config = $this->processConfig($config);
     $realFile = $config['file'];
     $parameterKey = $config['parameter-key'];
     $exists = is_file($realFile);
     $yamlParser = new Parser();
     $action = $exists ? 'Updating' : 'Creating';
     $this->io->write(sprintf('<info>%s the "%s" file</info>', $action, $realFile));
     // Find the expected params
     $expectedValues = $yamlParser->parse(file_get_contents($config['dist-file']));
     if (!isset($expectedValues[$parameterKey])) {
         throw new \InvalidArgumentException(sprintf('The top-level key %s is missing.', $parameterKey));
     }
     $expectedParams = (array) $expectedValues[$parameterKey];
     // find the actual params
     $actualValues = array_merge($expectedValues, array($parameterKey => array()));
     if ($exists) {
         $existingValues = $yamlParser->parse(file_get_contents($realFile));
         if ($existingValues === null) {
             $existingValues = array();
         }
         if (!is_array($existingValues)) {
             throw new \InvalidArgumentException(sprintf('The existing "%s" file does not contain an array', $realFile));
         }
         $actualValues = array_merge($actualValues, $existingValues);
     }
     $actualValues[$parameterKey] = $this->processParams($config, $expectedParams, (array) $actualValues[$parameterKey]);
     if (!is_dir($dir = dirname($realFile))) {
         mkdir($dir, 0755, true);
     }
     file_put_contents($realFile, "# This file is auto-generated during the composer install\n" . Yaml::dump($actualValues, 99));
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if (NULL !== ($file = $input->getOption('file'))) {
         if (is_file($file) && !$input->getOption('overwrite')) {
             $output->writeln(sprintf('File <info>%s</info> already exists, use option <comment>-o</comment> to overwrite it.', $file));
             return;
         }
         $backup = $output;
         $fp = fopen($file, 'wb');
         $output = new StreamOutput($fp);
     }
     $request = new HttpRequest(new Uri('http://test.me/'));
     $this->requestScope->enter($request);
     try {
         $output->writeln('routes:');
         $routes = $this->router->getRoutes($this->context)->getSortedRoutes();
         foreach (array_reverse($routes) as $name => $route) {
             $output->writeln(sprintf('  %s:', $name));
             foreach (explode("\n", trim(Yaml::dump($route->toArray($this->context), 100))) as $line) {
                 $output->writeln(sprintf('    %s', $line));
             }
         }
     } finally {
         $this->requestScope->leave($request);
     }
     if (isset($fp) && is_resource($fp)) {
         @fclose($fp);
         $backup->writeln(sprintf('Config dumped to <info>%s</info>', $file));
     }
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if (empty($input->getOption('save-config'))) {
         return true;
     }
     $configFilePath = $this->getLocalConfigFilePath();
     $config = file_exists($configFilePath) ? Yaml::parse(file_get_contents($configFilePath)) : [];
     $commandName = $this->getName();
     if (empty($config[$commandName])) {
         $config[$commandName] = [];
     }
     $commandConfig = $config[$commandName];
     $options = array_filter($this->getDefinition()->getOptions(), function (InputOption $option) {
         return $option->getName() !== 'save-config';
     });
     /** @var InputOption $option */
     foreach ($options as $option) {
         $optionName = $option->getName();
         $optionValue = $input->getOption($optionName);
         if (empty($optionValue)) {
             continue;
         }
         $commandConfig[$optionName] = $optionValue;
     }
     $config[$commandName] = $commandConfig;
     $yamlDump = Yaml::dump($config);
     file_put_contents($configFilePath, $this->getConfigFilePrefix() . "\n\n" . $yamlDump);
     $output->writeln('<info>[' . $commandName . '] command configuration saved to [' . $configFilePath . '] file.</info>');
 }
Exemple #8
0
 public function writeConfig($destinationDir = null)
 {
     if (!$destinationDir) {
         $destinationDir = Platform::rootDir();
     }
     return file_put_contents($destinationDir . '/' . self::PLATFORM_CONFIG, Yaml::dump($this->config, 2));
 }
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new SymfonyStyle($input, $output);
     if (null === ($name = $input->getArgument('name'))) {
         $this->listBundles($io);
         $io->comment('Provide the name of a bundle as the first argument of this command to dump its configuration. (e.g. <comment>debug:config FrameworkBundle</comment>)');
         $io->comment('For dumping a specific option, add its path as the second argument of this command. (e.g. <comment>debug:config FrameworkBundle serializer</comment> to dump the <comment>framework.serializer</comment> configuration)');
         return;
     }
     $extension = $this->findExtension($name);
     $container = $this->compileContainer();
     $extensionAlias = $extension->getAlias();
     $configs = $container->getExtensionConfig($extensionAlias);
     $configuration = $extension->getConfiguration($configs, $container);
     $this->validateConfiguration($extension, $configuration);
     $configs = $container->getParameterBag()->resolveValue($configs);
     $processor = new Processor();
     $config = $processor->processConfiguration($configuration, $configs);
     if (null === ($path = $input->getArgument('path'))) {
         $io->title(sprintf('Current configuration for %s', $name === $extensionAlias ? sprintf('extension with alias "%s"', $extensionAlias) : sprintf('"%s"', $name)));
         $io->writeln(Yaml::dump(array($extensionAlias => $config), 10));
         return;
     }
     try {
         $config = $this->getConfigForPath($config, $path, $extensionAlias);
     } catch (LogicException $e) {
         $io->error($e->getMessage());
         return;
     }
     $io->title(sprintf('Current configuration for "%s.%s"', $extensionAlias, $path));
     $io->writeln(Yaml::dump($config, 10));
 }
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $name = $input->getArgument('name');
     if (empty($name)) {
         $this->listBundles($output);
         return;
     }
     $extension = $this->findExtension($name);
     $kernel = $this->getContainer()->get('kernel');
     $method = new \ReflectionMethod($kernel, 'buildContainer');
     $method->setAccessible(true);
     $container = $method->invoke($kernel);
     $configs = $container->getExtensionConfig($extension->getAlias());
     $configuration = $extension->getConfiguration($configs, $container);
     $this->validateConfiguration($extension, $configuration);
     $configs = $container->getParameterBag()->resolveValue($configs);
     $processor = new Processor();
     $config = $processor->processConfiguration($configuration, $configs);
     if ($name === $extension->getAlias()) {
         $output->writeln(sprintf('# Current configuration for extension with alias: "%s"', $name));
     } else {
         $output->writeln(sprintf('# Current configuration for "%s"', $name));
     }
     $output->writeln(Yaml::dump(array($extension->getAlias() => $config), 3));
 }
 /**
  * Tests success case for loading a valid and readable YAML file.
  *
  * @covers ::load
  */
 public function testLoad()
 {
     $initialContent = ['hello' => 'world'];
     $ymlContent = Yaml::dump($initialContent);
     vfsStream::create(['file1' => $ymlContent], $this->root);
     $this->assertEquals($initialContent, (new YamlFileLoader())->load(vfsStream::url('test/file1')));
 }
Exemple #12
0
 /**
  * Dumps an array into the parameters.yml file.
  *
  * @param array $config
  */
 public function dump(array $config, $mode = 0777)
 {
     $values = ['parameters' => array_merge($this->getConfigValues(), $config)];
     $yaml = Yaml::dump($values);
     $this->fileSystem->dumpFile($this->configFile, $yaml, $mode);
     $this->fileSystem->remove(sprintf('%s/%s.php', $this->kernel->getCacheDir(), $this->kernel->getContainerCacheClass()));
 }
 /**
  * {@inheritdoc}
  */
 protected function doExecute(InputInterface $input, OutputInterface $output)
 {
     $paths = $this->extractPath($this->container->getApplicationBox());
     foreach ($paths as $path) {
         $this->container['filesystem']->mkdir($path);
     }
     $type = strtolower($input->getArgument('type'));
     $enabled = $input->getOption('enabled');
     $factory = new H264Factory($this->container['monolog'], true, $type, $this->computeMapping($paths));
     $mode = $factory->createMode(true);
     $currentConf = isset($this->container['phraseanet.configuration']['h264-pseudo-streaming']) ? $this->container['phraseanet.configuration']['h264-pseudo-streaming'] : [];
     $currentMapping = isset($currentConf['mapping']) && is_array($currentConf['mapping']) ? $currentConf['mapping'] : [];
     $conf = ['enabled' => $enabled, 'type' => $type, 'mapping' => $mode->getMapping()];
     if ($input->getOption('write')) {
         $output->write("Writing configuration ...");
         $this->container['phraseanet.configuration']['h264-pseudo-streaming'] = $conf;
         $output->writeln(" <info>OK</info>");
         $output->writeln("");
         $output->write("It is now strongly recommended to use <info>h264-pseudo-streaming:dump-configuration</info> command to upgrade your virtual-host");
     } else {
         $output->writeln("Configuration will <info>not</info> be written, use <info>--write</info> option to write it");
         $output->writeln("");
         $output->writeln(Yaml::dump(['h264-pseudo-streaming' => $conf], 4));
     }
     return 0;
 }
Exemple #14
0
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $suite = $input->getArgument('suite');
     $guy = $input->getArgument('guy');
     $config = \Codeception\Configuration::config($input->getOption('config'));
     $dir = \Codeception\Configuration::projectDir() . $config['paths']['tests'] . DIRECTORY_SEPARATOR;
     if (file_exists($dir . DIRECTORY_SEPARATOR . $suite)) {
         throw new \Exception("Directory {$suite} already exists.");
     }
     if (file_exists($dir . $suite . '.suite.yml')) {
         throw new \Exception("Suite configuration file '{$suite}.suite.yml' already exists.");
     }
     @mkdir($dir . DIRECTORY_SEPARATOR . $suite);
     // generate bootstrap
     file_put_contents($dir . DIRECTORY_SEPARATOR . $suite . '/_bootstrap.php', "<?php\n// Here you can initialize variables that will for your tests\n");
     if (strpos(strrev($guy), 'yuG') !== 0) {
         $guy = $guy . 'Guy';
     }
     $guyname = substr($guy, 0, -3);
     // generate helper
     file_put_contents(\Codeception\Configuration::projectDir() . $config['paths']['helpers'] . DIRECTORY_SEPARATOR . $guyname . 'Helper.php', "<?php\nnamespace Codeception\\Module;\n\n// here you can define custom functions for {$guy} \n\nclass {$guyname}Helper extends \\Codeception\\Module\n{\n}\n");
     $conf = array('class_name' => $guy, 'modules' => array('enabled' => array($guyname . 'Helper')));
     file_put_contents($dir . $suite . '.suite.yml', Yaml::dump($conf, 2));
     $output->writeln("<info>Suite {$suite} generated</info>");
 }
Exemple #15
0
 protected function makeConfigTemplates()
 {
     $json_options = 0;
     if (defined('JSON_PRETTY_PRINT')) {
         $json_options = $json_options | JSON_PRETTY_PRINT;
     }
     if (defined('JSON_UNESCAPED_SLASHES')) {
         $json_options = $json_options | JSON_UNESCAPED_SLASHES;
     }
     $templates = array();
     foreach ($this->config as $file => $rawContents) {
         $ext = pathinfo($file, PATHINFO_EXTENSION);
         if ($ext == 'dist') {
             $fileSubName = substr($file, 0, strlen($file) - 5);
             $ext = pathinfo($fileSubName, PATHINFO_EXTENSION);
         }
         switch ($ext) {
             case 'yml':
                 $contents = $this->yamlPretty(Yaml::dump($rawContents, 3));
                 break;
             case 'json':
                 $contents = json_encode($rawContents, $json_options);
                 break;
             default:
                 if (is_scalar($rawContents)) {
                     $contents = $rawContents;
                 } else {
                     throw new \RuntimeException('Unable to identify config file parser for ' . $file);
                 }
         }
         $templates[$file] = $contents;
     }
     return $templates;
 }
Exemple #16
0
 public function registerContainerConfiguration(LoaderInterface $loader)
 {
     $file = $this->getRootDir() . '/config.yml';
     $contents = Yaml::dump($this->_config);
     file_put_contents($file, $contents);
     $loader->load($file);
 }
 /**
  * テンプレート一覧画面
  *
  * @param Application $app
  * @param Request $request
  */
 public function index(Application $app, Request $request)
 {
     $DeviceType = $app['eccube.repository.master.device_type']->find(DeviceType::DEVICE_TYPE_PC);
     $Templates = $app['eccube.repository.template']->findBy(array('DeviceType' => $DeviceType));
     $form = $app->form()->add('selected', 'hidden')->getForm();
     if ('POST' === $request->getMethod()) {
         $form->handleRequest($request);
         if ($form->isValid()) {
             $Template = $app['eccube.repository.template']->find($form['selected']->getData());
             // path.ymlの再構築
             $file = $app['config']['root_dir'] . '/app/config/eccube/path.yml';
             $config = Yaml::parse($file);
             $templateCode = $Template->getCode();
             $config['template_code'] = $templateCode;
             $config['template_realdir'] = $config['root_dir'] . '/app/template/' . $templateCode;
             $config['template_html_realdir'] = $config['root_dir'] . '/html/template/' . $templateCode;
             $config['front_urlpath'] = $config['root_urlpath'] . '/template/' . $templateCode;
             $config['block_realdir'] = $config['template_realdir'] . '/Block';
             file_put_contents($file, Yaml::dump($config));
             $app->addSuccess('admin.content.template.save.complete', 'admin');
             return $app->redirect($app->url('admin_store_template'));
         }
     }
     return $app->render('Store/template.twig', array('form' => $form->createView(), 'Templates' => $Templates));
 }
Exemple #18
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $helper = $this->getHelper('question');
     $file = $this->directory . '/.tl.yml';
     if (file_exists($file)) {
         $config = Yaml::parse(file_get_contents($file));
         $output->writeln(sprintf('<info>Found existing file %s</info>', $file));
     } else {
         $output->writeln('<info>Creating new file</info>');
         $config = [];
     }
     foreach ($this->configurableServiceIds as $service_id) {
         $service_definition = $this->container->getDefinition($service_id);
         /** @var ConfigurableService $service_class */
         $service_class = $service_definition->getClass();
         $config = $service_class::getDefaults($config);
         $config = $service_class::askPreBootQuestions($helper, $input, $output, $config);
     }
     $this->container->setParameter('config', $config);
     // Now we can attempt boot.
     foreach ($this->configurableServiceIds as $service_id) {
         /** @var ConfigurableService $service */
         $service = $this->container->get($service_id);
         $config = $service->askPostBootQuestions($helper, $input, $output, $config);
     }
     $this->container->setParameter('config', $config);
     file_put_contents($file, Yaml::dump($config));
     $output->writeln(sprintf('<info>Wrote configuration to file %s</info>', $file));
 }
 /**
  * {@inheritdoc}
  */
 protected function doExecute(InputInterface $input, OutputInterface $output)
 {
     $paths = $this->extractPath($this->container['phraseanet.appbox']);
     foreach ($paths as $path) {
         $this->container['filesystem']->mkdir($path);
     }
     $type = strtolower($input->getArgument('type'));
     $enabled = $input->getOption('enabled');
     $factory = new XSendFileFactory($this->container['monolog'], true, $type, $this->computeMapping($paths));
     $mode = $factory->getMode(true);
     $conf = ['enabled' => $enabled, 'type' => $type, 'mapping' => $mode->getMapping()];
     if ($input->getOption('write')) {
         $output->write("Writing configuration ...");
         $this->container['conf']->set('xsendfile', $conf);
         $output->writeln(" <info>OK</info>");
         $output->writeln("");
         $output->writeln("It is now strongly recommended to use <info>xsendfile:dump-configuration</info> command to upgrade your virtual-host");
     } else {
         $output->writeln("Configuration will <info>not</info> be written, use <info>--write</info> option to write it");
         $output->writeln("");
         $output->writeln(Yaml::dump(['xsendfile' => $conf], 4));
     }
     $output->writeln("");
     return 0;
 }
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $suite = lcfirst($input->getArgument('suite'));
     $actor = $input->getArgument('actor');
     if ($this->containsInvalidCharacters($suite)) {
         $output->writeln("<error>Suite name '{$suite}' contains invalid characters. ([A-Za-z0-9_]).</error>");
         return;
     }
     $config = \Codeception\Configuration::config($input->getOption('config'));
     if (!$actor) {
         $actor = ucfirst($suite) . $config['actor'];
     }
     $config['class_name'] = $actor;
     $dir = \Codeception\Configuration::testsDir();
     if (file_exists($dir . $suite . '.suite.yml')) {
         throw new \Exception("Suite configuration file '{$suite}.suite.yml' already exists.");
     }
     $this->buildPath($dir . $suite . DIRECTORY_SEPARATOR, '_bootstrap.php');
     // generate bootstrap
     $this->save($dir . $suite . DIRECTORY_SEPARATOR . '_bootstrap.php', "<?php\n// Here you can initialize variables that will be available to your tests\n", true);
     $actorName = $this->removeSuffix($actor, $config['actor']);
     $file = $this->buildPath(\Codeception\Configuration::supportDir() . "Helper", "{$actorName}.php") . "{$actorName}.php";
     $gen = new Helper($actorName, $config['namespace']);
     // generate helper
     $this->save($file, $gen->produce());
     $conf = ['class_name' => $actorName . $config['actor'], 'modules' => ['enabled' => [$gen->getHelperName()]]];
     $this->save($dir . $suite . '.suite.yml', Yaml::dump($conf, 2));
     $output->writeln("<info>Suite {$suite} generated</info>");
 }
    public function getCode($template, $gatewayName = null)
    {
        $payumConfigHtml = '';
        if ($gatewayName) {
            ob_start();
            include __DIR__ . '/../../../../../app/config/payum.yml';
            $config = Yaml::parse(ob_get_clean());
            $payumConfig = Yaml::dump(array('payum' => array('security' => $config['payum']['security'], 'gateways' => array($gatewayName => $config['payum']['gateways'][$gatewayName]))), $inline = 10);
            $payumConfigHtml = "<p><strong>Payum config:</strong></p><pre># app/config/payum.yml\n\n{$payumConfig}</pre>";
        }
        // highlight_string highlights php code only if '<?php' tag is present.
        $controller = highlight_string("<?php" . $this->getControllerCode(), true);
        $controller = str_replace('<span style="color: #0000BB">&lt;?php&nbsp;&nbsp;&nbsp;&nbsp;</span>', '&nbsp;&nbsp;&nbsp;&nbsp;', $controller);
        $template = htmlspecialchars($this->getTemplateCode($template), ENT_QUOTES, 'UTF-8');
        // remove the code block
        $template = str_replace('{% set code = code(_self) %}', '', $template);
        return <<<EOF
<p><strong><a name="whats-inside?">What's inside?</a></strong></p>

{$payumConfigHtml}

<p><strong>Controller Code</strong></p>
<pre>{$controller}</pre>

<p><strong>Template Code</strong></p>
<pre>{$template}</pre>
EOF;
    }
Exemple #22
0
 protected function yamlDump($data)
 {
     if (!$this->yaml) {
         $this->yaml = new Yaml();
     }
     return $this->yaml->dump($data, 50, 4);
 }
Exemple #23
0
 public function loadFile($source, $parameters = array())
 {
     if (!is_readable($source)) {
         throw new \Exception('Configuration source "' . $source . '" is not readable!');
     }
     $cacheDest = 'config/' . md5($source) . '/' . md5(json_encode($parameters));
     if (Cache::needFresh($source, $cacheDest) || DEBUG) {
         $content = file_get_contents($source);
         foreach ($parameters as $k => $v) {
             $parameters['&' . $k] = $v;
             $content = str_replace('%' . $k . '%', '*' . $k, $content);
             unset($parameters[$k]);
         }
         $aliasYaml = Yaml::dump(array('__aliases' => $parameters), 3);
         foreach ($parameters as $k => $v) {
             $aliasYaml = str_replace('\'' . $k . '\':', '- ' . $k, $aliasYaml);
         }
         //die($aliasYaml.PHP_EOL.$content);
         $result = Yaml::parse($aliasYaml . PHP_EOL . $content);
         unset($result['__aliases']);
         Cache::set($cacheDest, $result);
     } else {
         $result = Cache::get($cacheDest);
     }
     foreach ($result as $k => $v) {
         $this->addNode($k, $v);
     }
     return $this;
 }
 /**
  * Verifies that we can load an optional resource.
  */
 public function testLoadOptional()
 {
     file_put_contents($this->dir . '/test.yml.dist', Yaml::dump(array('parameters' => array('test' => 'value'))));
     self::assertFalse($this->loader->loadOptional(new ResourceCollection(array(new Resource('test.yml')))));
     self::assertTrue($this->loader->loadOptional(new ResourceCollection(array(new ResourceSupport('test.yml.dist', 'test.yml')))));
     self::assertEquals('value', $this->container->getParameter('test'));
 }
Exemple #25
0
 function it_dumps_configuration()
 {
     $this->dump(array('database' => array('user' => 'root')));
     if (Yaml::dump(array('parameters' => array('user' => 'root'))) !== ($actial = file_get_contents($this->getTmpFileName()))) {
         throw new \UnexpectedValueException($actial);
     }
 }
Exemple #26
0
 /**
  * Executes the flo project-setup command.
  * @param InputInterface $input
  * @param OutputInterface $output
  * @throws \Exception
  *
  * @return null
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->checkGitRoot();
     $fs = new Filesystem();
     $helper = $this->getHelper('question');
     if ($fs->exists($this::FLO_YAML_PATH)) {
         throw new \Exception("flo.yml already exists.");
     }
     // Questions.
     $org_question = new Question('Please enter the name of the GitHub organization/username: '******'NBCUOTS');
     $repo_question = new Question('Please enter the name of your github repository: ');
     $shortname_question = new Question('Please enter project short name: ');
     $github_question = new Question('Please enter the GitHub git url: ');
     $acquia_question = new Question('Please enter the Acquia git url: ');
     $pull_request_question = new Question('Please enter the pull-request domain: ');
     $pull_request_prefix_question = new Question('Please enter the pull-request prefix (ex: p7): ');
     // Prompts.
     $organization = $helper->ask($input, $output, $org_question);
     $repository = $helper->ask($input, $output, $repo_question);
     $shortname = $helper->ask($input, $output, $shortname_question);
     $github_git_url = $helper->ask($input, $output, $github_question);
     $acquia_git_url = $helper->ask($input, $output, $acquia_question);
     $pull_request_domain = $helper->ask($input, $output, $pull_request_question);
     $pull_request_prefix = $helper->ask($input, $output, $pull_request_prefix_question);
     $flo_yml = array('organization' => $organization, 'repository' => $repository, 'shortname' => $shortname, 'github_git_uri' => $github_git_url, 'acquia_git_uri' => $acquia_git_url, 'pull_request' => array('domain' => $pull_request_domain, 'prefix' => $pull_request_prefix));
     $fs->dumpFile($this::FLO_YAML_PATH, Yaml::dump($flo_yml, 2, 2));
     if ($fs->exists($this::FLO_YAML_PATH)) {
         $output->writeln("<info>Flo.yml created.</info>");
     }
 }
 /**
  * {@inheritdoc}
  */
 protected function transformDataToArray($file)
 {
     if (strpos($file, "\n") === false && is_file($file)) {
         if (false === is_readable($file)) {
             throw new ParseException(sprintf('Unable to parse "%s" as the file is not readable.', $file));
         }
         if (null !== $this->container && $this->container->has('faker.generator')) {
             $generator = $this->container->get('faker.generator');
             $faker = function ($type) use($generator) {
                 $args = func_get_args();
                 array_shift($args);
                 echo Yaml::dump(call_user_func_array(array($generator, $type), $args)) . "\n";
             };
         } else {
             $faker = function ($text) {
                 echo $text . "\n";
             };
         }
         ob_start();
         $retval = (include $file);
         $content = ob_get_clean();
         // if an array is returned by the config file assume it's in plain php form else in YAML
         $file = is_array($retval) ? $retval : $content;
         // if an array is returned by the config file assume it's in plain php form else in YAML
         if (is_array($file)) {
             return $file;
         }
     }
     return Yaml::parse($file);
 }
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new SymfonyStyle($input, $output);
     $name = $input->getArgument('name');
     if (empty($name)) {
         $io->comment('Provide the name of a bundle as the first argument of this command to dump its configuration.');
         $io->newLine();
         $this->listBundles($output);
         return;
     }
     $extension = $this->findExtension($name);
     $container = $this->compileContainer();
     $configs = $container->getExtensionConfig($extension->getAlias());
     $configuration = $extension->getConfiguration($configs, $container);
     $this->validateConfiguration($extension, $configuration);
     $configs = $container->getParameterBag()->resolveValue($configs);
     $processor = new Processor();
     $config = $processor->processConfiguration($configuration, $configs);
     if ($name === $extension->getAlias()) {
         $io->title(sprintf('Current configuration for extension with alias "%s"', $name));
     } else {
         $io->title(sprintf('Current configuration for "%s"', $name));
     }
     $io->writeln(Yaml::dump(array($extension->getAlias() => $config), 3));
 }
 /**
  * {@inheritDoc}
  */
 protected function format(MessageCatalogue $messages, $domain)
 {
     $m = $messages->all($domain);
     if ($this->nestLevel > 0) {
         // build a message tree from the message list, with a max depth
         // of $this->nestLevel
         $tree = array();
         foreach ($m as $key => $message) {
             // dots are ignored at the beginning and at the end of a key
             $key = trim($key, "\t .");
             if (strlen($key) > 0) {
                 $codes = explode('.', $key, $this->nestLevel + 1);
                 $node =& $tree;
                 foreach ($codes as $code) {
                     if (strlen($code) > 0) {
                         if (!isset($node)) {
                             $node = array();
                         }
                         $node =& $node[$code];
                     }
                 }
                 $node = $message;
             }
         }
         return Yaml::dump($tree, $this->nestLevel + 1);
         // second parameter at 1 outputs normal line-by-line catalogue
     } else {
         return Yaml::dump($m, 1);
     }
 }
Exemple #30
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output = new SymfonyStyle($input, $output);
     if (false !== strpos($input->getFirstArgument(), ':d')) {
         $output->caution('The use of "config:debug" command is deprecated since version 2.7 and will be removed in 3.0. Use the "debug:config" instead.');
     }
     $name = $input->getArgument('name');
     if (empty($name)) {
         $output->comment('Provide the name of a bundle as the first argument of this command to dump its configuration.');
         $output->newLine();
         $this->listBundles($output);
         return;
     }
     $extension = $this->findExtension($name);
     $container = $this->compileContainer();
     $configs = $container->getExtensionConfig($extension->getAlias());
     $configuration = $extension->getConfiguration($configs, $container);
     $this->validateConfiguration($extension, $configuration);
     $configs = $container->getParameterBag()->resolveValue($configs);
     $processor = new Processor();
     $config = $processor->processConfiguration($configuration, $configs);
     if ($name === $extension->getAlias()) {
         $output->title(sprintf('Current configuration for extension with alias "%s"', $name));
     } else {
         $output->title(sprintf('Current configuration for "%s"', $name));
     }
     $output->writeln(Yaml::dump(array($extension->getAlias() => $config), 3));
 }