| @@ 22-77 (lines=56) @@ | ||
| 19 | /** |
|
| 20 | * @author GeLo <[email protected]> |
|
| 21 | */ |
|
| 22 | class RotateControlRenderer extends AbstractJsonRenderer implements ControlRendererInterface |
|
| 23 | { |
|
| 24 | /** |
|
| 25 | * @var ControlPositionRenderer |
|
| 26 | */ |
|
| 27 | private $controlPositionRenderer; |
|
| 28 | ||
| 29 | /** |
|
| 30 | * @param Formatter $formatter |
|
| 31 | * @param JsonBuilder $jsonBuilder |
|
| 32 | * @param ControlPositionRenderer $controlPositionRenderer |
|
| 33 | */ |
|
| 34 | public function __construct( |
|
| 35 | Formatter $formatter, |
|
| 36 | JsonBuilder $jsonBuilder, |
|
| 37 | ControlPositionRenderer $controlPositionRenderer |
|
| 38 | ) { |
|
| 39 | parent::__construct($formatter, $jsonBuilder); |
|
| 40 | ||
| 41 | $this->setControlPositionRenderer($controlPositionRenderer); |
|
| 42 | } |
|
| 43 | ||
| 44 | /** |
|
| 45 | * @return ControlPositionRenderer |
|
| 46 | */ |
|
| 47 | public function getControlPositionRenderer() |
|
| 48 | { |
|
| 49 | return $this->controlPositionRenderer; |
|
| 50 | } |
|
| 51 | ||
| 52 | /** |
|
| 53 | * @param ControlPositionRenderer $controlPositionRenderer |
|
| 54 | */ |
|
| 55 | public function setControlPositionRenderer(ControlPositionRenderer $controlPositionRenderer) |
|
| 56 | { |
|
| 57 | $this->controlPositionRenderer = $controlPositionRenderer; |
|
| 58 | } |
|
| 59 | ||
| 60 | /** |
|
| 61 | * {@inheritdoc} |
|
| 62 | */ |
|
| 63 | public function render($control) |
|
| 64 | { |
|
| 65 | if (!$control instanceof RotateControl) { |
|
| 66 | throw new \InvalidArgumentException(sprintf( |
|
| 67 | 'Expected a "%s", got "%s".', |
|
| 68 | RotateControl::class, |
|
| 69 | is_object($control) ? get_class($control) : gettype($control) |
|
| 70 | )); |
|
| 71 | } |
|
| 72 | ||
| 73 | return $this->getJsonBuilder() |
|
| 74 | ->setValue('[position]', $this->controlPositionRenderer->render($control->getPosition()), false) |
|
| 75 | ->build(); |
|
| 76 | } |
|
| 77 | } |
|
| 78 | ||
| @@ 22-77 (lines=56) @@ | ||
| 19 | /** |
|
| 20 | * @author GeLo <[email protected]> |
|
| 21 | */ |
|
| 22 | class StreetViewControlRenderer extends AbstractJsonRenderer implements ControlRendererInterface |
|
| 23 | { |
|
| 24 | /** |
|
| 25 | * @var ControlPositionRenderer |
|
| 26 | */ |
|
| 27 | private $controlPositionRenderer; |
|
| 28 | ||
| 29 | /** |
|
| 30 | * @param Formatter $formatter |
|
| 31 | * @param JsonBuilder $jsonBuilder |
|
| 32 | * @param ControlPositionRenderer $controlPositionRenderer |
|
| 33 | */ |
|
| 34 | public function __construct( |
|
| 35 | Formatter $formatter, |
|
| 36 | JsonBuilder $jsonBuilder, |
|
| 37 | ControlPositionRenderer $controlPositionRenderer |
|
| 38 | ) { |
|
| 39 | parent::__construct($formatter, $jsonBuilder); |
|
| 40 | ||
| 41 | $this->setControlPositionRenderer($controlPositionRenderer); |
|
| 42 | } |
|
| 43 | ||
| 44 | /** |
|
| 45 | * @return ControlPositionRenderer |
|
| 46 | */ |
|
| 47 | public function getControlPositionRenderer() |
|
| 48 | { |
|
| 49 | return $this->controlPositionRenderer; |
|
| 50 | } |
|
| 51 | ||
| 52 | /** |
|
| 53 | * @param ControlPositionRenderer $controlPositionRenderer |
|
| 54 | */ |
|
| 55 | public function setControlPositionRenderer(ControlPositionRenderer $controlPositionRenderer) |
|
| 56 | { |
|
| 57 | $this->controlPositionRenderer = $controlPositionRenderer; |
|
| 58 | } |
|
| 59 | ||
| 60 | /** |
|
| 61 | * {@inheritdoc} |
|
| 62 | */ |
|
| 63 | public function render($control) |
|
| 64 | { |
|
| 65 | if (!$control instanceof StreetViewControl) { |
|
| 66 | throw new \InvalidArgumentException(sprintf( |
|
| 67 | 'Expected a "%s", got "%s".', |
|
| 68 | StreetViewControl::class, |
|
| 69 | is_object($control) ? get_class($control) : gettype($control) |
|
| 70 | )); |
|
| 71 | } |
|
| 72 | ||
| 73 | return $this->getJsonBuilder() |
|
| 74 | ->setValue('[position]', $this->controlPositionRenderer->render($control->getPosition()), false) |
|
| 75 | ->build(); |
|
| 76 | } |
|
| 77 | } |
|
| 78 | ||
| @@ 22-77 (lines=56) @@ | ||
| 19 | /** |
|
| 20 | * @author GeLo <[email protected]> |
|
| 21 | */ |
|
| 22 | class FullscreenControlRenderer extends AbstractJsonRenderer implements ControlRendererInterface |
|
| 23 | { |
|
| 24 | /** |
|
| 25 | * @var ControlPositionRenderer |
|
| 26 | */ |
|
| 27 | private $controlPositionRenderer; |
|
| 28 | ||
| 29 | /** |
|
| 30 | * @param Formatter $formatter |
|
| 31 | * @param JsonBuilder $jsonBuilder |
|
| 32 | * @param ControlPositionRenderer $controlPositionRenderer |
|
| 33 | */ |
|
| 34 | public function __construct( |
|
| 35 | Formatter $formatter, |
|
| 36 | JsonBuilder $jsonBuilder, |
|
| 37 | ControlPositionRenderer $controlPositionRenderer |
|
| 38 | ) { |
|
| 39 | parent::__construct($formatter, $jsonBuilder); |
|
| 40 | ||
| 41 | $this->setControlPositionRenderer($controlPositionRenderer); |
|
| 42 | } |
|
| 43 | ||
| 44 | /** |
|
| 45 | * @return ControlPositionRenderer |
|
| 46 | */ |
|
| 47 | public function getControlPositionRenderer() |
|
| 48 | { |
|
| 49 | return $this->controlPositionRenderer; |
|
| 50 | } |
|
| 51 | ||
| 52 | /** |
|
| 53 | * @param ControlPositionRenderer $controlPositionRenderer |
|
| 54 | */ |
|
| 55 | public function setControlPositionRenderer(ControlPositionRenderer $controlPositionRenderer) |
|
| 56 | { |
|
| 57 | $this->controlPositionRenderer = $controlPositionRenderer; |
|
| 58 | } |
|
| 59 | ||
| 60 | /** |
|
| 61 | * {@inheritdoc} |
|
| 62 | */ |
|
| 63 | public function render($control) |
|
| 64 | { |
|
| 65 | if (!$control instanceof FullscreenControl) { |
|
| 66 | throw new \InvalidArgumentException(sprintf( |
|
| 67 | 'Expected a "%s", got "%s".', |
|
| 68 | FullscreenControl::class, |
|
| 69 | is_object($control) ? get_class($control) : gettype($control) |
|
| 70 | )); |
|
| 71 | } |
|
| 72 | ||
| 73 | return $this->getJsonBuilder() |
|
| 74 | ->setValue('[position]', $this->controlPositionRenderer->render($control->getPosition()), false) |
|
| 75 | ->build(); |
|
| 76 | } |
|
| 77 | } |
|
| 78 | ||