| 1 |
<?php |
| 2 |
|
| 3 |
namespace ResponsiveMenu\Collections; |
| 4 |
use ResponsiveMenu\Models\Option as Option; |
| 5 |
|
| 6 |
class OptionsCollection implements \ArrayAccess { |
| 7 |
|
| 8 |
private $options; |
| 9 |
|
| 10 |
public function add(Option $option) { |
| 11 |
$this->options[$option->getName()] = $option; |
| 12 |
} |
| 13 |
|
| 14 |
public function get($name) { |
| 15 |
return $this->options[$name]; |
| 16 |
} |
| 17 |
|
| 18 |
public function all() { |
| 19 |
return $this->options; |
| 20 |
} |
| 21 |
|
| 22 |
public function usesFontIcons() { |
| 23 |
return false; |
| 24 |
} |
| 25 |
|
| 26 |
public function getActiveArrow() { |
| 27 |
if($this->options['active_arrow_image'] && $this->options['active_arrow_image']->getValue()) |
| 28 |
return '<img src="' . $this->options['active_arrow_image'] .'" />'; |
| 29 |
else |
| 30 |
return $this->options['active_arrow_shape']; |
| 31 |
|
| 32 |
} |
| 33 |
|
| 34 |
public function getInActiveArrow() { |
| 35 |
if($this->options['inactive_arrow_image'] && $this->options['inactive_arrow_image']->getValue()) |
| 36 |
return '<img src="' . $this->options['inactive_arrow_image'] .'" />'; |
| 37 |
else |
| 38 |
return $this->options['inactive_arrow_shape']; |
| 39 |
|
| 40 |
} |
| 41 |
|
| 42 |
public function getTitleImage() { |
| 43 |
if($this->options['menu_title_image'] && $this->options['menu_title_image']->getValue()) |
| 44 |
return '<img src="' . $this->options['menu_title_image'] .'" />'; |
| 45 |
else |
| 46 |
return null; |
| 47 |
|
| 48 |
} |
| 49 |
|
| 50 |
public function getButtonIcon() { |
| 51 |
if($this->options['button_image'] && $this->options['button_image']->getValue()) |
| 52 |
return '<img src="' . $this->options['button_image'] .'" class="responsive-menu-button-icon responsive-menu-button-icon-active" />'; |
| 53 |
else |
| 54 |
return '<span class="responsive-menu-inner"></span>'; |
| 55 |
} |
| 56 |
|
| 57 |
public function getButtonIconActive() { |
| 58 |
if($this->options['button_image'] && $this->options['button_image']->getValue()) |
| 59 |
return '<img src="' . $this->options['button_image_when_clicked'] .'" class=" responsive-menu-button-icon responsive-menu-button-icon-inactive" />'; |
| 60 |
} |
| 61 |
|
| 62 |
public function offsetExists($offset) { |
| 63 |
return array_key_exists($offset, $this->options); |
| 64 |
} |
| 65 |
|
| 66 |
public function offsetGet($offset) { |
| 67 |
return $this->options[$offset]; |
| 68 |
} |
| 69 |
|
| 70 |
public function offsetSet($offset, $value) { |
| 71 |
if(isset($this->options[$offset])) |
| 72 |
$this->options[$offset]->setValue($value); |
| 73 |
} |
| 74 |
|
| 75 |
public function offsetUnset($offset) { |
| 76 |
unset($this->options[$offset]); |
| 77 |
} |
| 78 |
|
| 79 |
public function isEmpty() { |
| 80 |
return isset($this->options) && count($this->options) > 0 ? false : true; |
| 81 |
} |
| 82 |
|
| 83 |
} |
| 84 |
|