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


PHP Yaml::encode方法代码示例

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


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

示例1: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $messageHelper = $this->getHelperSet()->get('message');
     $directory = $input->getArgument('directory');
     if (!$directory) {
         $config = $this->getConfigFactory()->get('system.file');
         $directory = $config->get('path.temporary') ?: file_directory_temp();
         $directory .= '/' . CONFIG_STAGING_DIRECTORY;
     }
     if (!is_dir($directory)) {
         mkdir($directory, 0777, true);
     }
     $config_export_file = $directory . '/config.tar.gz';
     file_unmanaged_delete($config_export_file);
     try {
         $archiver = new ArchiveTar($config_export_file, 'gz');
         $this->configManager = $this->getConfigManager();
         // Get raw configuration data without overrides.
         foreach ($this->configManager->getConfigFactory()->listAll() as $name) {
             $archiver->addString("{$name}.yml", Yaml::encode($this->configManager->getConfigFactory()->get($name)->getRawData()));
         }
         $this->targetStorage = $this->getConfigStorage();
         // Get all override data from the remaining collections.
         foreach ($this->targetStorage->getAllCollectionNames() as $collection) {
             $collection_storage = $this->targetStorage->createCollection($collection);
             foreach ($collection_storage->listAll() as $name) {
                 $archiver->addString(str_replace('.', '/', $collection) . "/{$name}.yml", Yaml::encode($collection_storage->read($name)));
             }
         }
     } catch (\Exception $e) {
         $output->writeln('[+] <error>' . $e->getMessage() . '</error>');
         return;
     }
     $messageHelper->addSuccessMessage(sprintf($this->trans('commands.config.export.messages.directory'), $config_export_file));
 }
开发者ID:amira2r,项目名称:DrupalConsole,代码行数:38,代码来源:ConfigExportCommand.php

示例2: buildForm

 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state, $config_name = '')
 {
     $config = $this->config($config_name);
     if ($config === FALSE || $config->isNew()) {
         drupal_set_message(t('Config @name does not exist in the system.', array('@name' => $config_name)), 'error');
         return;
     }
     $data = $config->get();
     if (empty($data)) {
         drupal_set_message(t('Config @name exists but has no data.', array('@name' => $config_name)), 'warning');
         return;
     }
     try {
         $output = Yaml::encode($data);
     } catch (InvalidDataTypeException $e) {
         drupal_set_message(t('Invalid data detected for @name : %error', array('@name' => $config_name, '%error' => $e->getMessage())), 'error');
         return;
     }
     $form['current'] = array('#type' => 'details', '#title' => $this->t('Current value for %variable', array('%variable' => $config_name)), '#attributes' => array('class' => array('container-inline')));
     $form['current']['value'] = array('#type' => 'item', '#markup' => dpr($output, TRUE));
     $form['name'] = array('#type' => 'value', '#value' => $config_name);
     $form['new'] = array('#type' => 'textarea', '#title' => $this->t('New value'), '#default_value' => $output, '#rows' => 24, '#required' => TRUE);
     $form['actions'] = array('#type' => 'actions');
     $form['actions']['submit'] = array('#type' => 'submit', '#value' => $this->t('Save'));
     $form['actions']['cancel'] = array('#type' => 'link', '#title' => $this->t('Cancel'), '#url' => $this->buildCancelLinkUrl());
     return $form;
 }
开发者ID:isramv,项目名称:camp-gdl,代码行数:30,代码来源:ConfigEditor.php

示例3: geViewByID

 /**
  * @param $output         OutputInterface
  * @param $table          TableHelper
  * @param $resource_id    String
  */
 private function geViewByID($output, $table, $view_id)
 {
     $entity_manager = $this->getEntityManager();
     $view = $entity_manager->getStorage('view')->load($view_id);
     if (empty($view)) {
         $output->writeln('[+] <error>' . sprintf($this->trans('commands.views.debug.messages.not-found'), $view_id) . '</error>');
         return false;
     }
     $configuration = array();
     $configuration[$this->trans('commands.views.debug.messages.view-id')] = $view->get('id');
     $configuration[$this->trans('commands.views.debug.messages.view-name')] = (string) $view->get('label');
     $configuration[$this->trans('commands.views.debug.messages.tag')] = $view->get('tag');
     $configuration[$this->trans('commands.views.debug.messages.status')] = $view->status() ? $this->trans('commands.common.status.enabled') : $this->trans('commands.common.status.disabled');
     $configuration[$this->trans('commands.views.debug.messages.description')] = $view->get('description');
     $configurationEncoded = Yaml::encode($configuration);
     $output->writeln($configurationEncoded);
     $table->render($output);
     $table->setHeaders([$this->trans('commands.views.debug.messages.display-id'), $this->trans('commands.views.debug.messages.display-name'), $this->trans('commands.views.debug.messages.display-description'), $this->trans('commands.views.debug.messages.display-paths')]);
     $displays = $this->getDisplaysList($view);
     $paths = $this->getDisplayPaths($view);
     $output->writeln('<info>' . sprintf($this->trans('commands.views.debug.messages.display-list'), $view_id) . '</info>');
     foreach ($displays as $display_id => $display) {
         $table->addRow([$display_id, $display['name'], $display['description'], $this->getDisplayPaths($view, $display_id)]);
     }
     $table->render($output);
 }
