public function testRemoveValues() { $array = array('these' => 'are', 'my' => 'values'); TbArray::removeValues(array('these', 'my'), $array); $this->assertArrayNotHasKey('these', $array); $this->assertArrayNotHasKey('my', $array); }
/** * Generates a button. * @param string $type the button type. * @param string $label the button label text. * @param array $htmlOptions additional HTML attributes. * @return string the generated button. */ public static function btn($type, $label, $htmlOptions = array()) { self::addCssClass('btn', $htmlOptions); $color = TbArray::popValue('color', $htmlOptions); if (!empty($color)) { self::addCssClass('btn-' . $color, $htmlOptions); } $size = TbArray::popValue('size', $htmlOptions); if (!empty($size)) { self::addCssClass('btn-' . $size, $htmlOptions); } if (TbArray::popValue('block', $htmlOptions, false)) { self::addCssClass('btn-block', $htmlOptions); } if (TbArray::popValue('disabled', $htmlOptions, false)) { self::addCssClass('disabled', $htmlOptions); $htmlOptions['disabled'] = 'disabled'; } $loading = TbArray::popValue('loading', $htmlOptions); if (!empty($loading)) { $htmlOptions['data-loading-text'] = $loading; } if (TbArray::popValue('toggle', $htmlOptions, false)) { $htmlOptions['data-toggle'] = 'button'; } $icon = TbArray::popValue('icon', $htmlOptions); $iconOptions = TbArray::popValue('iconOptions', $htmlOptions, array()); if (strpos($type, 'input') === false) { if (!empty($icon)) { $label = self::icon($icon, $iconOptions) . ' ' . $label; } $items = TbArray::popValue('items', $htmlOptions); } $dropdownOptions = $htmlOptions; TbArray::removeValues(array('groupOptions', 'menuOptions', 'dropup'), $htmlOptions); self::addSpanClass($htmlOptions); // must be called here as parent renders buttons self::addPullClass($htmlOptions); // must be called here as parent renders buttons return isset($items) ? self::btnDropdown($type, $label, $items, $dropdownOptions) : self::createButton($type, $label, $htmlOptions); }