Maslosoft Framework Logo Maslosoft Framework Documentation
Flexible Application Foundation

Smart Menu

Smart menu is a "hamburger" type menu placed on top right or left side of viewport. Is is designed in a way that any application component can obtain instance of it, and add icon, or element to it.

Adding menu elements manually

To get instance flyweight pattern should be used, by calling static fly() method. Then icon or widget can be added by calling add() method. It will add icon if it implements SmartIconInterface or widget if it implements WidgetInterface.

Example of adding icon with class implementing SmartIconInterface:

$myIcon = new MyIconClass;

Adding icons with signals

To add icons with signals there need to be some slot method added, which should have @SlotFor annotation for SmartSignal signal. Smart menu will emit signal when it is being initialized.

Class SmartSignal exposes method for getting instance of Smart, the getSmart().

Example of adding icon on menu initialization via signals:

class MySlots implements AnnotatedInterface
     * @SlotFor(SmartSignal)
     * @param SmartSignal $signal
    public function reactOn(SmartSignal $signal)
        $signal->getSmart()->add(new MyMenuIcon);

For easier icon adding and creation, there are some more or less partial implementations available: