当前位置: 首页>>代码示例>>PHP>>正文


PHP Yaml::dump方法代码示例

本文整理汇总了PHP中Symfony\Component\Yaml\Yaml::dump方法的典型用法代码示例。如果您正苦于以下问题:PHP Yaml::dump方法的具体用法?PHP Yaml::dump怎么用?PHP Yaml::dump使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\Yaml\Yaml的用法示例。


在下文中一共展示了Yaml::dump方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: createMergeRule

 /** @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);
     }
 }
开发者ID:AndyBursh,项目名称:Shopfitter,代码行数:12,代码来源:Parser.php

示例2: write

 /**
  * 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);
 }
开发者ID:erickmerchant,项目名称:wright,代码行数:18,代码来源:YamlSettings.php

示例3: testParseAndDump

 public function testParseAndDump()
 {
     $data = array('lorem' => 'ipsum', 'dolor' => 'sit');
     $yml = Yaml::dump($data);
     $parsed = Yaml::parse($yml);
     $this->assertEquals($data, $parsed);
 }
开发者ID:Ceciceciceci,项目名称:MySJSU-Class-Registration,代码行数:7,代码来源:YamlTest.php

示例4: encode

 /**
  * Convert an array to a Yaml string.
  *
  * {@inheritDoc}
  */
 public static function encode($array)
 {
     if (count($array) < 1) {
         return "";
     }
     return SymfonyYaml::dump($array);
 }
开发者ID:Masterfion,项目名称:plugin-sonos,代码行数:12,代码来源:Yaml.php

示例5: processFile

 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));
 }
开发者ID:justasr,项目名称:symfony2-front-back-structure,代码行数:33,代码来源:Processor.php

示例6: execute

 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));
     }
 }
开发者ID:koolkode,项目名称:http-komponent,代码行数:30,代码来源:DumpRoutesCommand.php

示例7: execute

 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>');
 }
开发者ID:lucatume,项目名称:codeception-setup-local,代码行数:29,代码来源:BaseCommand.php

示例8: writeConfig

 public function writeConfig($destinationDir = null)
 {
     if (!$destinationDir) {
         $destinationDir = Platform::rootDir();
     }
     return file_put_contents($destinationDir . '/' . self::PLATFORM_CONFIG, Yaml::dump($this->config, 2));
 }
开发者ID:mglaman,项目名称:platform-docker,代码行数:7,代码来源:Config.php

示例9: execute

 /**
  * {@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));
 }
开发者ID:symfony,项目名称:framework-bundle,代码行数:35,代码来源:ConfigDebugCommand.php

示例10: execute

 /**
  * {@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));
 }
开发者ID:guitarooman14,项目名称:hackazon,代码行数:28,代码来源:ConfigDebugCommand.php

示例11: testLoad

 /**
  * 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')));
 }
开发者ID:ebidtech,项目名称:config-loader,代码行数:12,代码来源:YamlFileLoaderTest.php

示例12: dump

 /**
  * 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()));
 }
开发者ID:csbill,项目名称:csbill,代码行数:12,代码来源:ConfigWriter.php

示例13: doExecute

 /**
  * {@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;
 }
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:29,代码来源:H264MappingGenerator.php

示例14: execute

 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>");
 }
开发者ID:pfz,项目名称:codeception,代码行数:25,代码来源:GenerateSuite.php

示例15: makeConfigTemplates

 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;
 }
开发者ID:tedivm,项目名称:spark,代码行数:34,代码来源:Builder.php


注:本文中的Symfony\Component\Yaml\Yaml::dump方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。