From 7438808aee5354d6e18864faad31686df5ca2b85 Mon Sep 17 00:00:00 2001
From: Patrizio Bekerle <patrizio.bekerle@tugraz.at>
Date: Tue, 26 Apr 2022 09:19:19 +0200
Subject: [PATCH] Add more migrations from "template" to "example"

---
 composer.json                                 |  8 ++---
 phpunit.xml.dist                              |  2 +-
 src/Command/TestCommand.php                   |  2 +-
 src/Controller/LoggedInOnly.php               |  4 +--
 src/DataPersister/PlaceDataPersister.php      |  6 ++--
 .../PlaceCollectionDataProvider.php           |  6 ++--
 src/DataProvider/PlaceItemDataProvider.php    |  6 ++--
 ...teBundle.php => DbpRelayExampleBundle.php} |  4 +--
 src/DependencyInjection/Configuration.php     |  2 +-
 .../DbpRelayTemplateExtension.php             |  6 ++--
 src/Entity/Place.php                          | 32 +++++++++----------
 src/Resources/config/services.yaml            | 16 +++++-----
 src/Service/ExternalApi.php                   |  4 +--
 src/Service/MyCustomService.php               |  2 +-
 src/Service/PlaceProviderInterface.php        |  4 +--
 tests/ApiTest.php                             | 12 +++----
 tests/Kernel.php                              |  6 ++--
 tests/Service/ExternalApiTest.php             |  6 ++--
 18 files changed, 64 insertions(+), 64 deletions(-)
 rename src/{DbpRelayTemplateBundle.php => DbpRelayExampleBundle.php} (72%)