开发者ID:xsw3ws,项目名称:DrupalConsole,代码行数:31,代码来源:ViewsDebugCommand.php

示例4: mergeInfoFile

 /**
  * Merges an info file into a package's info file.
  *
  * @param string $package_info
  *   The Yaml encoded package info.
  * @param string $info_file_uri
  *   The info file's URI.
  */
 protected function mergeInfoFile($package_info, $info_file_uri)
 {
     $package_info = Yaml::decode($package_info);
     /** @var \Drupal\Core\Extension\InfoParserInterface $existing_info */
     $existing_info = \Drupal::service('info_parser')->parse($info_file_uri);
     return Yaml::encode($this->featuresManager->mergeInfoArray($existing_info, $package_info));
 }
开发者ID:selwynpolit,项目名称:d8_test2,代码行数:15,代码来源:FeaturesGenerationMethodBase.php

示例5: mergeInfoFile

 /**
  * Merges an info file into a package's info file.
  *
  * @param string $package_info
  *   The Yaml encoded package info.
  * @param string $info_file_uri
  *   The info file's URI.
  */
 protected function mergeInfoFile($package_info, $info_file_uri) {
   $package_info = Yaml::decode($package_info);
   $existing_info = \Drupal::service('info_parser')->parse($info_file_uri);
   // Ensure the entire 'features' data is replaced by new data.
   unset($existing_info['features']);
   return Yaml::encode($this->featuresManager->arrayMergeUnique($existing_info, $package_info));
 }
开发者ID:jeetendrasingh,项目名称:manage_profile,代码行数:15,代码来源:FeaturesGenerationMethodBase.php

示例6: getRestByID

 /**
  * @param $output         OutputInterface
  * @param $table          TableHelper
  * @param $config_name    String
  */
 private function getRestByID($output, $table, $resource_id)
 {
     // Get the list of enabled and disabled resources.
     $config = $this->getRestDrupalConfig();
     $resourcePluginManager = $this->getPluginManagerRest();
     $plugin = $resourcePluginManager->getInstance(array('id' => $resource_id));
     if (empty($plugin)) {
         $output->writeln('[+] <error>' . sprintf($this->trans('commands.rest.debug.messages.not-found'), $resource_id) . '</error>');
         return false;
     }
     $resource = $plugin->getPluginDefinition();
     $configuration = array();
     $configuration[$this->trans('commands.rest.debug.messages.id')] = $resource['id'];
     $configuration[$this->trans('commands.rest.debug.messages.label')] = (string) $resource['label'];
     $configuration[$this->trans('commands.rest.debug.messages.canonical_url')] = $resource['uri_paths']['canonical'];
     $configuration[$this->trans('commands.rest.debug.messages.status')] = isset($config[$resource['id']]) ? $this->trans('commands.rest.debug.messages.enabled') : $this->trans('commands.rest.debug.messages.disabled');
     $configuration[$this->trans('commands.rest.debug.messages.provider')] = $resource['provider'];
     $configurationEncoded = Yaml::encode($configuration);
     $output->writeln($configurationEncoded);
     $table->render($output);
     $table->setHeaders([$this->trans('commands.rest.debug.messages.rest-state'), $this->trans('commands.rest.debug.messages.supported-formats'), $this->trans('commands.rest.debug.messages.supported_auth')]);
     foreach ($config[$resource['id']] as $method => $settings) {
         $table->addRow([$method, implode(', ', $settings['supported_formats']), implode(', ', $settings['supported_auth'])]);
     }
     $table->render($output);
 }
开发者ID:palantirnet,项目名称:DrupalConsole,代码行数:31,代码来源:RestDebugCommand.php

示例7: execute

 public function execute()
 {
     $file = $this->getUnaliasedPath($this->configuration['in']);
     $data = file_exists($file) ? YAML::decode(file_get_contents($file)) : [];
     $keys = explode('/', $this->configuration['key']);
     NestedArray::setValue($data, $keys, $this->configuration['value']);
     file_put_contents($file, YAML::encode($data));
 }
开发者ID:nishantkumar155,项目名称:drupal8.crackle,代码行数:8,代码来源:Define.php

示例8: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     $this->info = array('type' => 'profile', 'core' => \Drupal::CORE_COMPATIBILITY, 'name' => 'Distribution profile', 'distribution' => array('name' => 'My Distribution', 'langcode' => $this->langcode, 'install' => array('theme' => 'bartik')));
     // File API functions are not available yet.
     $path = $this->siteDirectory . '/profiles/mydistro';
     mkdir($path, 0777, TRUE);
     file_put_contents("{$path}/mydistro.info.yml", Yaml::encode($this->info));
     parent::setUp();
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:12,代码来源:DistributionProfileTranslationTest.php

示例9: getYamlConfig

 /**
  * @param $config_name String
  *
  * @return array
  */
 protected function getYamlConfig($config_name)
 {
     $configStorage = $this->getConfigStorage();
     if ($configStorage->exists($config_name)) {
         $configuration = $configStorage->read($config_name);
         $configurationEncoded = Yaml::encode($configuration);
     }
     return $configurationEncoded;
 }
开发者ID:amira2r,项目名称:DrupalConsole,代码行数:14,代码来源:ConfigEditCommand.php

示例10: setUp

 protected function setUp()
 {
     $this->info = array('type' => 'profile', 'core' => \Drupal::CORE_COMPATIBILITY, 'name' => 'Override standard', 'hidden' => TRUE);
     // File API functions are not available yet.
     $path = $this->siteDirectory . '/profiles/standard';
     mkdir($path, 0777, TRUE);
     file_put_contents("{$path}/standard.info.yml", Yaml::encode($this->info));
     parent::setUp();
 }
开发者ID:HakS,项目名称:drupal8_training,代码行数:9,代码来源:SingleVisibleProfileTest.php

示例11: getConfigurationByName

 /**
  * @param $output         OutputInterface
  * @param $table          TableHelper
  * @param $config_name    String
  */
 private function getConfigurationByName($output, $table, $config_name)
 {
     $configStorage = $this->getConfigStorage();
     if ($configStorage->exists($config_name)) {
         $table->setHeaders([$config_name]);
         $configuration = $configStorage->read($config_name);
         $configurationEncoded = Yaml::encode($configuration);
         $table->addRow([$configurationEncoded]);
     }
     $table->render($output);
 }
开发者ID:palantirnet,项目名称:DrupalConsole,代码行数:16,代码来源:ConfigDebugCommand.php

示例12: addRouteAttributes

 protected function addRouteAttributes($attr, $attributes = null)
 {
     foreach ($attr as $key => $value) {
         if (is_array($value)) {
             $attributes[] = [' ' . $key, str_replace('- ', '', Yaml::encode($value))];
         } else {
             $attributes[] = [' ' . $key, $value];
         }
     }
     return $attributes;
 }
开发者ID:blasoliva,项目名称:DrupalConsole,代码行数:11,代码来源:DebugCommand.php

示例13: convert

 /**
  * {@inheritdoc}
  */
 public function convert(TargetInterface $target)
 {
     parent::convert($target);
     if ($this->defaults && $this->schema) {
         $group = $target->id() . '.settings';
         $this->write($target, InstallStorage::CONFIG_INSTALL_DIRECTORY . '/' . $group . '.yml', Yaml::encode($this->defaults));
         $this->defaults = [];
         $schema = [$group => ['type' => 'mapping', 'label' => (string) $this->t('Settings'), 'mapping' => $this->schema]];
         $this->write($target, InstallStorage::CONFIG_SCHEMA_DIRECTORY . '/' . $target->id() . '.schema.yml', Yaml::encode($schema));
         $this->schema = [];
     }
 }
开发者ID:nishantkumar155,项目名称:drupal8.crackle,代码行数:15,代码来源:VariableGet.php

示例14: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $key = $input->getArgument('key');
     if ($key) {
         $state = $this->getState();
         $io->writeln(sprintf('<info>%s:</info>', $key));
         $io->writeln(Yaml::encode($state->get($key)));
         return;
     }
     $this->showAllStateKeys($io);
 }
开发者ID:desarrollolibre,项目名称:DrupalConsole,代码行数:15,代码来源:DebugCommand.php

示例15: getTestByID

 /**
  * @param $output         OutputInterface
  * @param $table          TableHelper
  * @param $config_name    String
  */
 private function getTestByID($output, $table, $test_id)
 {
     $testing_groups = $this->getTestDiscovery()->getTestClasses(null);
     foreach ($testing_groups as $testing_group => $tests) {
         foreach ($tests as $key => $test) {
             break;
         }
     }
     $configurationEncoded = Yaml::encode($test);
     $table->addRow([$configurationEncoded]);
     $table->render($output);
 }
开发者ID:paucku,项目名称:DrupalConsole,代码行数:17,代码来源:TestDebugCommand.php


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