| 1 |
<?php |
| 2 |
|
| 3 |
namespace ResponsiveMenu\Controllers; |
| 4 |
|
| 5 |
use ResponsiveMenu\Services\OptionService; |
| 6 |
use ResponsiveMenu\View\View; |
| 7 |
use ResponsiveMenu\ViewModels\Menu; |
| 8 |
use ResponsiveMenu\ViewModels\Button; |
| 9 |
|
| 10 |
class Front { |
| 11 |
|
| 12 |
public function __construct(OptionService $service, View $view, Menu $menu, Button $button) { |
| 13 |
$this->service = $service; |
| 14 |
$this->view = $view; |
| 15 |
$this->menu = $menu; |
| 16 |
$this->button = $button; |
| 17 |
} |
| 18 |
|
| 19 |
public function index() { |
| 20 |
|
| 21 |
$options = $this->service->all(); |
| 22 |
|
| 23 |
$this->view->echoOrIncludeScripts($options); |
| 24 |
|
| 25 |
if($options['shortcode'] == 'off'): |
| 26 |
$this->view->render('button', ['options' => $options, 'button' => $this->button->getHtml($options)]); |
| 27 |
return $this->view->render('menu', ['options' => $options, 'menu' => $this->menu->getHtml($options)]); |
| 28 |
else: |
| 29 |
return $this->view->addShortcode($options, $this->button, $this->menu); |
| 30 |
endif; |
| 31 |
|
| 32 |
} |
| 33 |
|
| 34 |
public function preview() { |
| 35 |
return $this->view->render('preview'); |
| 36 |
} |
| 37 |
|
| 38 |
} |
| 39 |
|