/** * Renders the map control * * @param Ivory\GoogleMapBundle\Model\Map $map * @param string $controlName * @param mixed $controlHelper * @return string Map control */ protected function renderMapControl(Map &$map, $controlName, $controlHelper) { $mapControl = array(); $lcFirstControlName = lcfirst($controlName); if ($map->hasMapOption($lcFirstControlName)) { if ($map->getMapOption($lcFirstControlName)) { $mapControl[] = sprintf('"%s":true', $lcFirstControlName); $hasControlMethod = 'has' . $controlName; if ($map->{$hasControlMethod}()) { $getControlMethod = 'get' . $controlName; $mapControl[] = sprintf('"%sOptions":%s', $lcFirstControlName, $controlHelper->render($map->{$getControlMethod}())); } } else { $mapControl[] = sprintf('"%s":false', $lcFirstControlName); } $map->removeMapOption($lcFirstControlName); } return implode(',', $mapControl); }