public function child($class) { if (class_exists($class)) { $this->class = $class; $method = $class::plural(); $this->related = method_exists($this->model, $method) ? $this->model->{$method}()->get() : $this->model->related($class); $this->actions->add(Button::create()->parent($class)->link('create')->classes('button success')); } return $this; }
/** * Constructor. * @param Extender $extender * @param Application $app */ public function __construct(Extender $extender, Application $app) { $this->checkDependencies(); $this->extender = $extender; $this->app = $app; $this->navigation = ButtonGroup::create()->classes('navigation-list')->element('ul'); }
public function test_button_components() { // Test object $page = Page::find(1); // Check the create method. $group = ButtonGroup::create(); $this->assertInstanceOf(ButtonGroup::class, $group); // Shouldn't have anything in it. $this->assertCount(0, $group->getButtons()); // Should return a zero count. $this->assertEquals(0, $group->count()); // Button groups $button = Button::create(); // Check default setting. $this->assertNull($button->getAttribute('href')); // Adding to the group will increment the button count. $group->add($button); $this->assertEquals(1, $group->count()); // Try adding the other way around. $button2 = Button::create(); $button2->addTo($group); $this->assertEquals(2, $group->count()); // Check if the button attributes are assigned correctly. $button->parent($page)->link('view'); $this->assertEquals("View Pages", $button->getLabel()); $this->assertEquals($page::getIcon(), $button->getIcon()); $this->assertEquals(cms_url($page::plural()), $button->getAttribute('href')); }
/** * Add this button to a button group. * @param ButtonGroup $component * @return $this */ public function addTo(ButtonGroup $component) { $component->add($this); return $this; }
protected function setViews($array = []) { return $this->setData('views', ButtonGroup::build($array)); }