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


PHP Yaml\Dumper类代码示例

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


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

示例1: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $result = '';
     $time_start = microtime(true);
     $dbname = $input->getArgument('name');
     $yaml = new Parser();
     $homesteadFile = $yaml->parse(file_get_contents(getenv("HOME") . '/.homestead/Homestead.yaml'));
     foreach ($homesteadFile['databases'] as $key => $db) {
         if ($db === $dbname) {
             unset($homesteadFile['databases'][$key]);
         }
     }
     $dumper = new Dumper();
     $yaml = $dumper->dump($homesteadFile, 2);
     file_put_contents(getenv("HOME") . '/.homestead/Homestead.yaml', $yaml);
     $output->writeln("\nCurrent Databases:");
     foreach ($homesteadFile['databases'] as $db) {
         $output->writeln("\n<comment>" . $db . "</comment>");
     }
     $output->writeln('halting homestead...');
     exec('cd ~/Homestead && vagrant halt', $result);
     $output->writeln('restarting homestead...');
     exec('cd ~/Homestead && vagrant up --provision', $result);
     $time_end = microtime(true);
     $time = $time_end - $time_start;
     $output->writeln("\nCompleted in: " . $time . " seconds");
 }
开发者ID:mlantz,项目名称:homeforge,代码行数:27,代码来源:DatabaseRemoveCommand.php

示例2: execute

 /**
  * Executes a command via CLI
  *
  * @param Console\Input\InputInterface $input
  * @param Console\Output\OutputInterface $output
  *
  * @return int|null|void
  */
 protected function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
 {
     $tempFolder = $input->getOption('temp-folder');
     $fs = new Filesystem();
     $version = $input->getArgument('version');
     $chamiloRoot = $input->getArgument('chamilo_root');
     if ($version == '111') {
         $file = $chamiloRoot . 'app/config/migrations.yml';
         require_once $chamiloRoot . 'app/Migrations/AbstractMigrationChamilo.php';
         $this->migrationFile = $file;
         return 1;
     }
     if ($version == '110') {
         $file = $chamiloRoot . 'app/config/migrations110.yml';
         $this->migrationFile = $file;
         return 1;
     }
     require_once $chamiloRoot . 'app/Migrations/AbstractMigrationChamilo.php';
     $migrationsFolder = $tempFolder . '/Migrations/';
     if (!$fs->exists($migrationsFolder)) {
         $fs->mkdir($migrationsFolder);
     }
     $migrations = array('name' => 'Chamilo Migrations', 'migrations_namespace' => 'Application\\Migrations\\Schema\\V111', 'table_name' => 'version', 'migrations_directory' => $migrationsFolder);
     $dumper = new Dumper();
     $yaml = $dumper->dump($migrations, 1);
     $file = $migrationsFolder . 'migrations.yml';
     file_put_contents($file, $yaml);
     $migrationPathSource = __DIR__ . '/../../../Chash/Migrations/';
     $fs->mirror($migrationPathSource, $migrationsFolder);
     // migrations_directory
     $output->writeln("<comment>Chash migrations.yml saved: {$file}</comment>");
     $this->migrationFile = $file;
 }
开发者ID:chamilo,项目名称:chash,代码行数:41,代码来源:SetupCommand.php

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $message = $this->getMessageHelper();
     $application = $this->getApplication();
     $sitesDirectory = $application->getConfig()->getSitesDirectory();
     if (!is_dir($sitesDirectory)) {
         $message->addErrorMessage(sprintf($this->trans('commands.site.debug.messages.directory-not-found'), $sitesDirectory));
         return;
     }
     // Get the target argument
     $target = $input->getArgument('target');
     if ($target && $application->getConfig()->loadTarget($target)) {
         $targetConfig = $application->getConfig()->getTarget($target);
         $dumper = new Dumper();
         $yaml = $dumper->dump($targetConfig, 5);
         $output->writeln($yaml);
         return;
     }
     $finder = new Finder();
     $finder->in($sitesDirectory);
     $finder->name("*.yml");
     $table = new Table($output);
     $table->setHeaders([$this->trans('commands.site.debug.messages.site'), $this->trans('commands.site.debug.messages.host'), $this->trans('commands.site.debug.messages.root')]);
     foreach ($finder as $site) {
         $siteConfiguration = $site->getBasename('.yml');
         $application->getConfig()->loadSite($siteConfiguration);
         $environments = $application->getConfig()->get('sites.' . $siteConfiguration);
         foreach ($environments as $env => $config) {
             $table->addRow([$siteConfiguration . '.' . $env, array_key_exists('host', $config) ? $config['host'] : 'local', array_key_exists('root', $config) ? $config['root'] : '']);
         }
     }
     $table->render();
 }
