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


PHP sfToolkit::replaceConstants方法代码示例

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


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

示例1: replaceConstants

 /**
  * Replaces constant identifiers in a value.
  *
  * If the value is an array replacements are made recursively.
  *
  * @param mixed The value on which to run the replacement procedure
  *
  * @return string The new value
  */
 public static function replaceConstants($value)
 {
     if (is_array($value)) {
         array_walk_recursive($value, create_function('&$value', '$value = sfToolkit::replaceConstants($value);'));
     } else {
         $value = sfToolkit::replaceConstants($value);
     }
     return $value;
 }
开发者ID:Daniel-Marynicz,项目名称:symfony1-legacy,代码行数:18,代码来源:sfConfigHandler.class.php

示例2: sprintf

  {
    $t->is(sfToolkit::literalize(strtoupper($param)), null, sprintf('::literalize() returns null with "%s"', strtoupper($param)));
  }
  $t->is(sfToolkit::literalize(' '.$param.' '), null, sprintf('::literalize() returns null with "%s"', ' '.$param.' '));
}

// ::replaceConstants()
$t->diag('::replaceConstants()');
sfConfig::set('foo', 'bar');
$t->is(sfToolkit::replaceConstants('my value with a %foo% constant'), 'my value with a bar constant', '::replaceConstantsCallback() replaces constants enclosed in %');
$t->is(sfToolkit::replaceConstants('%Y/%m/%d %H:%M'), '%Y/%m/%d %H:%M', '::replaceConstantsCallback() does not replace unknown constants');
sfConfig::set('bar', null);
$t->is(sfToolkit::replaceConstants('my value with a %bar% constant'), 'my value with a  constant', '::replaceConstantsCallback() replaces constants enclosed in % even if value is null');
$t->is(sfToolkit::replaceConstants('my value with a %foobar% constant'), 'my value with a %foobar% constant', '::replaceConstantsCallback() returns the original string if the constant is not defined');
$t->is(sfToolkit::replaceConstants('my value with a %foo\'bar% constant'), 'my value with a %foo\'bar% constant', '::replaceConstantsCallback() returns the original string if the constant is not defined');
$t->is(sfToolkit::replaceConstants('my value with a %foo"bar% constant'), 'my value with a %foo"bar% constant', '::replaceConstantsCallback() returns the original string if the constant is not defined');

// ::isPathAbsolute()
$t->diag('::isPathAbsolute()');
$t->is(sfToolkit::isPathAbsolute('/test'), true, '::isPathAbsolute() returns true if path is absolute');
$t->is(sfToolkit::isPathAbsolute('\\test'), true, '::isPathAbsolute() returns true if path is absolute');
$t->is(sfToolkit::isPathAbsolute('C:\\test'), true, '::isPathAbsolute() returns true if path is absolute');
$t->is(sfToolkit::isPathAbsolute('d:/test'), true, '::isPathAbsolute() returns true if path is absolute');
$t->is(sfToolkit::isPathAbsolute('test'), false, '::isPathAbsolute() returns false if path is relative');
$t->is(sfToolkit::isPathAbsolute('../test'), false, '::isPathAbsolute() returns false if path is relative');
$t->is(sfToolkit::isPathAbsolute('..\\test'), false, '::isPathAbsolute() returns false if path is relative');

// ::stripComments()
$t->diag('::stripComments()');

$php = <<<EOF
开发者ID:nationalfield,项目名称:symfony,代码行数:31,代码来源:sfToolkitTest.php

示例3: getLinkToAction

 /**
  * Returns HTML code for an action link.
  *
  * @param string  The action name
  * @param array   The parameters
  * @param boolean Whether to add a primary key link or not
  *
  * @return string HTML code
  */
 public function getLinkToAction($actionName, $params, $pk_link = false)
 {
     $options = isset($params['params']) ? sfToolkit::stringToArray($params['params']) : array();
     // default values
     if ($actionName[0] == '_') {
         $actionName = substr($actionName, 1);
         $name = $actionName;
         $icon = sfConfig::get('sf_admin_web_dir') . '/images/' . $actionName . '_icon.png';
         $action = $actionName;
         if ($actionName == 'delete') {
             $options['post'] = true;
             if (!isset($options['confirm'])) {
                 $options['confirm'] = 'Are you sure?';
             }
         }
     } else {
         $name = isset($params['name']) ? $params['name'] : $actionName;
         $icon = isset($params['icon']) ? sfToolkit::replaceConstants($params['icon']) : sfConfig::get('sf_admin_web_dir') . '/images/default_icon.png';
         $action = isset($params['action']) ? $params['action'] : 'List' . sfInflector::camelize($actionName);
     }
     $url_params = $pk_link ? '?' . $this->getPrimaryKeyUrlParams() : '\'';
     $phpOptions = var_export($options, true);
     // little hack
     $phpOptions = preg_replace("/'confirm' => '(.+?)(?<!\\\\)'/", '\'confirm\' => __(\'$1\')', $phpOptions);
     return '<li>[?php echo link_to(image_tag(\'' . $icon . '\', array(\'alt\' => __(\'' . $name . '\'), \'title\' => __(\'' . $name . '\'))), \'' . $this->getModuleName() . '/' . $action . $url_params . ($options ? ', ' . $phpOptions : '') . ') ?]</li>' . "\n";
 }
开发者ID:taryono,项目名称:school,代码行数:35,代码来源:sfAdminGenerator.class.php

示例4: array

<?php

$this->configCache->registerConfigHandler('config/include_path.yml', 'sfSimpleYamlConfigHandler');
$data = $this->configCache->checkConfig('config/include_path.yml', true);
if ($data) {
    $data = (include $data);
    $paths = array();
    foreach ($data['include_path'] as $name => $include_path) {
        $include_path = sfToolkit::replaceConstants($include_path);
        $paths[] = $include_path;
    }
    set_include_path(get_include_path() . PATH_SEPARATOR . implode(PATH_SEPARATOR, $paths));
}
开发者ID:hidenorigoto,项目名称:sfjp-cms2,代码行数:13,代码来源:config.php


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