From 94e5deb8a0a3c7b13c6e73ddbbf7c44d216cea57 Mon Sep 17 00:00:00 2001 From: Christopher Georg Date: Wed, 21 Feb 2024 12:27:20 +0100 Subject: [PATCH] feat: remove "symfony/templating" --- .../IvoryGoogleMapExtension.php | 1 - Resources/config/templating.xml | 41 ------- Resources/doc/map.md | 19 --- Resources/doc/static_map.md | 8 -- .../Form/place_autocomplete_widget.html.php | 4 - Templating/ApiHelper.php | 50 -------- Templating/MapHelper.php | 75 ------------ Templating/PlaceAutocompleteHelper.php | 65 ----------- Templating/StaticMapHelper.php | 48 -------- .../AbstractIvoryGoogleMapExtensionTest.php | 11 -- Tests/Templating/ApiHelperTest.php | 66 ----------- Tests/Templating/MapHelperTest.php | 108 ------------------ .../PlaceAutocompleteHelperTest.php | 97 ---------------- Tests/Templating/StaticMapHelperTest.php | 75 ------------ composer.json | 1 - 15 files changed, 669 deletions(-) delete mode 100644 Resources/config/templating.xml delete mode 100644 Resources/views/Form/place_autocomplete_widget.html.php delete mode 100644 Templating/ApiHelper.php delete mode 100644 Templating/MapHelper.php delete mode 100644 Templating/PlaceAutocompleteHelper.php delete mode 100644 Templating/StaticMapHelper.php delete mode 100644 Tests/Templating/ApiHelperTest.php delete mode 100644 Tests/Templating/MapHelperTest.php delete mode 100644 Tests/Templating/PlaceAutocompleteHelperTest.php delete mode 100644 Tests/Templating/StaticMapHelperTest.php diff --git a/DependencyInjection/IvoryGoogleMapExtension.php b/DependencyInjection/IvoryGoogleMapExtension.php index e081fb39..5554f488 100644 --- a/DependencyInjection/IvoryGoogleMapExtension.php +++ b/DependencyInjection/IvoryGoogleMapExtension.php @@ -40,7 +40,6 @@ protected function loadInternal(array $mergedConfig, ContainerBuilder $container 'helper/renderer', 'helper/subscriber', 'helper/utility', - 'templating', 'twig', ]; diff --git a/Resources/config/templating.xml b/Resources/config/templating.xml deleted file mode 100644 index 4ab0dce4..00000000 --- a/Resources/config/templating.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Resources/doc/map.md b/Resources/doc/map.md index 0632900e..a9ca20cc 100644 --- a/Resources/doc/map.md +++ b/Resources/doc/map.md @@ -70,22 +70,3 @@ The available Twig functions are: - `ivory_google_map_css`: Renders the map stylesheet. **Don't forget to always render the Google API loading after rendering your map.** - -### Php - -If you're using the PHP templating engine, then, the most easy way to render a map is: - -``` php -render($map) ?> -render([$map]) ?> -``` - -The available helper methods are: - - - `ivory_google_api::render`: Renders the Google API loading. - - `ivory_google_map::render`: Renders the map container + javascript + stylesheet. - - `ivory_google_map::renderHtml`: Renders the map container. - - `ivory_google_map::renderJavascript`: Renders the map javascript. - - `ivory_google_map::renderStylesheet`: Renders the map stylesheet. - -**Don't forget to always render the Google API loading after rendering your map.** diff --git a/Resources/doc/static_map.md b/Resources/doc/static_map.md index b1dd0796..48de96ae 100644 --- a/Resources/doc/static_map.md +++ b/Resources/doc/static_map.md @@ -62,11 +62,3 @@ If you're using Twig, the most easy way to render a map is: ``` twig ``` - -### Php - -If you're using the PHP templating engine, then, the most easy way to render a map is: - -``` php - -``` diff --git a/Resources/views/Form/place_autocomplete_widget.html.php b/Resources/views/Form/place_autocomplete_widget.html.php deleted file mode 100644 index 0dc4438c..00000000 --- a/Resources/views/Form/place_autocomplete_widget.html.php +++ /dev/null @@ -1,4 +0,0 @@ -render($autocomplete, $attr) ?> - - render([$autocomplete]) ?> - diff --git a/Templating/ApiHelper.php b/Templating/ApiHelper.php deleted file mode 100644 index 693df26c..00000000 --- a/Templating/ApiHelper.php +++ /dev/null @@ -1,50 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMapBundle\Templating; - -use Ivory\GoogleMap\Helper\ApiHelper as BaseApiHelper; -use Symfony\Component\Templating\Helper\Helper; - -/** - * @author GeLo - */ -class ApiHelper extends Helper -{ - /** - * @var BaseApiHelper - */ - private $apiHelper; - - /** - * @param BaseApiHelper $apiHelper - */ - public function __construct(BaseApiHelper $apiHelper) - { - $this->apiHelper = $apiHelper; - } - - /** - * @param object[] $objects - */ - public function render(array $objects): string - { - return $this->apiHelper->render($objects); - } - - /** - * {@inheritdoc} - */ - public function getName(): string - { - return 'ivory_google_api'; - } -} diff --git a/Templating/MapHelper.php b/Templating/MapHelper.php deleted file mode 100644 index 1ab1283e..00000000 --- a/Templating/MapHelper.php +++ /dev/null @@ -1,75 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMapBundle\Templating; - -use Ivory\GoogleMap\Helper\MapHelper as BaseMapHelper; -use Ivory\GoogleMap\Map; -use Symfony\Component\Templating\Helper\Helper; - -/** - * @author GeLo - */ -class MapHelper extends Helper -{ - /** - * @var BaseMapHelper - */ - private $mapHelper; - - /** - * @param BaseMapHelper $mapHelper - */ - public function __construct(BaseMapHelper $mapHelper) - { - $this->mapHelper = $mapHelper; - } - - /** - * @param Map $map - * @param string[] $attributes - */ - public function render(Map $map, array $attributes = []): string - { - $map->addHtmlAttributes($attributes); - - return $this->mapHelper->render($map); - } - - /** - * @param Map $map - * @param string[] $attributes - */ - public function renderHtml(Map $map, array $attributes = []): string - { - $map->addHtmlAttributes($attributes); - - return $this->mapHelper->renderHtml($map); - } - - public function renderStylesheet(Map $map): string - { - return $this->mapHelper->renderStylesheet($map); - } - - public function renderJavascript(Map $map): string - { - return $this->mapHelper->renderJavascript($map); - } - - /** - * {@inheritdoc} - */ - public function getName(): string - { - return 'ivory_google_map'; - } -} diff --git a/Templating/PlaceAutocompleteHelper.php b/Templating/PlaceAutocompleteHelper.php deleted file mode 100644 index 6723c1b9..00000000 --- a/Templating/PlaceAutocompleteHelper.php +++ /dev/null @@ -1,65 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMapBundle\Templating; - -use Ivory\GoogleMap\Helper\PlaceAutocompleteHelper as BasePlaceAutocompleteHelper; -use Ivory\GoogleMap\Place\Autocomplete; -use Symfony\Component\Templating\Helper\Helper; - -/** - * @author GeLo - */ -class PlaceAutocompleteHelper extends Helper -{ - /** - * @var BasePlaceAutocompleteHelper - */ - private $placeAutocompleteHelper; - - public function __construct(BasePlaceAutocompleteHelper $placeAutocompleteHelper) - { - $this->placeAutocompleteHelper = $placeAutocompleteHelper; - } - - /** - * @param string[] $attributes - */ - public function render(Autocomplete $autocomplete, array $attributes = []): string - { - $autocomplete->addInputAttributes($attributes); - - return $this->placeAutocompleteHelper->render($autocomplete); - } - - /** - * @param string[] $attributes - */ - public function renderHtml(Autocomplete $autocomplete, array $attributes = []): string - { - $autocomplete->addInputAttributes($attributes); - - return $this->placeAutocompleteHelper->renderHtml($autocomplete); - } - - public function renderJavascript(Autocomplete $autocomplete): string - { - return $this->placeAutocompleteHelper->renderJavascript($autocomplete); - } - - /** - * {@inheritdoc} - */ - public function getName(): string - { - return 'ivory_google_place_autocomplete'; - } -} diff --git a/Templating/StaticMapHelper.php b/Templating/StaticMapHelper.php deleted file mode 100644 index ce1a6369..00000000 --- a/Templating/StaticMapHelper.php +++ /dev/null @@ -1,48 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMapBundle\Templating; - -use Ivory\GoogleMap\Helper\StaticMapHelper as BaseStaticMapHelper; -use Ivory\GoogleMap\Map; -use Symfony\Component\Templating\Helper\Helper; - -/** - * @author GeLo - */ -class StaticMapHelper extends Helper -{ - /** - * @var BaseStaticMapHelper - */ - private $staticMapHelper; - - /** - * @param BaseStaticMapHelper $staticMapHelper - */ - public function __construct(BaseStaticMapHelper $staticMapHelper) - { - $this->staticMapHelper = $staticMapHelper; - } - - public function render(Map $map): string - { - return $this->staticMapHelper->render($map); - } - - /** - * {@inheritdoc} - */ - public function getName(): string - { - return 'ivory_google_map_static'; - } -} diff --git a/Tests/DependencyInjection/AbstractIvoryGoogleMapExtensionTest.php b/Tests/DependencyInjection/AbstractIvoryGoogleMapExtensionTest.php index 2247c43d..0a911b52 100644 --- a/Tests/DependencyInjection/AbstractIvoryGoogleMapExtensionTest.php +++ b/Tests/DependencyInjection/AbstractIvoryGoogleMapExtensionTest.php @@ -136,17 +136,6 @@ public function testDefaultState(): void $this->assertFalse($this->container->has('ivory.google_map.twig.extension.place_autocomplete')); } - public function testTemplatingHelpers() - { - $this->container->setDefinition('templating.engine.php', new Definition(\stdClass::class)); - $this->container->compile(); - - $this->assertTrue($this->container->has('ivory.google_map.templating.api')); - $this->assertTrue($this->container->has('ivory.google_map.templating.map')); - $this->assertTrue($this->container->has('ivory.google_map.templating.map.static')); - $this->assertTrue($this->container->has('ivory.google_map.templating.place_autocomplete')); - } - public function testTwigExtensions() { $this->container->setDefinition('twig', new Definition(\stdClass::class)); diff --git a/Tests/Templating/ApiHelperTest.php b/Tests/Templating/ApiHelperTest.php deleted file mode 100644 index e31be037..00000000 --- a/Tests/Templating/ApiHelperTest.php +++ /dev/null @@ -1,66 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMapBundle\Tests\Templating; - -use Ivory\GoogleMap\Helper\ApiHelper as BaseApiHelper; -use Ivory\GoogleMapBundle\Templating\ApiHelper; -use PHPUnit\Framework\MockObject\MockObject; -use PHPUnit\Framework\TestCase; - -/** - * @author GeLo - */ -class ApiHelperTest extends TestCase -{ - /** - * @var ApiHelper - */ - private $apiHelper; - - /** - * @var BaseApiHelper|MockObject - */ - private $innerApiHelper; - - /** - * {@inheritdoc} - */ - protected function setUp(): void - { - $this->innerApiHelper = $this->createApiHelperMock(); - $this->apiHelper = new ApiHelper($this->innerApiHelper); - } - - public function testRender(): void - { - $this->innerApiHelper - ->expects($this->once()) - ->method('render') - ->with($this->identicalTo($objects = [new \stdClass()])) - ->will($this->returnValue($result = 'result')); - - $this->assertSame($result, $this->apiHelper->render($objects)); - } - - public function testName() - { - $this->assertSame('ivory_google_api', $this->apiHelper->getName()); - } - - /** - * @return MockObject|BaseApiHelper - */ - private function createApiHelperMock() - { - return $this->createMock(BaseApiHelper::class); - } -} diff --git a/Tests/Templating/MapHelperTest.php b/Tests/Templating/MapHelperTest.php deleted file mode 100644 index 99413dad..00000000 --- a/Tests/Templating/MapHelperTest.php +++ /dev/null @@ -1,108 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMapBundle\Tests\Templating; - -use Ivory\GoogleMap\Helper\MapHelper as BaseMapHelper; -use Ivory\GoogleMap\Map; -use Ivory\GoogleMapBundle\Templating\MapHelper; -use PHPUnit\Framework\MockObject\MockObject; -use PHPUnit\Framework\TestCase; - -/** - * @author GeLo - */ -class MapHelperTest extends TestCase -{ - /** - * @var MapHelper - */ - private $mapHelper; - - /** - * @var BaseMapHelper|MockObject - */ - private $innerMapHelper; - - /** - * {@inheritdoc} - */ - protected function setUp(): void - { - $this->innerMapHelper = $this->createMapHelperMock(); - $this->mapHelper = new MapHelper($this->innerMapHelper); - } - - public function testRender() - { - $this->innerMapHelper - ->expects($this->once()) - ->method('render') - ->with($this->identicalTo($map = $this->createMapMock())) - ->will($this->returnValue($result = 'result')); - - $this->assertSame($result, $this->mapHelper->render($map)); - } - - public function testRenderHtml() - { - $this->innerMapHelper - ->expects($this->once()) - ->method('renderHtml') - ->with($this->identicalTo($map = $this->createMapMock())) - ->will($this->returnValue($result = 'result')); - - $this->assertSame($result, $this->mapHelper->renderHtml($map)); - } - - public function testRenderStylesheet() - { - $this->innerMapHelper - ->expects($this->once()) - ->method('renderStylesheet') - ->with($this->identicalTo($map = $this->createMapMock())) - ->will($this->returnValue($result = 'result')); - - $this->assertSame($result, $this->mapHelper->renderStylesheet($map)); - } - - public function testRenderJavascript() - { - $this->innerMapHelper - ->expects($this->once()) - ->method('renderJavascript') - ->with($this->identicalTo($map = $this->createMapMock())) - ->will($this->returnValue($result = 'result')); - - $this->assertSame($result, $this->mapHelper->renderJavascript($map)); - } - - public function testName() - { - $this->assertSame('ivory_google_map', $this->mapHelper->getName()); - } - - /** - * @return MockObject|BaseMapHelper - */ - private function createMapHelperMock() - { - return $this->createMock(BaseMapHelper::class); - } - - /** - * @return MockObject|Map - */ - private function createMapMock() - { - return $this->createMock(Map::class); - } -} diff --git a/Tests/Templating/PlaceAutocompleteHelperTest.php b/Tests/Templating/PlaceAutocompleteHelperTest.php deleted file mode 100644 index 2724660e..00000000 --- a/Tests/Templating/PlaceAutocompleteHelperTest.php +++ /dev/null @@ -1,97 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMapBundle\Tests\Templating; - -use Ivory\GoogleMap\Helper\PlaceAutocompleteHelper as BasePlaceAutocompleteHelper; -use Ivory\GoogleMap\Place\Autocomplete; -use Ivory\GoogleMapBundle\Templating\PlaceAutocompleteHelper; -use PHPUnit\Framework\MockObject\MockObject; -use PHPUnit\Framework\TestCase; - -/** - * @author GeLo - */ -class PlaceAutocompleteHelperTest extends TestCase -{ - /** - * @var PlaceAutocompleteHelper - */ - private $placeAutocompleteHelper; - - /** - * @var BasePlaceAutocompleteHelper|MockObject - */ - private $innerPlaceAutocompleteHelper; - - /** - * {@inheritdoc} - */ - protected function setUp(): void - { - $this->innerPlaceAutocompleteHelper = $this->createPlaceAutocompleteHelperMock(); - $this->placeAutocompleteHelper = new PlaceAutocompleteHelper($this->innerPlaceAutocompleteHelper); - } - - public function testRender() - { - $this->innerPlaceAutocompleteHelper - ->expects($this->once()) - ->method('render') - ->with($this->identicalTo($autocomplete = $this->createAutocompleteMock())) - ->will($this->returnValue($result = 'result')); - - $this->assertSame($result, $this->placeAutocompleteHelper->render($autocomplete)); - } - - public function testRenderHtml() - { - $this->innerPlaceAutocompleteHelper - ->expects($this->once()) - ->method('renderHtml') - ->with($this->identicalTo($autocomplete = $this->createAutocompleteMock())) - ->will($this->returnValue($result = 'result')); - - $this->assertSame($result, $this->placeAutocompleteHelper->renderHtml($autocomplete)); - } - - public function testRenderJavascript() - { - $this->innerPlaceAutocompleteHelper - ->expects($this->once()) - ->method('renderJavascript') - ->with($this->identicalTo($autocomplete = $this->createAutocompleteMock())) - ->will($this->returnValue($result = 'result')); - - $this->assertSame($result, $this->placeAutocompleteHelper->renderJavascript($autocomplete)); - } - - public function testName() - { - $this->assertSame('ivory_google_place_autocomplete', $this->placeAutocompleteHelper->getName()); - } - - /** - * @return MockObject|BasePlaceAutocompleteHelper - */ - private function createPlaceAutocompleteHelperMock() - { - return $this->createMock(BasePlaceAutocompleteHelper::class); - } - - /** - * @return MockObject|Autocomplete - */ - private function createAutocompleteMock() - { - return $this->createMock(Autocomplete::class); - } -} diff --git a/Tests/Templating/StaticMapHelperTest.php b/Tests/Templating/StaticMapHelperTest.php deleted file mode 100644 index 0fb03454..00000000 --- a/Tests/Templating/StaticMapHelperTest.php +++ /dev/null @@ -1,75 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMapBundle\Tests\Templating; - -use Ivory\GoogleMap\Helper\StaticMapHelper as BaseStaticMapHelper; -use Ivory\GoogleMap\Map; -use Ivory\GoogleMapBundle\Templating\StaticMapHelper; -use PHPUnit\Framework\MockObject\MockObject; -use PHPUnit\Framework\TestCase; - -/** - * @author GeLo - */ -class StaticMapHelperTest extends TestCase -{ - /** - * @var StaticMapHelper - */ - private $staticMapHelper; - - /** - * @var BaseStaticMapHelper|MockObject - */ - private $innerStaticMapHelper; - - /** - * {@inheritdoc} - */ - protected function setUp(): void - { - $this->innerStaticMapHelper = $this->createStaticMapHelperMock(); - $this->staticMapHelper = new StaticMapHelper($this->innerStaticMapHelper); - } - - public function testRender() - { - $this->innerStaticMapHelper - ->expects($this->once()) - ->method('render') - ->with($this->identicalTo($map = $this->createMapMock())) - ->will($this->returnValue($result = 'result')); - - $this->assertSame($result, $this->staticMapHelper->render($map)); - } - - public function testName() - { - $this->assertSame('ivory_google_map_static', $this->staticMapHelper->getName()); - } - - /** - * @return MockObject|BaseStaticMapHelper - */ - private function createStaticMapHelperMock() - { - return $this->createMock(BaseStaticMapHelper::class); - } - - /** - * @return MockObject|Map - */ - private function createMapMock() - { - return $this->createMock(Map::class); - } -} diff --git a/composer.json b/composer.json index 80a758c3..8f321f23 100644 --- a/composer.json +++ b/composer.json @@ -30,7 +30,6 @@ "symfony/cache": "^6.4 || ^7.0", "symfony/form": "^6.4 || ^7.0", "symfony/phpunit-bridge": "^6.4 || ^7.0", - "symfony/templating": "^6.4", "symfony/yaml": "^6.4 || ^7.0", "twig/twig": "^3.8" },