开发者ID:GoZOo,项目名称:DrupalConsole,代码行数:36,代码来源:DebugCommand.php

示例9: respondWithArray

 protected function respondWithArray(array $array, array $headers = [])
 {
     $mimeTypeRaw = Input::server('HTTP_ACCEPT', '*/*');
     // If its empty or has */* then default to JSON
     if ($mimeTypeRaw === '*/*') {
         $mimeType = 'application/json';
     } else {
         // You'll probably want to do something intelligent with charset if provided
         // This chapter just assumes UTF8 everything everywhere
         $mimeParts = (array) explode(';', $mimeTypeRaw);
         $mimeType = strtolower($mimeParts[0]);
     }
     switch ($mimeType) {
         case 'application/json':
             $contentType = 'application/json';
             $content = json_encode($array);
             break;
         case 'application/x-yaml':
             $contentType = 'application/x-yaml';
             $dumper = new YamlDumper();
             $content = $dumper->dump($array, 2);
             break;
         default:
             $contentType = 'application/json';
             $content = json_encode(['error' => ['code' => static::CODE_INVALID_MIME_TYPE, 'http_code' => 415, 'message' => sprintf('Content of type %s is not supported.', $mimeType)]]);
     }
     $response = Response::make($content, $this->statusCode, $headers);
     $response->header('Content-Type', $contentType);
     return $response;
 }
开发者ID:rcuvgd,项目名称:Build-API..,代码行数:30,代码来源:ApiController.php

示例10: update

 /**
  */
 public function update()
 {
     echo 'Update Migrations: ';
     $dirIterator = new DirectoryIterator($this->dbFilesDir);
     $files = [];
     $installed = [];
     $i = 0;
     foreach ($dirIterator as $dir) {
         $file = $dir->getFilename();
         if ($file == '.' || $file == '..' || !preg_match('/\\.sql$/', $file)) {
             continue;
         }
         if (in_array($file, $this->successMigration)) {
             $installed[] = $file;
             continue;
         }
         $files[$i]['path'] = $dir->getPathname();
         $files[$i]['name'] = $file;
         $i++;
     }
     usort($files, function ($val1, $val2) {
         return strcmp($val1['name'], $val2['name']);
     });
     foreach ($files as $file) {
         if ($this->install($file['path'])) {
             $installed[] = $file['name'];
             echo PHP_EOL . $file['name'] . ': Success';
         } else {
             echo PHP_EOL . $file['name'] . ': Fail';
             break;
         }
     }
     $dumper = new Dumper();
     file_put_contents($this->ymlFilePath, $dumper->dump($installed));
 }
开发者ID:valous,项目名称:database-installer,代码行数:37,代码来源:Engine.php

示例11: export

 public function export($filename)
 {
     $fname = basename($filename);
     $this->output->writeln("Exporting to <info>" . $filename . "</info>...");
     list($name, $locale, $type) = explode('.', $fname);
     switch ($type) {
         case 'yml':
             $data = $this->getContainer()->get('server_grove_translation_editor.storage_manager')->getCollection()->findOne(array('filename' => $filename));
             if (!$data) {
                 $this->output->writeln("Could not find data for this locale");
                 return;
             }
             foreach ($data['entries'] as $key => $val) {
                 if (empty($val)) {
                     unset($data['entries'][$key]);
                 }
             }
             $dumper = new Dumper();
             $result = $dumper->dump($data['entries'], 1);
             $this->output->writeln("  Writing " . count($data['entries']) . " entries to {$filename}");
             if (!$this->input->getOption('dry-run')) {
                 file_put_contents($filename, $result);
             }
             break;
         case 'xliff':
             $this->output->writeln("  Skipping, not implemented");
             break;
     }
 }
