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


PHP YAML类代码示例

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


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

示例1: testDecoding

 public function testDecoding()
 {
     $formatter = new YAML();
     $data = array('name' => 'Joe', 'age' => 21, 'employed' => true);
     $raw = file_get_contents(__DIR__ . '/fixtures/joe.yaml');
     $this->assertEquals($data, $formatter->decode($raw));
 }
开发者ID:gekt,项目名称:www,代码行数:7,代码来源:YAMLTest.php

示例2: control_panel__add_routes

 public function control_panel__add_routes()
 {
     $app = \Slim\Slim::getInstance();
     $app->get('/globes', function () use($app) {
         authenticateForRole('admin');
         doStatamicVersionCheck($app);
         Statamic_View::set_templates(array('globes-overview'), __DIR__ . '/templates');
         $data = $this->tasks->getThemeSettings();
         $app->render(null, array('route' => 'globes', 'app' => $app) + $data);
     })->name('globes');
     // Update global vars
     $app->post('/globes/update', function () use($app) {
         authenticateForRole('admin');
         doStatamicVersionCheck($app);
         $data = $this->tasks->getThemeSettings();
         $vars = Request::fetch('pageglobals');
         foreach ($vars as $name => $var) {
             foreach ($data['globals'] as $key => $item) {
                 if ($item['name'] === $name) {
                     $data['globals'][$key]['value'] = $var;
                 }
             }
         }
         File::put($this->tasks->getThemeSettingsPath(), YAML::dump($data, 1));
         $app->flash('success', Localization::fetch('update_success'));
         $app->redirect($app->urlFor('globes'));
     });
 }
开发者ID:QDigitalStudio,项目名称:statamic-globes,代码行数:28,代码来源:hooks.globes.php

示例3: fetch

 /**
  * Fetch an L10n content string
  *
  * @param $key      string  YAML key of the desired text string
  * @param $language string  Optionally override the desired language
  * @return mixed
  */
 public static function fetch($key, $language = null, $lower = false)
 {
     $app = \Slim\Slim::getInstance();
     $language = $language ? $language : Config::getCurrentLanguage();
     $value = $key;
     /*
     |--------------------------------------------------------------------------
     | Check for new language
     |--------------------------------------------------------------------------
     |
     | English is loaded by default. If requesting a language not already
     | cached, go grab it.
     |
     */
     if (!isset($app->config['_translations'][$language])) {
         $app->config['_translations'][$language] = YAML::parse(Config::getTranslation($language));
     }
     /*
     |--------------------------------------------------------------------------
     | Resolve translation
     |--------------------------------------------------------------------------
     |
     | If the set language is found and the key exists, return it. Falls back to
     | English, and then falls back to the slug-style key itself.
     |
     */
     if (array_get($app->config['_translations'][$language]['translations'], $value, false)) {
         $value = array_get($app->config['_translations'][$language]['translations'], $value);
     } else {
         $value = array_get($app->config['_translations']['en']['translations'], $value, $value);
     }
     return $lower ? strtolower($value) : $value;
 }
开发者ID:nob,项目名称:joi,代码行数:40,代码来源:localization.php

示例4: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $method = $input->getOption('method');
     switch ($method) {
         case 'drush':
             $alias = $input->getOption('alias');
             if (empty($alias)) {
                 throw new RuntimeException("You must supply a valid Drush alias using the --alias argument.");
             }
             if ($alias[0] != '@') {
                 throw new RuntimeException("Invalid alias \"{$alas}\".");
             }
             $config = array('fetch-method' => $method, 'fetch-alias' => $alias);
             break;
         case 'dump-n-config':
             $config = array('fetch-method' => $method, 'fetch-dumpfile' => $input->getOption('dumpfile'), 'fetch-staging' => $input->getOption('staging'));
             break;
         default:
             throw new RuntimeException("Unknown fetching method \"{$method}\".");
     }
     $fileName = 'tests/proctor/drupal.yml';
     $dirName = dirname($fileName);
     if (!file_exists($dirName) && !mkdir($dirName, 0777, true)) {
         throw new RuntimeException("Could not create {$dirName}", 1);
     }
     $config = YAML::dump($config);
     if (file_put_contents($fileName, $config) === false) {
         throw new RuntimeException("Could not write {$fileName}", 1);
     }
     $output->writeln("<info>Wrote " . $fileName . "</info>");
 }
