PluginProbe
Responsive Menu – Create Mobile-Friendly Menu / 3.0.4
Responsive Menu – Create Mobile-Friendly Menu v3.0.4
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.4, at src/app/Controllers/Front.php

51 lines 1.6 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\Repositories\OptionRepository as OptionRepository;
6 use ResponsiveMenu\Controllers\Base as Base;
7 use ResponsiveMenu\ViewModels\Menu as MenuViewModel;
8 use ResponsiveMenu\ViewModels\Button as ButtonViewModel;
9 use ResponsiveMenu\Factories\FrontDisplayFactory as DisplayFactory;
10 use ResponsiveMenu\Shortcodes\ResponsiveMenuShortcode as Shortcode;
11
12 class Front {
13
14 public function __construct(OptionRepository $repository, View $view) {
15 $this->repository = $repository;
16 $this->view = $view;
17 }
18
19 public function index() {
20 # Get Latest Options
21 $options = $this->repository->all();
22
23 # This needs refactoring - Martin Fowler HELP!
24 $display_factory = new DisplayFactory();
25 $display_factory->build($options);
26
27 # Build Our Menu Display
28 $menu = new MenuViewModel($options);
29 $html = new ButtonViewModel($options);
30
31 # Only render if we don't have shortcodes turned on
32 if($options['shortcode'] == 'off'):
33 $this->view->render('button', ['options' => $options, 'button' => $html->getHtml()]);
34 $this->view->render('menu', ['options' => $options, 'menu' => $menu->getHtml()]);
35 else:
36 add_shortcode('responsive_menu', function($atts) use($options, $html, $menu) {
37
38 if($atts)
39 array_walk($atts, function($a, $b) use ($options) { $options[$b] = $a; });
40
41 $html = $this->view->make('button', ['options' => $options, 'button' => $html->getHtml()]);
42
43 return $html . $this->view->make('menu', ['options' => $options, 'menu' => $menu->getHtml()]);
44
45 });
46 endif;
47
48 }
49
50 }
51