开发者ID:TobeyYang,项目名称:TranslationEditorBundle,代码行数:29,代码来源:ExportCommand.php

示例12: export

 /**
  * export
  *
  * @param bool $ignoreTrack
  * @param bool $prefixOnly
  * @param bool $text
  *
  * @return mixed|string
  */
 public function export($ignoreTrack = false, $prefixOnly = false, $text = true)
 {
     $tableObject = new Table();
     $trackObject = new Track();
     $tables = $prefixOnly ? $tableObject->listSite() : $tableObject->listAll();
     $track = $trackObject->getTrackList();
     $result = array();
     $this->tableCount = 0;
     $this->rowCount = 0;
     foreach ($tables as $table) {
         $trackStatus = $track->get('table.' . $table, 'none');
         if ($trackStatus == 'none' && !$ignoreTrack) {
             continue;
         }
         $result[$table] = $this->getCreateTable($table);
         $this->tableCount++;
         if ($trackStatus == 'all' || $ignoreTrack) {
             $insert = $this->getInserts($table);
             if ($insert) {
                 $result[$table] = array_merge($result[$table], $insert);
             }
         }
     }
     $this->state->set('dump.count.tables', $this->tableCount);
     $this->state->set('dump.count.rows', $this->rowCount);
     $dumper = new Dumper();
     $result = json_decode(json_encode($result), true);
     return $text ? $dumper->dump($result, 3, 0, false, true) : $result;
 }
开发者ID:lyrasoft,项目名称:lyrasoft.github.io,代码行数:38,代码来源:YamlExporter.php

示例13: 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

示例14: dumpToString

 /**
  * @param mixed $value
  *
  * @return string
  */
 public function dumpToString($value)
 {
     $dumper = new Dumper();
     $dumper->setIndentation(2);
     $yamlString = $dumper->dump($value, 15);
     return $yamlString;
 }
开发者ID:jamescaldwell,项目名称:TestScribe,代码行数:12,代码来源:YamlUtil.php

示例15: createAction

 /**
  * @Route("/new", name="wiki_create")
  * @Method("POST")
  */
 public function createAction(Request $request)
 {
     $name = $request->request->get('name');
     $user = $this->getUser();
     $slug = $request->request->get('slug');
     if (empty($slug)) {
         $slug = $this->get('slug')->slugify($name);
     }
     $repositoryService = $this->get('app.repository');
     $repository = $repositoryService->createRepository($slug);
     $adminRepository = $repositoryService->getRepository($this->getParameter('app.admin_repository'));
     $path = $repository->getWorkingDir();
     $fs = new Filesystem();
     $fs->dumpFile($path . '/index.md', '# ' . $name);
     $repository->setDescription($name);
     $repository->run('add', array('-A'));
     $repository->run('commit', array('-m Initial commit', '--author="' . $user->getName() . ' <' . $user->getEmail() . '>"'));
     $username = $user->getUsername();
     $adminPath = $adminRepository->getWorkingDir();
     $yamlDumper = new Dumper();
     $yamlString = $yamlDumper->dump(array('groups' => null, 'owners' => array($username), 'users' => array($username => 'RW+')), 3);
     $fs->dumpFile($adminPath . '/wikis/' . $slug . '.yml', $yamlString);
     $adminMessage = sprintf('Added wiki %s', $slug);
     $adminRepository->run('add', array('-A'));
     $adminRepository->run('commit', array('-m ' . $adminMessage, '--author="' . $user->getName() . ' <' . $user->getEmail() . '>"'));
     return $this->redirectToRoute('page_show', array('slug' => $slug));
 }
开发者ID:gitdown-wiki,项目名称:gitdown-wiki,代码行数:31,代码来源:WikiController.php


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