开发者ID:xendk,项目名称:proctor,代码行数:31,代码来源:SetupDrupal.php

示例5: __construct

 /**
  * Singleton pattern.
  *
  * @throws Exceptions\DatacashRequestException
  */
 protected function __construct()
 {
     // Get the default configurations.
     $env_config = YAML::parse(file_get_contents(__DIR__ . "/../../config/environment.yaml"));
     $datacash_config = YAML::parse(file_get_contents(__DIR__ . "/../../config/datacash.yaml"));
     $datacash_config = $datacash_config[$env_config['environment']]['parameters'];
     // Set the configurations for the request.
     if (!empty($datacash_config['server_url'])) {
         $this->hostName = $datacash_config['server_url'];
     } else {
         throw new DatacashRequestException("Not set or invalid hostname.");
     }
     if (!empty($datacash_config['timeout'])) {
         $this->timeout = $datacash_config['timeout'];
     }
     if (!empty($datacash_config['datacash_network_ssl_path'])) {
         $this->sslCertPath = $datacash_config['datacash_network_ssl_path'];
         // Do not set cert SSL verifiation if we don't have a certificate.
         if (!empty($datacash_config['datacash_network_ssl_verify'])) {
             $this->sslVerify = $datacash_config['datacash_network_ssl_verify'];
         }
     } else {
         $this->sslVerify = FALSE;
     }
     // Use proxy only if proxy url is available.
     if (!empty($datacash_config['proxy_url'])) {
         $this->proxyUrl = $datacash_config['proxy_url'];
     }
 }
开发者ID:abghosh82,项目名称:datacash_payment_library,代码行数:34,代码来源:SSLAgent.php

示例6: go

 public function go()
 {
     //$feed = file_get_contents($_SERVER['DOCUMENT_ROOT'].'/_add-ons/wordpress/wp_posts.xml');
     //$items = simplexml_load_string($feed);
     $posts_object = simplexml_load_file($_SERVER['DOCUMENT_ROOT'] . '/_add-ons/wordpress/roobottom_old_posts.xml');
     $posts = object_to_array($posts_object);
     $yaml_path = $_SERVER['DOCUMENT_ROOT'] . '/_content/01-blog/';
     foreach ($posts['table'] as $post) {
         if ($post['column'][8] == "publish") {
             $slug = Slug::make($post['column'][5]);
             $slug = preg_replace('/[^a-z\\d]+/i', '-', $slug);
             if (substr($slug, -1) == '-') {
                 $slug = substr($slug, 0, -1);
             }
             $date = date('Y-m-d-Hi', strtotime($post['column'][3]));
             $file = $date . "-" . $slug . ".md";
             if (!File::exists($yaml_path . $file)) {
                 $yaml = [];
                 $yaml['title'] = $post['column'][5];
                 $content = $post['column'][4];
                 $markdown = new HTML_To_Markdown($content, array('header_style' => 'atx'));
                 File::put($yaml_path . $file, YAML::dump($yaml) . '---' . "\n" . $markdown);
             }
             echo $slug . "-" . $date;
             echo "<br/><hr/><br/>";
         }
     }
     return "ok";
 }
开发者ID:roobottom,项目名称:roobottom-statamic,代码行数:29,代码来源:pi.wordpress.php

示例7: getRedirectUrl

 /**
  * Get datacash redirect URL for payment page.
  *
  * @return string
  */
 public function getRedirectUrl()
 {
     // Get the default configurations.
     $env_config = YAML::parse(file_get_contents(__DIR__ . "/../../config/environment.yaml"));
     $datacash_config = YAML::parse(file_get_contents(__DIR__ . "/../../config/datacash.yaml"));
     $datacash_config = $datacash_config[$env_config['environment']]['parameters'];
     return $datacash_config['redirect_url'] . $this->HpsTxn->session_id->getValue();
 }
开发者ID:abghosh82,项目名称:datacash_payment_library,代码行数:13,代码来源:Response.php

示例8: set

 /**
  * Sets the current environment to the given $environment
  *
  * @param string  $environment  Environment to set
  * @param array  $config  Config to set to
  * @return void
  */
 public static function set($environment, &$config)
 {
     $config['environment'] = $environment;
     $config['is_' . $environment] = true;
     $environment_config = YAML::parse("_config/environments/{$environment}.yaml");
     if (is_array($environment_config)) {
         $config = array_merge($config, $environment_config);
     }
 }
