本文整理汇总了PHP中sfYamlInline类的典型用法代码示例。如果您正苦于以下问题:PHP sfYamlInline类的具体用法?PHP sfYamlInline怎么用?PHP sfYamlInline使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了sfYamlInline类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: asString
/**
* @see sfValidatorBase
*/
public function asString($indent = 0)
{
$options = $this->getOptionsWithoutDefaults();
$messages = $this->getMessagesWithoutDefaults();
unset($options['left_field'], $options['operator'], $options['right_field']);
$arguments = '';
if ($options || $messages) {
$arguments = sprintf('(%s%s)', $options ? sfYamlInline::dump($options) : ($messages ? '{}' : ''), $messages ? ', ' . sfYamlInline::dump($messages) : '');
}
return sprintf('%s%s %s%s %s', str_repeat(' ', $indent), $this->getOption('left_field'), $this->getOption('operator'), $arguments, $this->getOption('right_field'));
}
开发者ID:voota,项目名称:voota,代码行数:14,代码来源:sfValidatorRequiredIfField.class.php
示例3: execute
protected function execute($arguments = array(), $options = array())
{
$root = sfConfig::get('sf_root_dir');
$flavor = $root . '/flavors/' . $arguments['flavor'];
if (!is_dir($flavor)) {
$this->logSection('Error', 'The provided flavor does not exist the flavors/ directory', null, 'ERROR');
return false;
}
$web = sfConfig::get('sf_web_dir');
$web_css = $web . '/css';
$web_img = $web . '/images';
$pm_pdf_kit_cfg = sfConfig::get('sf_apps_dir') . '/backend/config/pm_pdf_kit.yml';
$files = array();
foreach (array($web_css, $web_img, $pm_pdf_kit_cfg) as $file) {
if (file_exists($file)) {
$files[] = $file;
}
}
if (!empty($files)) {
$this->logSection('Assets', 'Deleting the existing assets');
$this->getFilesystem()->remove($files);
} else {
$this->logSection('Assets', 'No existing assets found');
}
$this->logSection('Assets', 'Linking the chosen flavor: ' . $arguments['flavor']);
$flavor_css = $flavor . '/web/css';
$flavor_img = $flavor . '/web/images';
$pm_pdf_kit = $flavor . '/config/pm_pdf_kit.yml';
$this->getFilesystem()->symlink($flavor_css, $web_css, true);
$this->getFilesystem()->symlink($flavor_img, $web_img, true);
$this->getFilesystem()->symlink($pm_pdf_kit, $pm_pdf_kit_cfg, true);
$this->logSection('Config', 'Updating configuration');
$cfg_dir = sfConfig::get('sf_config_dir');
$configuration = array('nc_flavor' => array('flavors' => array('root_dir' => 'flavors', 'current' => $arguments['flavor'])));
$updated = @file_put_contents($cfg_dir . '/nc_flavor.yml', sfYaml::dump($configuration));
if ($updated === false) {
$this->logSection('Config', 'Unable to update configuration', null, 'ERROR');
$this->logSection('Config', "Please update your configuration file {$cfg_dir}/nc_flavor.yml with this contents:");
$this->logBlock(sfYamlInline::dump($configuration), 'COMMENT');
} else {
$this->logSection('Flavor', 'Successfully updated flavor configuration file');
}
if ($updated === false) {
$this->logSection('Config', 'Unable to update configuration', null, 'ERROR');
$this->logBlock($school_behavior, 'COMMENT');
} else {
$this->logSection('Behavior', 'Successfully updated school_behavior configuration file');
}
$cc = new sfCacheClearTask($this->dispatcher, $this->formatter);
$cc->run();
$this->logSection('Done', ':)');
}
开发者ID:nvidela,项目名称:kimkelen,代码行数:52,代码来源:kimkelenFlavorTask.class.php
示例4: dump
/**
* Dumps a PHP value to YAML.
*
* @param mixed $input The PHP value
* @param integer $inline The level where you switch to inline YAML
* @param integer $indent The level o indentation indentation (used internally)
*
* @return string The YAML representation of the PHP value
*/
public function dump($input, $inline = 0, $indent = 0)
{
$output = '';
$prefix = $indent ? str_repeat(' ', $indent) : '';
if ($inline <= 0 || !is_array($input) || empty($input)) {
$output .= $prefix . sfYamlInline::dump($input);
} else {
$isAHash = array_keys($input) !== range(0, count($input) - 1);
foreach ($input as $key => $value) {
$willBeInlined = $inline - 1 <= 0 || !is_array($value) || empty($value);
$output .= sprintf('%s%s%s%s', $prefix, $isAHash ? sfYamlInline::dump($key) . ':' : '-', $willBeInlined ? ' ' : "\n", $this->dump($value, $inline - 1, $willBeInlined ? 0 : $indent + 2)) . ($willBeInlined ? "\n" : '');
}
}
return $output;
}
开发者ID:mahassan,项目名称:shellneverknow,代码行数:24,代码来源:sfYamlDumper.php
示例5: execute
/**
* @see sfTask
*/
protected function execute($arguments = array(), $options = array())
{
$app = $arguments['app'];
// Validate the application name
if (!preg_match('/^[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*$/', $app)) {
throw new sfCommandException(sprintf('The application name "%s" is invalid.', $app));
}
$appDir = sfConfig::get('sf_apps_dir') . '/' . $app;
if (is_dir($appDir)) {
throw new sfCommandException(sprintf('The application "%s" already exists.', $appDir));
}
if (is_readable(sfConfig::get('sf_data_dir') . '/skeleton/app')) {
$skeletonDir = sfConfig::get('sf_data_dir') . '/skeleton/app';
} else {
$skeletonDir = __DIR__ . '/skeleton/app';
}
// Create basic application structure
$finder = sfFinder::type('any')->discard('.sf');
$this->getFilesystem()->mirror($skeletonDir . '/app', $appDir, $finder);
// Create $app.php or index.php if it is our first app
$indexName = 'index';
$firstApp = !file_exists(sfConfig::get('sf_web_dir') . '/index.php');
if (!$firstApp) {
$indexName = $app;
}
if (true === $options['csrf-secret']) {
$options['csrf-secret'] = sha1(mt_rand(11111111, 99999999) . getmypid());
}
// Set no_script_name value in settings.yml for production environment
$finder = sfFinder::type('file')->name('settings.yml');
$this->getFilesystem()->replaceTokens($finder->in($appDir . '/config'), '##', '##', array('NO_SCRIPT_NAME' => $firstApp ? 'true' : 'false', 'CSRF_SECRET' => sfYamlInline::dump(sfYamlInline::parseScalar($options['csrf-secret'])), 'ESCAPING_STRATEGY' => sfYamlInline::dump((bool) sfYamlInline::parseScalar($options['escaping-strategy'])), 'USE_DATABASE' => sfConfig::has('sf_orm') ? 'true' : 'false'));
$this->getFilesystem()->copy($skeletonDir . '/web/index.php', sfConfig::get('sf_web_dir') . '/' . $indexName . '.php');
$this->getFilesystem()->copy($skeletonDir . '/web/index.php', sfConfig::get('sf_web_dir') . '/' . $app . '_dev.php');
$this->getFilesystem()->replaceTokens(sfConfig::get('sf_web_dir') . '/' . $indexName . '.php', '##', '##', array('APP_NAME' => $app, 'ENVIRONMENT' => 'prod', 'IS_DEBUG' => 'false', 'IP_CHECK' => ''));
$this->getFilesystem()->replaceTokens(sfConfig::get('sf_web_dir') . '/' . $app . '_dev.php', '##', '##', array('APP_NAME' => $app, 'ENVIRONMENT' => 'dev', 'IS_DEBUG' => 'true', 'IP_CHECK' => '// this check prevents access to debug front controllers that are deployed by accident to production servers.' . PHP_EOL . '// feel free to remove this, extend it or make something more sophisticated.' . PHP_EOL . 'if (!in_array(@$_SERVER[\'REMOTE_ADDR\'], array(\'127.0.0.1\', \'::1\')))' . PHP_EOL . '{' . PHP_EOL . ' die(\'You are not allowed to access this file. Check \'.basename(__FILE__).\' for more information.\');' . PHP_EOL . '}' . PHP_EOL));
$this->getFilesystem()->rename($appDir . '/config/ApplicationConfiguration.class.php', $appDir . '/config/' . $app . 'Configuration.class.php');
$this->getFilesystem()->replaceTokens($appDir . '/config/' . $app . 'Configuration.class.php', '##', '##', array('APP_NAME' => $app));
$fixPerms = new sfProjectPermissionsTask($this->dispatcher, $this->formatter);
$fixPerms->setCommandApplication($this->commandApplication);
$fixPerms->setConfiguration($this->configuration);
$fixPerms->run();
// Create test dir
$this->getFilesystem()->mkdirs(sfConfig::get('sf_test_dir') . '/functional/' . $app);
}
开发者ID:marekk,项目名称:symfony1,代码行数:47,代码来源:sfGenerateAppTask.class.php
示例6: asString
/**
* Returns a string representation of this validator.
*
* @param int $indent Indentation (number of spaces before each line)
*
* @return string The string representation of the validator
*/
public function asString($indent = 0)
{
$options = $this->getOptionsWithoutDefaults();
$messages = $this->getMessagesWithoutDefaults();
return sprintf('%s%s(%s%s)', str_repeat(' ', $indent), str_replace('sfValidator', '', get_class($this)), $options ? sfYamlInline::dump($options) : ($messages ? '{}' : ''), $messages ? ', ' . sfYamlInline::dump($messages) : '');
}
开发者ID:laiello,项目名称:tesiscdfeg12,代码行数:13,代码来源:sfValidatorBase.class.php
示例7: 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
示例8: 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
示例9: asString
/**
* @see sfValidatorBase
*/
public function asString($indent = 0)
{
$validators = '';
for ($i = 0, $max = count($this->validators); $i < $max; $i++) {
$validators .= "\n" . $this->validators[$i]->asString($indent + 2) . "\n";
if ($i < $max - 1) {
$validators .= str_repeat(' ', $indent + 2) . 'or';
}
if ($i == $max - 2) {
$options = $this->getOptionsWithoutDefaults();
$messages = $this->getMessagesWithoutDefaults();
if ($options || $messages) {
$validators .= sprintf('(%s%s)', $options ? sfYamlInline::dump($options) : ($messages ? '{}' : ''), $messages ? ', ' . sfYamlInline::dump($messages) : '');
}
}
}
return sprintf("%s(%s%s)", str_repeat(' ', $indent), $validators, str_repeat(' ', $indent));
}
开发者ID:cuongnv540,项目名称:jobeet,代码行数:21,代码来源:sfValidatorOr.class.php
示例10: 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
示例11: asString
/**
* @see sfValidatorBase
*/
public function asString($indent = 0)
{
$options = $this->getOptionsWithoutDefaults();
$messages = $this->getMessagesWithoutDefaults();
unset($options['control_field'], $options['validator_schema']);
$arguments = '';
if ($options || $messages) {
$arguments = sprintf('(%s%s)', $options ? sfYamlInline::dump($options) : ($messages ? '{}' : ''), $messages ? ', ' . sfYamlInline::dump($messages) : '');
}
return sprintf('%s%s %s%s %s', str_repeat(' ', $indent), $this->getOption('control_field'), $this->getOption('validator_schema'), $arguments);
}
开发者ID:solutema,项目名称:siwapp-sf1,代码行数:14,代码来源:SiwappConditionalValidator.class.php
示例12: 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类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论