本文整理汇总了PHP中TbArray::merge方法的典型用法代码示例。如果您正苦于以下问题:PHP TbArray::merge方法的具体用法?PHP TbArray::merge怎么用?PHP TbArray::merge使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TbArray
的用法示例。
在下文中一共展示了TbArray::merge方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testMerge
public function testMerge()
{
$a = array('this' => 'is', 'array' => 'a');
$b = array('is' => 'this', 'b' => 'array');
$array = TbArray::merge($a, $b);
$this->assertEquals('is', TbArray::getValue('this', $array));
$this->assertEquals('a', TbArray::getValue('array', $array));
$this->assertEquals('this', TbArray::getValue('is', $array));
$this->assertEquals('array', TbArray::getValue('b', $array));
}
示例2: initOptions
/**
* Initializes the plugin options
*/
public function initOptions()
{
$options = array();
foreach (array('matcher', 'sorter', 'updater', 'highlighter') as $fn) {
if ($this->{$fn} !== null) {
if ($this->{$fn} instanceof CJavaScriptExpression) {
$options[$fn] = $this->{$fn};
} else {
$options[$fn] = new CJavaScriptExpression($this->{$fn});
}
}
}
$this->pluginOptions = TbArray::merge(array('source' => $this->source, 'items' => $this->items, 'minLength' => $this->minLength), $options);
}
示例3: init
/**
* @inheritdoc
*/
public function init()
{
parent::init();
if (!$this->hasModel() && $this->name === null) {
throw new CException("Either 'name', or 'model' and 'attribute' properties must be specified.");
}
if (!isset($this->htmlOptions['id'])) {
$this->htmlOptions['id'] = $this->hasModel() ? CHtml::activeId($this->model, $this->attribute) : $this->getId();
}
$this->attachBehavior('ywplugin', array('class' => 'yiiwheels.behaviors.WhPlugin'));
$this->htmlOptions = TbArray::merge($this->asDataAttributes($this->pluginOptions), $this->htmlOptions);
$this->pluginOptions = false;
if ($this->hasModel()) {
$this->htmlOptions['data-name'] = CHtml::activeId($this->model, $this->attribute);
$this->htmlOptions['data-value'] = CHtml::value($this->model, $this->attribute);
} else {
$this->htmlOptions['data-name'] = $this->name;
$this->htmlOptions['data-value'] = $this->value;
}
}
示例4: medias
/**
* Generates multiple media objects.
* @param array $items item configurations.
* @param string $tag the item tag name.
* @return string generated objects.
*/
public static function medias(array $items, $tag = 'div')
{
if (!empty($items)) {
$output = '';
foreach ($items as $itemOptions) {
if (isset($itemOptions['visible']) && $itemOptions['visible'] === false) {
continue;
}
// todo: consider removing the support for htmlOptions.
$options = TbArray::popValue('htmlOptions', $itemOptions, array());
if (!empty($options)) {
$itemOptions = TbArray::merge($options, $itemOptions);
}
$image = TbArray::popValue('image', $itemOptions);
$heading = TbArray::popValue('heading', $itemOptions, '');
$content = TbArray::popValue('content', $itemOptions, '');
TbArray::defaultValue('tag', $tag, $itemOptions);
$output .= self::media($image, $heading, $content, $itemOptions);
}
return $output;
}
return '';
}