Menu

Maslosoft Framework Logo Maslosoft Framework Documentation
Flexible Application Foundation


Signal Tabs

This is kind of tabs that will collect additional tabs via signals. These require property $signal to be set to instance of TabsSignalInterface, or array of this kind of signals.

Example of reacting for tab signal

To add tabs, other components should react for signal emitting (in example AccountTabs) and call add method with single tab configuration as parameter to add tabs to widget.

	/**
	 * @SlotFor(AccountTabs)
	 * @param AccountTabs $signal
	 */
	public function reactOnUserTab(AccountTabs $signal)
	{
		$signal->add([
			'title' => 'Tab Title,
			'content' => 'Tab Content'
		]);
	}

Implementing TabsSignalInterface

The interface contains methods add, which should accept tab configuration as parameter, and getTabs which should return configuration of all added tabs. For easier implementation the TabsSignalCommon can be used, which adds default functionality for add and getTabs. The basic implementation can consist of just class declaration implementing TabsSignalInterface and use of TabsSignalCommon. The class declaration is required to distinguish from other signals and can contain additional methods for use with reacting components.

class AccountTabs implements TabsSignalInterface
{
    use TabsSignalCommon;
}

Using SignalTabs

The only required parameter is `signal`, which should be instance of signal to emit. Tabs collected by signals will be appended to existing tabs.

For sake of simplicity, example below uses existing user account tabs (AccountTabs) signal.

Content of one
Content of two
Add
echo SignalTabs::widget([
	'signal' => new AccountTabs(new User),
	'items' => [
		[
			'label' => 'Item one',
			'content' => 'Content of one'
		],
		[
			'label' => 'Item two',
			'content' => 'Content of two'
		],
	]
]);