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


PHP sfYamlInline::load方法代码示例

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


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

示例1: execute

 /**
  * @see sfTask
  */
 protected function execute($arguments = array(), $options = array())
 {
     foreach ($arguments['configure'] as $value) {
         list($key, $value) = explode('=', $value);
         $e = explode('.', $key);
         $group = isset($e[1]) ? $e[0] : null;
         $key = isset($e[1]) ? $e[1] : $e[0];
         $value = is_numeric($value) ? (int) $value : $value;
         $value = $value == 'false' ? false : $value;
         $value = $value == 'true' ? true : $value;
         $infoValue = $value;
         if (in_array(substr($value, 0, 1), array('[', '{'))) {
             $value = sfYamlInline::load($value);
             $infoValue = 'YAML: ' . $infoValue;
         }
         $writeToApp = isset($options['application']) && $options['application'] ? true : false;
         if ($group) {
             $this->logSection('sympal', sprintf('Writing setting "%s" with a value of "%s" under the "%s" group.', $key, $infoValue, $group));
             sfSympalConfig::writeSetting($group, $key, $value, $writeToApp);
         } else {
             $this->logSection('sympal', sprintf('Writing setting "%s" with a value of "%s".', $key, $infoValue, $group));
             sfSympalConfig::writeSetting($key, $value, null, $writeToApp);
         }
     }
 }
开发者ID:sympal,项目名称:sympal,代码行数:28,代码来源:sfSympalConfigureTask.class.php

示例2: parseValue

 /**
  * Parses a YAML value.
  *
  * @param  string $value A YAML value
  *
  * @return mixed  A PHP value
  */
 protected function parseValue($value)
 {
     if ('*' === substr($value, 0, 1)) {
         if (false !== ($pos = strpos($value, '#'))) {
             $value = substr($value, 1, $pos - 2);
         } else {
             $value = substr($value, 1);
         }
         if (!array_key_exists($value, $this->refs)) {
             throw new InvalidArgumentException(sprintf('Reference "%s" does not exist (%s).', $value, $this->currentLine));
         }
         return $this->refs[$value];
     }
     if (preg_match('/^(?P<separator>\\||>)(?P<modifiers>\\+|\\-|\\d+|\\+\\d+|\\-\\d+|\\d+\\+|\\d+\\-)?(?P<comments> +#.*)?$/', $value, $matches)) {
         $modifiers = isset($matches['modifiers']) ? $matches['modifiers'] : '';
         return $this->parseFoldedScalar($matches['separator'], preg_replace('#\\d+#', '', $modifiers), intval(abs($modifiers)));
     } else {
         return sfYamlInline::load($value);
     }
 }
开发者ID:ketheriel,项目名称:ETVA,代码行数:27,代码来源:sfYamlParser.php

示例3: lime_test

 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
