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


PHP Dumper::dump方法代码示例

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


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

示例1: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $languages = explode(",", $input->getArgument('languages'));
     $finder = new Finder();
     $finder->files()->in(__DIR__ . "/../../datas/");
     $output_path = __DIR__ . "/../../output/";
     $datas_path = __DIR__ . "/../../datas/";
     $key = $input->getArgument('base_language');
     copy($datas_path . "messages.{$key}.yml", $output_path . "messages.{$key}.yml");
     $input = $datas_path . "messages.{$key}.yml";
     foreach ($languages as $lang) {
         $lang = trim($lang);
         $output = $output_path . "messages.{$lang}.yml";
         $origin = $datas_path . "messages.{$lang}.yml";
         $translator = new Translator($key, $input, $output);
         $translator->setLang($lang);
         $yaml = Yaml::parse($input);
         $dumper = new Dumper();
         $copy_yaml = Yaml::parse($origin);
         if (is_array($copy_yaml)) {
             $translator->readAndTranslate($yaml, '', $copy_yaml);
             file_put_contents($output, $dumper->dump($copy_yaml, 2));
         } else {
             $copy_yaml = $yaml;
             $test = Translator::eraseValues($copy_yaml);
             $translator->readAndTranslate($yaml, '', $test);
             file_put_contents($output, $dumper->dump($test, 2));
         }
     }
 }
开发者ID:WeCodePixels,项目名称:remiii-symfony2-and-google-translate,代码行数:30,代码来源:TranslateCommand.php

示例2: encode

 /**
  * @param mixed  $data
  * @param string $format
  * @param array  $context
  *
  * @return string
  */
 public function encode($data, $format, array $context = array())
 {
     if ($this->native) {
         return yaml_emit($data, YAML_UTF8_ENCODING, YAML_LN_BREAK);
     }
     return $this->encoder->dump($data);
 }
开发者ID:mihai-stancu,项目名称:serializer,代码行数:14,代码来源:YamlEncoder.php

示例3: serialize

 /**
  * @inheritDoc
  */
 public function serialize(array $parameters, $fileHeader = null)
 {
     $output = '';
     if ($fileHeader) {
         $output .= \NordCode\RoboParameters\wrap_lines($fileHeader, '# ') . "\n";
     }
     return $output . $this->yamlDumper->dump($parameters, 4);
 }
开发者ID:nordcode,项目名称:robo-parameters,代码行数:11,代码来源:YamlSerializer.php

示例4: getPackageVersions

 /**
  * gets all versions
  *
  * @return array version numbers of packages
  */
 public function getPackageVersions()
 {
     if ($this->isDesiredVersion('self')) {
         $versions = [$this->getContextVersion()];
     } else {
         $versions = array();
     }
     $versions = $this->getInstalledPackagesVersion($versions);
     return $this->yamlDumper->dump($versions);
 }
开发者ID:alebon,项目名称:graviton,代码行数:15,代码来源:CoreVersionUtils.php

示例5: encode

 public function encode($input, $inline = 0, $dumpObjects = false)
 {
     static $dumper;
     if (null === $dumper) {
         $dumper = new YamlDumper();
     }
     if (defined('Symfony\\Component\\Yaml\\Yaml::DUMP_OBJECT')) {
         return $dumper->dump($input, $inline, 0, is_bool($dumpObjects) ? Yaml::DUMP_OBJECT : 0);
     }
     return $dumper->dump($input, $inline, 0, false, $dumpObjects);
 }
开发者ID:raphydev,项目名称:onep,代码行数:11,代码来源:YamlExtension.php

示例6: export

 /**
  * Export Menus
  */
 public function export()
 {
     $app = Bootstrap::getApplication();
     $settings = $app['settings'];
     if (!isset($settings['content']['menus'])) {
         return;
     }
     $this->readMenus();
     $dumper = new Dumper();
     remove_all_filters('wp_get_nav_menu_items');
     $helpers = $app['helpers'];
     $exportTaxonomies = $app['exporttaxonomies'];
     $exportPosts = $app['exportposts'];
     $baseUrl = get_option('siteurl');
     foreach ($settings['content']['menus'] as $menu) {
         $dir = WPBOOT_BASEPATH . '/bootstrap/menus/' . $menu;
         array_map('unlink', glob("{$dir}/*"));
         @mkdir($dir, 0777, true);
         $menuMeta = array();
         $menuMeta['locations'] = array();
         if (isset($this->navMenus[$menu])) {
             $menuMeta['locations'] = $this->navMenus[$menu]->locations;
         }
         $file = WPBOOT_BASEPATH . "/bootstrap/menus/{$menu}_manifest";
         file_put_contents($file, $dumper->dump($menuMeta, 4));
         $menuItems = wp_get_nav_menu_items($menu);
         foreach ($menuItems as $menuItem) {
             $obj = get_post($menuItem->ID, ARRAY_A);
             $obj['post_meta'] = get_post_meta($obj['ID']);
             switch ($obj['post_meta']['_menu_item_type'][0]) {
                 case 'post_type':
                     $postType = $obj['post_meta']['_menu_item_object'][0];
                     $postId = $obj['post_meta']['_menu_item_object_id'][0];
                     $objPost = get_post($postId);
                     $exportPosts->addPost($postType, $objPost->post_name);
                     break;
                 case 'taxonomy':
                     $id = $obj['post_meta']['_menu_item_object_id'][0];
                     $taxonomy = $obj['post_meta']['_menu_item_object'][0];
                     $objTerm = get_term($id, $taxonomy);
                     if (!is_wp_error($objTerm)) {
                         $exportTaxonomies->addTerm($taxonomy, $objTerm->slug);
                     }
                     break;
             }
             $helpers->fieldSearchReplace($obj, $baseUrl, Bootstrap::NEUTRALURL);
             $file = $dir . '/' . $menuItem->post_name;
             file_put_contents($file, $dumper->dump($obj, 4));
         }
     }
 }
