PluginProbe
Responsive Menu – Create Mobile-Friendly Menu / 3.0.6
Responsive Menu – Create Mobile-Friendly Menu v3.0.6
4.7.3 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 4.0.0 4.0.1 4.0.2 4.0.3 4.0.4 4.1.0 4.1.1 4.1.10 4.1.11 4.1.12 4.1.2 4.1.3 4.1.4 4.1.5 4.1.6 4.1.7 4.1.8 4.1.9 4.2.0 All 90 releases
responsive-menu / src / app / Controllers / Front.php

Front.php in Responsive Menu – Create Mobile-Friendly Menu 3.0.6, at src/app/Controllers/Front.php

49 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace ResponsiveMenu\Controllers;
4 use ResponsiveMenu\View\View as View;
5 use ResponsiveMenu\Services\OptionService as OptionService;
6 use ResponsiveMenu\ViewModels\Menu as MenuViewModel;
7 use ResponsiveMenu\ViewModels\Button as ButtonViewModel;
8 use ResponsiveMenu\Factories\FrontDisplayFactory as DisplayFactory;
9
10 class Front {
11
12 public function __construct(OptionService $service, View $view) {
13 $this->service = $service;
14 $this->view = $view;
15 }
16
17 public function index() {
18 # Get Latest Options
19 $options = $this->service->all();
20
21 # This needs refactoring - Martin Fowler HELP!
22 $display_factory = new DisplayFactory();
23 $display_factory->build($options);
24
25 # Build Our Menu Display
26 $menu = new MenuViewModel($options);
27 $html = new ButtonViewModel($options);
28
29 # Only render if we don't have shortcodes turned on
30 if($options['shortcode'] == 'off'):
31 $this->view->render('button', ['options' => $options, 'button' => $html->getHtml()]);
32 $this->view->render('menu', ['options' => $options, 'menu' => $menu->getHtml()]);
33 else:
34 add_shortcode('responsive_menu', function($atts) use($options, $html, $menu) {
35
36 if($atts)
37 array_walk($atts, function($a, $b) use ($options) { $options[$b] = $a; });
38
39 $html = $this->view->make('button', ['options' => $options, 'button' => $html->getHtml()]);
40
41 return $html . $this->view->make('menu', ['options' => $options, 'menu' => $menu->getHtml()]);
42
43 });
44 endif;
45
46 }
47
48 }
49