require_once __DIR__ . '/../../bootstrap/unit.php';
sfYaml::setSpecVersion('1.1');
$t = new lime_test(124);
// ::load()
$t->diag('::load()');
$testsForLoad = array('' => '', 'null' => null, 'false' => false, 'true' => true, '12' => 12, '"quoted string"' => 'quoted string', "'quoted string'" => 'quoted string', '12.30e+02' => 1230.0, '0x4D2' => 0x4d2, '02333' => 02333, '.Inf' => -log(0), '-.Inf' => log(0), '123456789123456789000' => '123456789123456789000', '"foo\\r\\nbar"' => "foo\r\nbar", "'foo#bar'" => 'foo#bar', "'foo # bar'" => 'foo # bar', "'#cfcfcf'" => '#cfcfcf', '2007-10-30' => mktime(0, 0, 0, 10, 30, 2007), '2007-10-30T02:59:43Z' => gmmktime(2, 59, 43, 10, 30, 2007), '2007-10-30 02:59:43 Z' => gmmktime(2, 59, 43, 10, 30, 2007), '"a \\"string\\" with \'quoted strings inside\'"' => 'a "string" with \'quoted strings inside\'', "'a \"string\" with ''quoted strings inside'''" => 'a "string" with \'quoted strings inside\'', '[foo, http://urls.are/no/mappings, false, null, 12]' => array('foo', 'http://urls.are/no/mappings', false, null, 12), '[  foo  ,   bar , false  ,  null     ,  12  ]' => array('foo', 'bar', false, null, 12), '[\'foo,bar\', \'foo bar\']' => array('foo,bar', 'foo bar'), '{foo:bar,bar:foo,false:false,null:null,integer:12}' => array('foo' => 'bar', 'bar' => 'foo', 'false' => false, 'null' => null, 'integer' => 12), '{ foo  : bar, bar : foo,  false  :   false,  null  :   null,  integer :  12  }' => array('foo' => 'bar', 'bar' => 'foo', 'false' => false, 'null' => null, 'integer' => 12), '{foo: \'bar\', bar: \'foo: bar\'}' => array('foo' => 'bar', 'bar' => 'foo: bar'), '{\'foo\': \'bar\', "bar": \'foo: bar\'}' => array('foo' => 'bar', 'bar' => 'foo: bar'), '{\'foo\'\'\': \'bar\', "bar\\"": \'foo: bar\'}' => array('foo\'' => 'bar', "bar\"" => 'foo: bar'), '{\'foo: \': \'bar\', "bar: ": \'foo: bar\'}' => array('foo: ' => 'bar', "bar: " => 'foo: bar'), '[foo, [bar, foo]]' => array('foo', array('bar', 'foo')), '[foo, {bar: foo}]' => array('foo', array('bar' => 'foo')), '{ foo: {bar: foo} }' => array('foo' => array('bar' => 'foo')), '{ foo: [bar, foo] }' => array('foo' => array('bar', 'foo')), '[  foo, [  bar, foo  ]  ]' => array('foo', array('bar', 'foo')), '[{ foo: {bar: foo} }]' => array(array('foo' => array('bar' => 'foo'))), '[foo, [bar, [foo, [bar, foo]], foo]]' => array('foo', array('bar', array('foo', array('bar', 'foo')), 'foo')), '[foo, {bar: foo, foo: [foo, {bar: foo}]}, [foo, {bar: foo}]]' => array('foo', array('bar' => 'foo', 'foo' => array('foo', array('bar' => 'foo'))), array('foo', array('bar' => 'foo'))), '[foo, bar: { foo: bar }]' => array('foo', '1' => array('bar' => array('foo' => 'bar'))));
foreach ($testsForLoad as $yaml => $value) {
    $t->is_deeply(sfYamlInline::load($yaml), $value, sprintf('::load() converts an inline YAML to a PHP structure (%s)', $yaml));
}
$testsForDump = array('null' => null, 'false' => false, 'true' => true, '12' => 12, "'quoted string'" => 'quoted string', '12.30e+02' => 1230.0, '1234' => 0x4d2, '1243' => 02333, '.Inf' => -log(0), '-.Inf' => log(0), '"foo\\r\\nbar"' => "foo\r\nbar", "'foo#bar'" => 'foo#bar', "'foo # bar'" => 'foo # bar', "'#cfcfcf'" => '#cfcfcf', "'a \"string\" with ''quoted strings inside'''" => 'a "string" with \'quoted strings inside\'', '[foo, bar, false, null, 12]' => array('foo', 'bar', false, null, 12), '[\'foo,bar\', \'foo bar\']' => array('foo,bar', 'foo bar'), '{ foo: bar, bar: foo, \'false\': false, \'null\': null, integer: 12 }' => array('foo' => 'bar', 'bar' => 'foo', 'false' => false, 'null' => null, 'integer' => 12), '{ foo: bar, bar: \'foo: bar\' }' => array('foo' => 'bar', 'bar' => 'foo: bar'), '[foo, [bar, foo]]' => array('foo', array('bar', 'foo')), '[foo, [bar, [foo, [bar, foo]], foo]]' => array('foo', array('bar', array('foo', array('bar', 'foo')), 'foo')), '{ foo: { bar: foo } }' => array('foo' => array('bar' => 'foo')), '[foo, { bar: foo }]' => array('foo', array('bar' => 'foo')), '[foo, { bar: foo, foo: [foo, { bar: foo }] }, [foo, { bar: foo }]]' => array('foo', array('bar' => 'foo', 'foo' => array('foo', array('bar' => 'foo'))), array('foo', array('bar' => 'foo'))));
// ::dump()
$t->diag('::dump()');
foreach ($testsForDump as $yaml => $value) {
    $t->is(sfYamlInline::dump($value), $yaml, sprintf('::dump() converts a PHP structure to an inline YAML (%s)', $yaml));
}
foreach ($testsForLoad as $yaml => $value) {
    if ($value == 1230) {
        continue;
    }
    $t->is_deeply(sfYamlInline::load(sfYamlInline::dump($value)), $value, 'check consistency');
}
foreach ($testsForDump as $yaml => $value) {
    if ($value == 1230) {
        continue;
    }
    $t->is_deeply(sfYamlInline::load(sfYamlInline::dump($value)), $value, 'check consistency');
}
开发者ID:Phennim,项目名称:symfony1,代码行数:31,代码来源:sfYamlInlineTest.php

示例4: parseArguments

 /**
  * Parses validator arguments.
  *
  * @param  string  $string  The string to parse
  * @param  integer $i       The indice to start the parsing
  *
  * @return array   An array of parameters
  */
 protected function parseArguments($string, &$i)
 {
     $len = strlen($string);
     if ($i + 1 > $len || '(' != $string[$i]) {
         return array(array(), array());
     }
     ++$i;
     $args = '';
     $opened = 0;
     while ($i < $len) {
         if ('(' == $string[$i]) {
             ++$opened;
         } else {
             if (')' == $string[$i]) {
                 if (!$opened) {
                     break;
                 }
                 --$opened;
             }
         }
         $args .= $string[$i++];
     }
     ++$i;
     return sfYamlInline::load('[' . (!$args ? '{}' : $args) . ']');
 }
开发者ID:vcgato29,项目名称:poff,代码行数:33,代码来源:sfValidatorFromDescription.class.php

示例5: load

 /**
  * @see sfYamlInline::load()
  * @param String $value
  * @return Mixed PHP
  */
 public static function load($value)
 {
     return sfYamlInline::load($value);
 }
开发者ID:noreiller,项目名称:sfPlopPlugin,代码行数:9,代码来源:sfPlopConfigPeer.php


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