开发者ID:eriktorsner,项目名称:wp-bootstrap,代码行数:54,代码来源:ExportMenus.php

示例7: __toString

 /**
  * All objects must have a string representation.
  *
  * @return string $this
  */
 public function __toString()
 {
     // Encoder
     self::$_Encoder = self::$_Encoder ?: new Dumper();
     // Encode config
     return self::$_Encoder->dump(iterator_to_array($this), 2);
 }
开发者ID:mast3rpee,项目名称:blw,代码行数:12,代码来源:YAML.php

示例8: testShortcutGetConfigurationMethod

 public function testShortcutGetConfigurationMethod()
 {
     $envs = ["environment" => "dev", "required_environments" => ["dev", "sandbox"]];
     file_put_contents(self::$testCreateDir . "/global.yml", $this->dumper->dump($envs));
     $this->configLoader->load();
     $this->assertTrue($this->configLoader->getConfig() === $this->configLoader->getConfiguration());
 }
开发者ID:j7mbo,项目名称:config-loader,代码行数:7,代码来源:YamlConfigLoaderTest.php

示例9: dump

public static function dump($array, $inline = 2, $indent = 4, $exceptionOnInvalidType = false, $objectSupport = false)
{
$yaml = new Dumper();
$yaml->setIndentation($indent);

return $yaml->dump($array, $inline, 0, $exceptionOnInvalidType, $objectSupport);
}
开发者ID:Ryu0621,项目名称:SaNaVi,代码行数:7,代码来源:Yaml.php

示例10: writeSplittedFile

 protected function writeSplittedFile($yaml_splitted, $file_output_prefix = '', $file_output_suffix = '', DrupalStyle $io)
 {
     $dumper = new Dumper();
     $io->info($this->trans('commands.yaml.split.messages.generating-split'));
     foreach ($yaml_splitted as $key => $value) {
         if ($file_output_prefix) {
             $key = $file_output_prefix . '.' . $key;
         }
         if ($file_output_suffix) {
             $key .= '.' . $file_output_suffix;
         }
         $filename = $key . '.yml';
         try {
             $yaml = $dumper->dump($value, 10);
         } catch (\Exception $e) {
             $io->error(sprintf('%s: %s', $this->trans('commands.yaml.merge.messages.error-generating'), $e->getMessage()));
             return;
         }
         try {
             file_put_contents($filename, $yaml);
         } catch (\Exception $e) {
             $io->error(sprintf('%s: %s', $this->trans('commands.yaml.merge.messages.error-writing'), $e->getMessage()));
             return;
         }
         $io->success(sprintf($this->trans('commands.yaml.split.messages.split-generated'), $filename));
     }
 }
开发者ID:mnico,项目名称:DrupalConsole,代码行数:27,代码来源:SplitCommand.php

示例11: convertToYamlString

 /**
  * @param \Box\TestScribe\InputHistory\InputHistoryData $historyData
  *
  * @return string
  */
 private function convertToYamlString(InputHistoryData $historyData)
 {
     $dumper = new Dumper();
     $data = $historyData->getData();
     $dataInYaml = $dumper->dump($data, 2);
     return $dataInYaml;
 }
开发者ID:jamescaldwell,项目名称:TestScribe,代码行数:12,代码来源:InputHistoryPersistence.php

示例12: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $yaml = new Parser();
     $dumper = new Dumper();
     $yaml_file = $input->getArgument('yaml-file');
     $yaml_key = $input->getArgument('yaml-key');
     $yaml_new_key = $input->getArgument('yaml-new-key');
     try {
         $yaml_parsed = $yaml->parse(file_get_contents($yaml_file));
     } catch (\Exception $e) {
         $io->error($this->trans('commands.yaml.merge.messages.error-parsing') . ': ' . $e->getMessage());
         return;
     }
     if (empty($yaml_parsed)) {
         $io->info(sprintf($this->trans('commands.yaml.merge.messages.wrong-parse'), $yaml_file));
     }
     $nested_array = $this->getNestedArrayHelper();
     $parents = explode(".", $yaml_key);
     $nested_array->replaceKey($yaml_parsed, $parents, $yaml_new_key);
     try {
         $yaml = $dumper->dump($yaml_parsed, 10);
     } catch (\Exception $e) {
         $io->error($this->trans('commands.yaml.merge.messages.error-generating') . ': ' . $e->getMessage());
         return;
     }
     try {
         file_put_contents($yaml_file, $yaml);
     } catch (\Exception $e) {
         $io->error($this->trans('commands.yaml.merge.messages.error-writing') . ': ' . $e->getMessage());
         return;
     }
     $io->info(sprintf($this->trans('commands.yaml.update.value.messages.updated'), $yaml_file));
 }
