public function testMoveValue() { $a = array('key' => 'value'); $b = array(); ArrayHelper::moveValue('key', $a, $b); $this->assertArrayNotHasKey('key', $a); $this->assertEquals('value', ArrayHelper::getValue($b, 'key')); $a = array('key' => 'value'); $b = array('key' => 'other'); ArrayHelper::moveValue('key', $a, $b, true); $this->assertEquals('value', ArrayHelper::getValue($b, 'key')); }
/** * @param string|array $item * * @return string */ public static function menuItem($item) { // todo: add tests. if (is_string($item)) { return $item; // already rendered } if (!ArrayHelper::popValue($item, 'visible', true)) { return ''; } $options = ArrayHelper::popValue($item, 'itemOptions', []); static::addCssClassWithCondition($options, 'active', ArrayHelper::popValue($item, 'active')); static::addCssClassWithCondition($options, 'disabled', ArrayHelper::popValue($item, 'disabled')); $linkOptions = ArrayHelper::popValue($item, 'options', []); ArrayHelper::moveValue('icon', $item, $linkOptions); ArrayHelper::moveValue('badge', $item, $linkOptions); if (isset($item['url'])) { $item['content'] = static::a(ArrayHelper::popValue($item, 'label'), ArrayHelper::popValue($item, 'url'), $linkOptions); } return static::tag('li', $item['content'], $options); }