diff --git a/composer.json b/composer.json
index 4198b91..5932a93 100644
--- a/composer.json
+++ b/composer.json
@@ -1,6 +1,6 @@
 {
-    "name": "dbp/relay-template-bundle",
-    "description": "A template bundle for the Relay API gateway",
+    "name": "dbp/relay-example-bundle",
+    "description": "An example bundle for the Relay API gateway",
     "type": "symfony-bundle",
     "license": "AGPL-3.0-or-later",
     "require": {
@@ -23,12 +23,12 @@
     },
     "autoload": {
         "psr-4": {
-            "Dbp\\Relay\\TemplateBundle\\": "src/"
+            "Dbp\\Relay\\ExampleBundle\\": "src/"
         }
     },
     "autoload-dev": {
         "psr-4": {
-            "Dbp\\Relay\\TemplateBundle\\Tests\\": "tests/"
+            "Dbp\\Relay\\ExampleBundle\\Tests\\": "tests/"
         }
     },
     "config": {
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index ff463f6..99d85aa 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -12,7 +12,7 @@
     <server name="APP_ENV" value="test" force="true"/>
     <server name="SHELL_VERBOSITY" value="-1"/>
     <server name="SYMFONY_DEPRECATIONS_HELPER" value='max[direct]=0&amp;quiet[]=indirect'/>
-    <server name="KERNEL_CLASS" value="Dbp\Relay\TemplateBundle\Tests\Kernel"/>
+    <server name="KERNEL_CLASS" value="Dbp\Relay\ExampleBundle\Tests\Kernel"/>
   </php>
   <testsuites>
     <testsuite name="Project Test Suite">
diff --git a/src/Command/TestCommand.php b/src/Command/TestCommand.php
index 87f0172..8d9005b 100644
--- a/src/Command/TestCommand.php
+++ b/src/Command/TestCommand.php
@@ -2,7 +2,7 @@
 
 declare(strict_types=1);
 
-namespace Dbp\Relay\TemplateBundle\Command;
+namespace Dbp\Relay\ExampleBundle\Command;
 
 use Symfony\Component\Console\Command\Command;
 use Symfony\Component\Console\Input\InputArgument;
diff --git a/src/Controller/LoggedInOnly.php b/src/Controller/LoggedInOnly.php
index 16aee9c..7cfe4bd 100644
--- a/src/Controller/LoggedInOnly.php
+++ b/src/Controller/LoggedInOnly.php
@@ -2,9 +2,9 @@
 
 declare(strict_types=1);
 
-namespace Dbp\Relay\TemplateBundle\Controller;
+namespace Dbp\Relay\ExampleBundle\Controller;
 
-use Dbp\Relay\TemplateBundle\Entity\Place;
+use Dbp\Relay\ExampleBundle\Entity\Place;
 use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
 use Symfony\Component\HttpFoundation\Request;
 
diff --git a/src/DataPersister/PlaceDataPersister.php b/src/DataPersister/PlaceDataPersister.php
index bec4060..8b90ff7 100644
--- a/src/DataPersister/PlaceDataPersister.php
+++ b/src/DataPersister/PlaceDataPersister.php
@@ -2,11 +2,11 @@
 
 declare(strict_types=1);
 
-namespace Dbp\Relay\TemplateBundle\DataPersister;
+namespace Dbp\Relay\ExampleBundle\DataPersister;
 
 use ApiPlatform\Core\DataPersister\DataPersisterInterface;
-use Dbp\Relay\TemplateBundle\Entity\Place;
-use Dbp\Relay\TemplateBundle\Service\PlaceProviderInterface;
+use Dbp\Relay\ExampleBundle\Entity\Place;
+use Dbp\Relay\ExampleBundle\Service\PlaceProviderInterface;
 use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
 
 class PlaceDataPersister extends AbstractController implements DataPersisterInterface
diff --git a/src/DataProvider/PlaceCollectionDataProvider.php b/src/DataProvider/PlaceCollectionDataProvider.php
index b89deee..a2537c7 100644
--- a/src/DataProvider/PlaceCollectionDataProvider.php
+++ b/src/DataProvider/PlaceCollectionDataProvider.php
@@ -2,13 +2,13 @@
 
 declare(strict_types=1);
 
-namespace Dbp\Relay\TemplateBundle\DataProvider;
+namespace Dbp\Relay\ExampleBundle\DataProvider;
 
 use ApiPlatform\Core\DataProvider\CollectionDataProviderInterface;
 use ApiPlatform\Core\DataProvider\RestrictedDataProviderInterface;
 use Dbp\Relay\CoreBundle\Helpers\ArrayFullPaginator;
-use Dbp\Relay\TemplateBundle\Entity\Place;
-use Dbp\Relay\TemplateBundle\Service\PlaceProviderInterface;
+use Dbp\Relay\ExampleBundle\Entity\Place;
+use Dbp\Relay\ExampleBundle\Service\PlaceProviderInterface;
 use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
 
 final class PlaceCollectionDataProvider extends AbstractController implements CollectionDataProviderInterface, RestrictedDataProviderInterface
diff --git a/src/DataProvider/PlaceItemDataProvider.php b/src/DataProvider/PlaceItemDataProvider.php
index bba02e1..dd0d633 100644
--- a/src/DataProvider/PlaceItemDataProvider.php
+++ b/src/DataProvider/PlaceItemDataProvider.php
@@ -2,12 +2,12 @@
 
 declare(strict_types=1);
 
-namespace Dbp\Relay\TemplateBundle\DataProvider;
+namespace Dbp\Relay\ExampleBundle\DataProvider;
 
 use ApiPlatform\Core\DataProvider\ItemDataProviderInterface;
 use ApiPlatform\Core\DataProvider\RestrictedDataProviderInterface;
-use Dbp\Relay\TemplateBundle\Entity\Place;
-use Dbp\Relay\TemplateBundle\Service\PlaceProviderInterface;
+use Dbp\Relay\ExampleBundle\Entity\Place;
+use Dbp\Relay\ExampleBundle\Service\PlaceProviderInterface;
 use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
 
 final class PlaceItemDataProvider extends AbstractController implements ItemDataProviderInterface, RestrictedDataProviderInterface
diff --git a/src/DbpRelayTemplateBundle.php b/src/DbpRelayExampleBundle.php
similarity index 72%
rename from src/DbpRelayTemplateBundle.php
rename to src/DbpRelayExampleBundle.php
index e040da7..823295f 100644
--- a/src/DbpRelayTemplateBundle.php
+++ b/src/DbpRelayExampleBundle.php
@@ -2,12 +2,12 @@
 
 declare(strict_types=1);
 
-namespace Dbp\Relay\TemplateBundle;
+namespace Dbp\Relay\ExampleBundle;
 
 use Symfony\Component\DependencyInjection\ContainerBuilder;
 use Symfony\Component\HttpKernel\Bundle\Bundle;
 
-class DbpRelayTemplateBundle extends Bundle
+class DbpRelayExampleBundle extends Bundle
 {
     public function build(ContainerBuilder $container)
     {
diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php
index 86353cb..9a931b4 100644
--- a/src/DependencyInjection/Configuration.php
+++ b/src/DependencyInjection/Configuration.php
@@ -2,7 +2,7 @@
 
 declare(strict_types=1);
 
-namespace Dbp\Relay\TemplateBundle\DependencyInjection;
+namespace Dbp\Relay\ExampleBundle\DependencyInjection;
 
 use Symfony\Component\Config\Definition\Builder\TreeBuilder;
 use Symfony\Component\Config\Definition\ConfigurationInterface;
diff --git a/src/DependencyInjection/DbpRelayTemplateExtension.php b/src/DependencyInjection/DbpRelayTemplateExtension.php
index 93d457a..842ceb8 100644
--- a/src/DependencyInjection/DbpRelayTemplateExtension.php
+++ b/src/DependencyInjection/DbpRelayTemplateExtension.php
@@ -2,14 +2,14 @@
 
 declare(strict_types=1);
 
-namespace Dbp\Relay\TemplateBundle\DependencyInjection;
+namespace Dbp\Relay\ExampleBundle\DependencyInjection;
 
 use Symfony\Component\Config\FileLocator;
 use Symfony\Component\DependencyInjection\ContainerBuilder;
 use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
 use Symfony\Component\HttpKernel\DependencyInjection\ConfigurableExtension;
 
-class DbpRelayTemplateExtension extends ConfigurableExtension
+class DbpRelayExampleExtension extends ConfigurableExtension
 {
     public function loadInternal(array $mergedConfig, ContainerBuilder $container)
     {
@@ -23,7 +23,7 @@ class DbpRelayTemplateExtension extends ConfigurableExtension
         $loader->load('services.yaml');
 
         // Inject the config value into the MyCustomService service
-        $definition = $container->getDefinition('Dbp\Relay\TemplateBundle\Service\MyCustomService');
+        $definition = $container->getDefinition('Dbp\Relay\ExampleBundle\Service\MyCustomService');
         $definition->addArgument($mergedConfig['example_config']);
     }
 
diff --git a/src/Entity/Place.php b/src/Entity/Place.php
index 1efa7c0..0b18ad8 100644
--- a/src/Entity/Place.php
+++ b/src/Entity/Place.php
@@ -2,61 +2,61 @@
 
 declare(strict_types=1);
 
-namespace Dbp\Relay\TemplateBundle\Entity;
+namespace Dbp\Relay\ExampleBundle\Entity;
 
 use ApiPlatform\Core\Annotation\ApiProperty;
 use ApiPlatform\Core\Annotation\ApiResource;
-use Dbp\Relay\TemplateBundle\Controller\LoggedInOnly;
+use Dbp\Relay\ExampleBundle\Controller\LoggedInOnly;
 use Symfony\Component\Serializer\Annotation\Groups;
 
 /**
  * @ApiResource(
  *     collectionOperations={
  *         "get" = {
- *             "path" = "/template/places",
+ *             "path" = "/example/places",
  *             "openapi_context" = {
- *                 "tags" = {"Template"},
+ *                 "tags" = {"Example"},
  *             },
  *         }
  *     },
  *     itemOperations={
  *         "get" = {
- *             "path" = "/template/places/{identifier}",
+ *             "path" = "/example/places/{identifier}",
  *             "openapi_context" = {
- *                 "tags" = {"Template"},
+ *                 "tags" = {"Example"},
  *             },
  *         },
  *         "put" = {
- *             "path" = "/template/places/{identifier}",
+ *             "path" = "/example/places/{identifier}",
  *             "openapi_context" = {
- *                 "tags" = {"Template"},
+ *                 "tags" = {"Example"},
  *             },
  *         },
  *         "delete" = {
- *             "path" = "/template/places/{identifier}",
+ *             "path" = "/example/places/{identifier}",
  *             "openapi_context" = {
- *                 "tags" = {"Template"},
+ *                 "tags" = {"Example"},
  *             },
  *         },
  *         "loggedin_only" = {
  *             "security" = "is_granted('IS_AUTHENTICATED_FULLY')",
  *             "method" = "GET",
- *             "path" = "/template/places/{identifier}/loggedin-only",
+ *             "path" = "/example/places/{identifier}/loggedin-only",
  *             "controller" = LoggedInOnly::class,
  *             "openapi_context" = {
  *                 "summary" = "Only works when logged in.",
- *                 "tags" = {"Template"},
+ *                 "tags" = {"Example"},
  *             },
  *         }
  *     },
  *     iri="https://schema.org/Place",
- *     shortName="TemplatePlace",
+ *     shortName="ExamplePlace",
  *     normalizationContext={
- *         "groups" = {"TemplatePlace:output"},
+ *         "groups" = {"ExamplePlace:output"},
  *         "jsonld_embed_context" = true
  *     },
  *     denormalizationContext={
- *         "groups" = {"TemplatePlace:input"},
+ *         "groups" = {"ExamplePlace:input"},
  *         "jsonld_embed_context" = true
  *     }
  * )
@@ -70,7 +70,7 @@ class Place
 
     /**
      * @ApiProperty(iri="https://schema.org/name")
-     * @Groups({"TemplatePlace:output", "TemplatePlace:input"})
+     * @Groups({"ExamplePlace:output", "ExamplePlace:input"})
      *
      * @var string
      */
diff --git a/src/Resources/config/services.yaml b/src/Resources/config/services.yaml
index 9e9466b..3ed8519 100644
--- a/src/Resources/config/services.yaml
+++ b/src/Resources/config/services.yaml
@@ -1,30 +1,30 @@
 services:
-  Dbp\Relay\TemplateBundle\Command\TestCommand:
+  Dbp\Relay\ExampleBundle\Command\TestCommand:
     autowire: true
     autoconfigure: true
 
-  Dbp\Relay\TemplateBundle\Controller\:
+  Dbp\Relay\ExampleBundle\Controller\:
     resource: '../../Controller'
     autoconfigure: true
     autowire: true
 
-  Dbp\Relay\TemplateBundle\DataPersister\:
+  Dbp\Relay\ExampleBundle\DataPersister\:
     resource: '../../DataPersister'
     autowire: true
     autoconfigure: true
 
-  Dbp\Relay\TemplateBundle\DataProvider\:
+  Dbp\Relay\ExampleBundle\DataProvider\:
     resource: '../../DataProvider'
     autowire: true
     autoconfigure: true
 
-  Dbp\Relay\TemplateBundle\Service\ExternalApi:
+  Dbp\Relay\ExampleBundle\Service\ExternalApi:
     autowire: true
     autoconfigure: true
 
-  Dbp\Relay\TemplateBundle\Service\MyCustomService:
+  Dbp\Relay\ExampleBundle\Service\MyCustomService:
     autowire: true
     autoconfigure: true
 
-  Dbp\Relay\TemplateBundle\Service\PlaceProviderInterface:
-    '@Dbp\Relay\TemplateBundle\Service\ExternalApi'
+  Dbp\Relay\ExampleBundle\Service\PlaceProviderInterface:
+    '@Dbp\Relay\ExampleBundle\Service\ExternalApi'
diff --git a/src/Service/ExternalApi.php b/src/Service/ExternalApi.php
index c7e0f0f..791213a 100644
--- a/src/Service/ExternalApi.php
+++ b/src/Service/ExternalApi.php
@@ -2,9 +2,9 @@
 
 declare(strict_types=1);
 
-namespace Dbp\Relay\TemplateBundle\Service;
+namespace Dbp\Relay\ExampleBundle\Service;
 
-use Dbp\Relay\TemplateBundle\Entity\Place;
+use Dbp\Relay\ExampleBundle\Entity\Place;
 
 class ExternalApi implements PlaceProviderInterface
 {
diff --git a/src/Service/MyCustomService.php b/src/Service/MyCustomService.php
index b1817b0..b18fd5c 100644
--- a/src/Service/MyCustomService.php
+++ b/src/Service/MyCustomService.php
@@ -2,7 +2,7 @@
 
 declare(strict_types=1);
 
-namespace Dbp\Relay\TemplateBundle\Service;
+namespace Dbp\Relay\ExampleBundle\Service;
 
 class MyCustomService
 {
diff --git a/src/Service/PlaceProviderInterface.php b/src/Service/PlaceProviderInterface.php
index dc03399..e7a25c9 100644
--- a/src/Service/PlaceProviderInterface.php
+++ b/src/Service/PlaceProviderInterface.php
@@ -2,9 +2,9 @@
 
 declare(strict_types=1);
 
-namespace Dbp\Relay\TemplateBundle\Service;
+namespace Dbp\Relay\ExampleBundle\Service;
 
-use Dbp\Relay\TemplateBundle\Entity\Place;
+use Dbp\Relay\ExampleBundle\Entity\Place;
 
 interface PlaceProviderInterface
 {
diff --git a/tests/ApiTest.php b/tests/ApiTest.php
index 1cee1bf..957a1ac 100644
--- a/tests/ApiTest.php
+++ b/tests/ApiTest.php
@@ -2,7 +2,7 @@
 
 declare(strict_types=1);
 
-namespace Dbp\Relay\TemplateBundle\Tests;
+namespace Dbp\Relay\ExampleBundle\Tests;
 
 use ApiPlatform\Core\Bridge\Symfony\Bundle\Test\ApiTestCase;
 use Symfony\Component\HttpFoundation\Response;
@@ -12,16 +12,16 @@ class ApiTest extends ApiTestCase
     public function testBasics()
     {
         $client = self::createClient();
-        $response = $client->request('GET', '/template/places');
+        $response = $client->request('GET', '/example/places');
         $this->assertSame(Response::HTTP_OK, $response->getStatusCode());
 
-        $response = $client->request('GET', '/template/places/graz');
+        $response = $client->request('GET', '/example/places/graz');
         $this->assertSame(Response::HTTP_OK, $response->getStatusCode());
 
-        $response = $client->request('DELETE', '/template/places/graz');
+        $response = $client->request('DELETE', '/example/places/graz');
         $this->assertSame(Response::HTTP_NO_CONTENT, $response->getStatusCode());
 
-        $response = $client->request('PUT', '/template/places/graz', [
+        $response = $client->request('PUT', '/example/places/graz', [
             'headers' => [
                 'Content-Type' => 'application/json',
             ],
@@ -34,7 +34,7 @@ class ApiTest extends ApiTestCase
     public function testNoAuth()
     {
         $client = self::createClient();
-        $response = $client->request('GET', '/template/places/graz/loggedin-only');
+        $response = $client->request('GET', '/example/places/graz/loggedin-only');
         $this->assertSame(Response::HTTP_UNAUTHORIZED, $response->getStatusCode());
     }
 }
diff --git a/tests/Kernel.php b/tests/Kernel.php
index d3ee50e..7c51a36 100644
--- a/tests/Kernel.php
+++ b/tests/Kernel.php
@@ -2,11 +2,11 @@
 
 declare(strict_types=1);
 
-namespace Dbp\Relay\TemplateBundle\Tests;
+namespace Dbp\Relay\ExampleBundle\Tests;
 
 use ApiPlatform\Core\Bridge\Symfony\Bundle\ApiPlatformBundle;
 use Dbp\Relay\CoreBundle\DbpRelayCoreBundle;
-use Dbp\Relay\TemplateBundle\DbpRelayTemplateBundle;
+use Dbp\Relay\ExampleBundle\DbpRelayExampleBundle;
 use Nelmio\CorsBundle\NelmioCorsBundle;
 use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
 use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
@@ -30,7 +30,7 @@ class Kernel extends BaseKernel
         yield new NelmioCorsBundle();
         yield new MonologBundle();
         yield new ApiPlatformBundle();
-        yield new DbpRelayTemplateBundle();
+        yield new DbpRelayExampleBundle();
         yield new DbpRelayCoreBundle();
     }
 
diff --git a/tests/Service/ExternalApiTest.php b/tests/Service/ExternalApiTest.php
index 68211e5..ad22285 100644
--- a/tests/Service/ExternalApiTest.php
+++ b/tests/Service/ExternalApiTest.php
@@ -2,10 +2,10 @@
 
 declare(strict_types=1);
 
-namespace Dbp\Relay\TemplateBundle\Tests\Service;
+namespace Dbp\Relay\ExampleBundle\Tests\Service;
 
-use Dbp\Relay\TemplateBundle\Service\ExternalApi;
-use Dbp\Relay\TemplateBundle\Service\MyCustomService;
+use Dbp\Relay\ExampleBundle\Service\ExternalApi;
+use Dbp\Relay\ExampleBundle\Service\MyCustomService;
 use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
 
 class ExternalApiTest extends WebTestCase
-- 
GitLab