Gc\Component\Tabs::render PHP Method

render() public method

Render tab
public render ( array $tabs = null ) : string
$tabs array Contains objects
return string
    public function render(array $tabs = null)
    {
        if ($tabs === null) {
            $tabs = $this->data;
        }
        $html = '<ul>';
        $i = 1;
        foreach ($tabs as $iterator) {
            if (!$iterator instanceof IterableInterface) {
                $html .= '<li><a href="#tabs-' . $i . '">' . $iterator . '</a></li>';
            } else {
                $html .= '<li><a href="#tabs-' . $iterator->getId() . '">' . $iterator->getName() . '</a></li>';
            }
            $i++;
        }
        $html .= '</ul>';
        return $html;
    }

Usage Example

Example #1
0
 /**
  * Test
  *
  * @return void
  */
 public function testRenderWithoutParams()
 {
     $this->object->setData(array('string'));
     $this->assertEquals('<ul><li><a href="#tabs-1">string</a></li></ul>', $this->object->render());
 }