mirror of
https://github.com/symfony/ux-map.git
synced 2026-03-23 23:42:07 +01:00
[Map] Introduce ux_map.google_maps.default_map_id configuration
This commit is contained in:
@@ -1,4 +1,9 @@
|
||||
# CHANGELOG
|
||||
|
||||
## 2.22
|
||||
|
||||
- Add method `Symfony\UX\Map\Renderer\AbstractRenderer::tapOptions()`, to allow Renderer to modify options before rendering a Map.
|
||||
- Add `ux_map.google_maps.default_map_id` configuration to set the Google ``Map ID``
|
||||
|
||||
## 2.20
|
||||
|
||||
|
||||
@@ -12,8 +12,6 @@
|
||||
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
|
||||
|
||||
use Symfony\UX\Map\Twig\UXMapComponent;
|
||||
use Symfony\UX\Map\Twig\UXMapComponentListener;
|
||||
use Symfony\UX\TwigComponent\Event\PreCreateForRenderEvent;
|
||||
|
||||
return static function (ContainerConfigurator $container): void {
|
||||
$container->services()
|
||||
|
||||
@@ -31,6 +31,18 @@ abstract readonly class AbstractRenderer implements RendererInterface
|
||||
|
||||
abstract protected function getDefaultMapOptions(): MapOptionsInterface;
|
||||
|
||||
/**
|
||||
* @template T of MapOptionsInterface
|
||||
*
|
||||
* @param T $options
|
||||
*
|
||||
* @return T
|
||||
*/
|
||||
protected function tapOptions(MapOptionsInterface $options): MapOptionsInterface
|
||||
{
|
||||
return $options;
|
||||
}
|
||||
|
||||
final public function renderMap(Map $map, array $attributes = []): string
|
||||
{
|
||||
if (!$map->hasOptions()) {
|
||||
@@ -39,6 +51,8 @@ abstract readonly class AbstractRenderer implements RendererInterface
|
||||
$map->options($defaultMapOptions);
|
||||
}
|
||||
|
||||
$map->options($this->tapOptions($map->getOptions()));
|
||||
|
||||
$controllers = [];
|
||||
if ($attributes['data-controller'] ?? null) {
|
||||
$controllers[$attributes['data-controller']] = [];
|
||||
|
||||
@@ -44,6 +44,12 @@ final class UXMapBundle extends AbstractBundle
|
||||
$rootNode
|
||||
->children()
|
||||
->scalarNode('renderer')->defaultNull()->end()
|
||||
->arrayNode('google_maps')
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
->scalarNode('default_map_id')->defaultNull()->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
;
|
||||
}
|
||||
@@ -75,9 +81,17 @@ final class UXMapBundle extends AbstractBundle
|
||||
foreach (self::$bridges as $name => $bridge) {
|
||||
if (ContainerBuilder::willBeAvailable('symfony/ux-'.$name.'-map', $bridge['renderer_factory'], ['symfony/ux-map'])) {
|
||||
$container->services()
|
||||
->set('ux_map.renderer_factory.'.$name, $bridge['renderer_factory'])
|
||||
->set($rendererFactoryName = 'ux_map.renderer_factory.'.$name, $bridge['renderer_factory'])
|
||||
->parent('ux_map.renderer_factory.abstract')
|
||||
->tag('ux_map.renderer_factory');
|
||||
|
||||
if ('google' === $name) {
|
||||
$container->services()
|
||||
->get($rendererFactoryName)
|
||||
->args([
|
||||
'$defaultMapId' => $config['google_maps']['default_map_id'],
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user