开发者ID:andorpandor,项目名称:git-deploy.eu2.frbit.com-yr-prototype,代码行数:16,代码来源:_environment.php

示例9: set

 /**
  * Sets the current environment to the given $environment
  *
  * @param string  $environment  Environment to set
  * @return void
  */
 public static function set($environment)
 {
     $app = \Slim\Slim::getInstance();
     $app->config['environment'] = $environment;
     $app->config['is_' . $environment] = TRUE;
     $environment_config = YAML::parse("_config/environments/{$environment}.yaml");
     if (is_array($environment_config)) {
         $app->config = array_merge($app->config, $environment_config);
     }
 }
开发者ID:nob,项目名称:joi,代码行数:16,代码来源:environment.php

示例10: fetch_fieldset

 public static function fetch_fieldset($fieldset)
 {
     $defaults = array('fields' => array());
     if (File::exists("_config/fieldsets/{$fieldset}.yaml")) {
         $meta_raw = file_get_contents("_config/fieldsets/{$fieldset}.yaml");
         $meta = array_merge($defaults, YAML::Parse($meta_raw));
         return $meta;
     }
     return $defaults;
 }
开发者ID:zane-insight,项目名称:WhiteLaceInn,代码行数:10,代码来源:fieldset.php

示例11: fetch

 public static function fetch($form_name)
 {
     $filename = dirname(__DIR__) . '/forms/' . $form_name . '.yaml';
     if (file_exists($filename)) {
         return YAML::parse(file_get_contents($filename));
     } else {
         $error = 'missing form: ' . $filename;
         throw new Exception($error);
     }
 }
开发者ID:stevenosloan,项目名称:acreage,代码行数:10,代码来源:boot.php

示例12: generate_schema

function generate_schema($model)
{
    global $mysql;
    $cols = array();
    $result = mysql_query("DESCRIBE `{$model}`") or die("Error in query: {$sql} \n" . mysql_error() . "\n");
    while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
        $cols[$row['Field']] = $row;
    }
    $yaml = YAML::encode($cols);
    $comments = "# This file is auto-generated by script/generate_schema \n# Do not edit or you'll ruin Christmas!!\n\n";
    file_put_contents("db/schemas/{$model}.yml", $comments . $yaml);
}
开发者ID:phaedryx,项目名称:wannabe-mvc,代码行数:12,代码来源:schema.php

示例13: convertYAML

 /**
  * Parse YAML data into an array
  * @param  {String}       the text to be parsed
  *
  * @return {Array}        the parsed content
  */
 public static function convertYAML($text)
 {
     try {
         $yaml = YAML::parse($text);
     } catch (ParseException $e) {
         printf("unable to parse documentation: %s..\n", $e->getMessage());
     }
     // single line of text won't throw a YAML error. returns as string
     if (gettype($yaml) == "string") {
         $yaml = array();
     }
     return $yaml;
 }
开发者ID:mytoysgroup,项目名称:patternlab-php-core,代码行数:19,代码来源:Documentation.php

示例14: __construct

 /**
  * Function: __construct
  * Loads the Twig parser into <Theme>, and sets up the theme l10n domain.
  */
 private function __construct()
 {
     $config = Config::current();
     # Load the theme translator
     if (file_exists(THEME_DIR . "/locale/" . $config->locale . ".mo")) {
         load_translator("theme", THEME_DIR . "/locale/" . $config->locale . ".mo");
     }
     # Load the theme's info into the Theme class.
     foreach (YAML::load(THEME_DIR . "/info.yaml") as $key => $val) {
         $this->{$key} = $val;
     }
     $this->url = THEME_URL;
 }
开发者ID:eadz,项目名称:chyrp,代码行数:17,代码来源:Theme.php

示例15: load

 public static function load($config_dir)
 {
     $config_file = $config_dir . '/elib.yml';
     if (!file_exists($config_file)) {
         die('Config error: ' . $config_file . ' does not exist');
     }
     $config = YAML::load($config_file);
     foreach ($config as $index => $item) {
         if (!is_array($item)) {
             $index = 'ELIB_' . $index;
             define(strtoupper($index), $item);
         }
     }
 }
开发者ID:mikejw,项目名称:elib-experimental,代码行数:14,代码来源:Config.php


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