registerArgument('hotel', Hotel::class, 'The hotel'); $this->registerArgument('region', Region::class, 'The region'); $this->registerArgument('type', 'string', 'The map type', false, 'p'); $this->registerArgument('zoom', 'int', 'The zoom level', false, 10); } /** * @param array $arguments * @param \Closure $renderChildrenClosure * @param RenderingContextInterface $renderingContext * @return mixed */ public function render() { $hotel = $this->arguments['hotel']; $region = $this->arguments['region']; if ($hotel !== null && $hotel->getLatitude() && $hotel->getLongitude()) { $source = $hotel; } elseif ($hotel !== null && $hotel->getRegion()->getLatitude() && $hotel->getRegion()->getLongitude()) { $source = $hotel->getRegion(); } elseif ($region !== null) { $source = $region; } else { return 'http://www.google.de/maps'; } return sprintf(static::URLBASE, $source->getLatitude(), $source->getLongitude(), $this->arguments['type'], $this->arguments['zoom']); } }