开发者ID:blasoliva,项目名称:DrupalConsole,代码行数:34,代码来源:UpdateKeyCommand.php

示例13: writeDataToFile

 public function writeDataToFile($params)
 {
     // shorthand
     $filename = $this->args[0];
     // what are we doing?
     $printer = new DataPrinter();
     $logParams = $printer->convertToString($params);
     $log = usingLog()->startAction("create YAML file '{$filename}' with contents '{$logParams}'");
     // create an instance of the Symfony YAML writer
     $writer = new Dumper();
     // create the YAML data
     $yamlData = $writer->dump($params, 2);
     if (!is_string($yamlData) || strlen($yamlData) < 6) {
         throw new E5xx_ActionFailed(__METHOD__, "unable to convert data to YAML");
     }
     // prepend the YAML marker
     $yamlData = '---' . PHP_EOL . $yamlData;
     // write the file
     //
     // the loose FALSE test here is exactly what we want, because we want to catch
     // both the situation when the write fails, and when there's zero bytes written
     if (!file_put_contents($filename, $yamlData)) {
         throw new E5xx_ActionFailed(__METHOD__, "unable to write file '{$filename}'");
     }
     // all done
     $log->endAction();
 }
开发者ID:datasift,项目名称:storyplayer,代码行数:27,代码来源:UsingYamlFile.php

示例14: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $yaml = new Parser();
     $dumper = new Dumper();
     $yaml_file = $input->getArgument('yaml-file');
     $yaml_key = $input->getArgument('yaml-key');
     $yaml_value = $input->getArgument('yaml-value');
     try {
         $yaml_parsed = $yaml->parse(file_get_contents($yaml_file));
     } catch (\Exception $e) {
         $output->writeln('[+] <error>' . $this->trans('commands.yaml.merge.messages.error-parsing') . ': ' . $e->getMessage() . '</error>');
         return;
     }
     if (empty($yaml_parsed)) {
         $output->writeln('[+] <info>' . sprintf($this->trans('commands.yaml.merge.messages.wrong-parse'), $yaml_file) . '</info>');
     }
     $nested_array = $this->getNestedArrayHelper();
     $parents = explode(".", $yaml_key);
     $nested_array->setValue($yaml_parsed, $parents, $yaml_value, true);
     try {
         $yaml = $dumper->dump($yaml_parsed, 10);
     } catch (\Exception $e) {
         $output->writeln('[+] <error>' . $this->trans('commands.yaml.merge.messages.error-generating') . ': ' . $e->getMessage() . '</error>');
         return;
     }
     try {
         file_put_contents($yaml_file, $yaml);
     } catch (\Exception $e) {
         $output->writeln('[+] <error>' . $this->trans('commands.yaml.merge.messages.error-writing') . ': ' . $e->getMessage() . '</error>');
         return;
     }
     $output->writeln('[+] <info>' . sprintf($this->trans('commands.yaml.update.value.messages.updated'), $yaml_file) . '</info>');
 }
开发者ID:legovaer,项目名称:DrupalConsole,代码行数:33,代码来源:UpdateValueCommand.php

示例15: buildConfigurationForm

  /**
   * {@inheritdoc}
   */
  public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
    $form = parent::buildConfigurationForm($form, $form_state);

    $form['title'] = array(
      '#type' => 'checkbox',
      '#title' => $this->t('Index title attribute'),
      '#description' => $this->t('If set, the contents of title attributes will be indexed.'),
      '#default_value' => $this->configuration['title'],
    );

    $form['alt'] = array(
      '#type' => 'checkbox',
      '#title' => $this->t('Index alt attribute'),
      '#description' => $this->t('If set, the alternative text of images will be indexed.'),
      '#default_value' => $this->configuration['alt'],
    );

    $dumper = new Dumper();
    $tags = $dumper->dump($this->configuration['tags'], 2);
    $tags = str_replace('\r\n', "\n", $tags);
    $tags = str_replace('"', '', $tags);

    $t_args['@url'] = Url::fromUri('https://en.wikipedia.org/wiki/YAML')->toString();
    $form['tags'] = array(
      '#type' => 'textarea',
      '#title' => $this->t('Tag boosts'),
      '#description' => $this->t('Specify special boost values for certain HTML elements, in <a href="@url">YAML file format</a>. The boost values of nested elements are multiplied, elements not mentioned will have the default boost value of 1. Assign a boost of 0 to ignore the text content of that HTML element.', $t_args),
      '#default_value' => $tags,
    );

    return $form;
  }
开发者ID:jkyto,项目名称:agolf,代码行数:35,代码来源:HtmlFilter.php


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