PluginProbe
Responsive Menu – Create Mobile-Friendly Menu / 3.1.13
Responsive Menu – Create Mobile-Friendly Menu v3.1.13
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
← All changes | app/Controllers/FrontController.php +0 -65 4.0.13.1.13 View file →
@@ -5,89 +5,24 @@
5 5 use ResponsiveMenu\View\View;
6 6 use ResponsiveMenu\Management\OptionManager;
7 7 use ResponsiveMenu\Formatters\Minifier;
8 8
9 -/**
10 -* Entry point for all front end functionality.
11 -*
12 -* All routing for the front end comes through the functions below. When a
13 -* front end page is loaded in the browser it will come through here.
14 -*
15 -* @author Peter Featherstone <peter@featherstone.me>
16 -*
17 -* @since 3.0
18 -*/
19 9 class FrontController {
20 10
21 - /**
22 - * Constructor for setting up the FrontController.
23 - *
24 - * The constructor allows us to switch implementations for managing options
25 - * and for rendering views. Useful for switching out mocked or stubbed
26 - * classes during testing.
27 - *
28 - * @author Peter Featherstone <peter@featherstone.me>
29 - *
30 - * @since 3.0
31 - *
32 - * @param OptionManager $manager Instance of a Management options class.
33 - * @param View $view Instance of a View class for rendering.
34 - */
35 11 public function __construct(OptionManager $manager, View $view) {
36 12 $this->manager = $manager;
37 13 $this->view = $view;
38 14 }
39 15
40 - /**
41 - * Main route for the front end.
42 - *
43 - * This is the default view for the plugin on an initial GET request to the
44 - * front end page.
45 - *
46 - * @author Peter Featherstone <peter@featherstone.me>
47 - *
48 - * @since 3.0
49 - *
50 - * @return string Output HTML from rendered view.
51 - */
52 16 public function index() {
53 17 $options = $this->manager->all();
54 18 $this->buildFrontEnd($options);
55 19 }
56 20
57 - /**
58 - * Preview route for the front end.
59 - *
60 - * This is the preview view for the plugin when the preview admin option is
61 - * pressed.
62 - *
63 - * @author Peter Featherstone <peter@featherstone.me>
64 - *
65 - * @since 3.0
66 - *
67 - * @return string Output HTML from rendered view.
68 - */
69 21 public function preview() {
70 22 return $this->view->render('preview.html.twig');
71 23 }
72 24
73 - /**
74 - * Helper private method to setup and build the front end.
75 - *
76 - * This is the preview view for the plugin when the preview admin option is
77 - * pressed. We turn external files off to enable the preview options to
78 - * take effect.
79 - *
80 - * TODO: This is a horrible method that really needs to be broken up in some
81 - * way. There is a lot of setup and WordPress specific functionality going
82 - * on here that would ideally be abstracted away.
83 - *
84 - * @author Peter Featherstone <peter@featherstone.me>
85 - *
86 - * @since 3.0
87 - *
88 - * @param OptionsCollection $options A OptionsCollection object.
89 - */
90 25 private function buildFrontEnd(OptionsCollection $options) {
91 26 add_filter('body_class', function($classes) use($options) {
92 27 $classes[] = 'responsive-menu-' . $options['animation_type'] . '-' . $options['menu_appear_from'];
93 28 return $classes;