| 1 |
<?php |
| 2 |
|
| 3 |
namespace ResponsiveMenu\ViewModels\Components\Menu; |
| 4 |
use ResponsiveMenu\ViewModels\Components\ViewComponent; |
| 5 |
use ResponsiveMenu\Collections\OptionsCollection; |
| 6 |
use ResponsiveMenu\Translation\Translator; |
| 7 |
|
| 8 |
class Title implements ViewComponent { |
| 9 |
|
| 10 |
public function __construct(Translator $translator) { |
| 11 |
$this->translator = $translator; |
| 12 |
} |
| 13 |
|
| 14 |
public function render(OptionsCollection $options) { |
| 15 |
|
| 16 |
$title = $this->translator->translate($options['menu_title']); |
| 17 |
$link = $this->translator->translate($options['menu_title_link']); |
| 18 |
|
| 19 |
if($options['menu_title']->getValue() || $options->getTitleImage()): |
| 20 |
|
| 21 |
$content = '<div id="responsive-menu-title">'; |
| 22 |
|
| 23 |
if($options['menu_title_link']->getValue()) |
| 24 |
$content .= '<a href="'.$link.'" target="'.$options['menu_title_link_location'].'">'; |
| 25 |
|
| 26 |
if($options->getTitleImage()) |
| 27 |
$content .= '<div id="responsive-menu-title-image">' . $options->getTitleImage() . '</div>'; |
| 28 |
|
| 29 |
if($options['menu_title_link']->getValue()) |
| 30 |
$content .= '</a>'; |
| 31 |
|
| 32 |
if($options['menu_title_link']->getValue()) |
| 33 |
$content .= '<a href="'.$link.'" target="'.$options['menu_title_link_location'].'">'; |
| 34 |
|
| 35 |
$content .= $title; |
| 36 |
|
| 37 |
if($options['menu_title_link']->getValue()) |
| 38 |
$content .= '</a>'; |
| 39 |
|
| 40 |
$content .= '</div>'; |
| 41 |
|
| 42 |
return $content; |
| 43 |
|
| 44 |
endif; |
| 45 |
|
| 46 |
} |
| 47 |
|
| 48 |
} |
| 49 |
|