Skip to content
Snippets Groups Projects
Commit efdc5ece authored by Reiter, Christoph's avatar Reiter, Christoph :snake:
Browse files

Adjust to new naming schema everywhere

parent bc8c2ba5
No related branches found
No related tags found
No related merge requests found
Pipeline #105732 passed
Showing
with 97 additions and 73 deletions
# DBP API Starter Bundle # Relay Template Bundle
This Symfony bundle can be used as a template for creating new bundles for the This Symfony bundle can be used as a template for creating new bundles for the
DBP API project. DBP Relay project.
When including this bundle into your DBP API server it will gain the following When including this bundle into your API server it will gain the following
features: features:
* A custom `./bin/console` command * A custom `./bin/console` command
...@@ -13,9 +13,9 @@ features: ...@@ -13,9 +13,9 @@ features:
## Using the Bundle as a Template ## Using the Bundle as a Template
* Copy the repo contents * Copy the repo contents
* Adjust the project name in `composer.json` * Adjust the package name in `composer.json`
* Invent a new PHP namespace and adjust it in all PHP files * Invent a new PHP namespace and adjust it in all PHP files
* Rename `src/DbpStarterBundle` and `DependencyInjection/DbpStarterExtension` to match the new project name * Rename `src/DbpRelayTemplateBundle` and `DependencyInjection/DbpRelayTemplateExtension` to match the new project name
## Integration into the API Server ## Integration into the API Server
...@@ -25,7 +25,7 @@ features: ...@@ -25,7 +25,7 @@ features:
"repositories": [ "repositories": [
{ {
"type": "vcs", "type": "vcs",
"url": "git@gitlab.tugraz.at:dbp/dbp-api/api-starter-bundle.git" "url": "git@gitlab.tugraz.at:dbp/dbp-api/dbp-relay-template-bundle.git"
} }
], ],
``` ```
...@@ -33,14 +33,14 @@ features: ...@@ -33,14 +33,14 @@ features:
* Add the bundle package as a dependency: * Add the bundle package as a dependency:
``` ```
composer require dbp/api-starter-bundle=dev-main composer require dbp/relay-template-bundle=dev-main
``` ```
* Add the bundle to your `config/bundles.php`: * Add the bundle to your `config/bundles.php`:
```php ```php
... ...
DBP\API\StarterBundle\DbpStarterBundle::class => ['all' => true], Dbp\Relay\TemplateBundle\DbpRelayTemplateBundle::class => ['all' => true],
DBP\API\CoreBundle\DbpCoreBundle::class => ['all' => true], DBP\API\CoreBundle\DbpCoreBundle::class => ['all' => true],
]; ];
``` ```
...@@ -52,16 +52,16 @@ DBP\API\CoreBundle\DbpCoreBundle::class => ['all' => true], ...@@ -52,16 +52,16 @@ DBP\API\CoreBundle\DbpCoreBundle::class => ['all' => true],
The bundle has a `secret_token` configuration value that you can specify in your The bundle has a `secret_token` configuration value that you can specify in your
app, either by hardcoding it, or by referencing an environment variable. app, either by hardcoding it, or by referencing an environment variable.
For this create `config/packages/dbp_starter.yaml` in the app with the following For this create `config/packages/dbp_relay_template.yaml` in the app with the following
content: content:
```yaml ```yaml
dbp_starter: dbp_relay_template:
secret_token: 42 secret_token: 42
# secret_token: '%env(SECRET_TOKEN)%' # secret_token: '%env(SECRET_TOKEN)%'
``` ```
The value gets read in `DbpStarterExtension` and passed when creating the The value gets read in `DbpRelayTemplateExtension` and passed when creating the
`MyCustomService` service. `MyCustomService` service.
For more info on bundle configuration see For more info on bundle configuration see
...@@ -79,6 +79,6 @@ https://symfony.com/doc/current/bundles/configuration.html ...@@ -79,6 +79,6 @@ https://symfony.com/doc/current/bundles/configuration.html
Don't forget you need to pull down your dependencies in your main application if you are installing packages in a bundle. Don't forget you need to pull down your dependencies in your main application if you are installing packages in a bundle.
```bash ```bash
# updates and installs dependencies from dbp/api-starter-bundle # updates and installs dependencies from dbp/relay-template-bundle
composer update dbp/api-starter-bundle composer update dbp/relay-template-bundle
``` ```
{ {
"name": "dbp/api-starter-bundle", "name": "dbp/relay-template-bundle",
"type": "symfony-bundle", "type": "symfony-bundle",
"license": "AGPL-3.0-or-later", "license": "AGPL-3.0-or-later",
"require": { "require": {
...@@ -26,12 +26,12 @@ ...@@ -26,12 +26,12 @@
], ],
"autoload": { "autoload": {
"psr-4": { "psr-4": {
"DBP\\API\\StarterBundle\\": "src/" "Dbp\\Relay\\TemplateBundle\\": "src/"
} }
}, },
"autoload-dev": { "autoload-dev": {
"psr-4": { "psr-4": {
"DBP\\API\\StarterBundle\\Tests\\": "tests/" "Dbp\\Relay\\TemplateBundle\\Tests\\": "tests/"
} }
}, },
"config": { "config": {
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
<server name="SYMFONY_PHPUNIT_REMOVE" value=""/> <server name="SYMFONY_PHPUNIT_REMOVE" value=""/>
<server name="SYMFONY_PHPUNIT_VERSION" value="9"/> <server name="SYMFONY_PHPUNIT_VERSION" value="9"/>
<server name="SYMFONY_DEPRECATIONS_HELPER" value="weak"/> <server name="SYMFONY_DEPRECATIONS_HELPER" value="weak"/>
<server name="KERNEL_CLASS" value="DBP\API\StarterBundle\Tests\Kernel"/> <server name="KERNEL_CLASS" value="Dbp\Relay\TemplateBundle\Tests\Kernel"/>
</php> </php>
<testsuites> <testsuites>
<testsuite name="Project Test Suite"> <testsuite name="Project Test Suite">
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace DBP\API\StarterBundle\Command; namespace Dbp\Relay\TemplateBundle\Command;
use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputArgument;
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
declare(strict_types=1); declare(strict_types=1);
namespace DBP\API\StarterBundle\Controller; namespace Dbp\Relay\TemplateBundle\Controller;
use DBP\API\StarterBundle\Entity\Place; use Dbp\Relay\TemplateBundle\Entity\Place;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
......
...@@ -2,11 +2,11 @@ ...@@ -2,11 +2,11 @@
declare(strict_types=1); declare(strict_types=1);
namespace DBP\API\StarterBundle\DataPersister; namespace Dbp\Relay\TemplateBundle\DataPersister;
use ApiPlatform\Core\DataPersister\DataPersisterInterface; use ApiPlatform\Core\DataPersister\DataPersisterInterface;
use DBP\API\StarterBundle\Entity\Place; use Dbp\Relay\TemplateBundle\Entity\Place;
use DBP\API\StarterBundle\Service\PlaceProviderInterface; use Dbp\Relay\TemplateBundle\Service\PlaceProviderInterface;
class PlaceDataPersister implements DataPersisterInterface class PlaceDataPersister implements DataPersisterInterface
{ {
......
...@@ -2,13 +2,13 @@ ...@@ -2,13 +2,13 @@
declare(strict_types=1); declare(strict_types=1);
namespace DBP\API\StarterBundle\DataProvider; namespace Dbp\Relay\TemplateBundle\DataProvider;
use ApiPlatform\Core\DataProvider\CollectionDataProviderInterface; use ApiPlatform\Core\DataProvider\CollectionDataProviderInterface;
use ApiPlatform\Core\DataProvider\RestrictedDataProviderInterface; use ApiPlatform\Core\DataProvider\RestrictedDataProviderInterface;
use DBP\API\CoreBundle\Helpers\ArrayFullPaginator; use DBP\API\CoreBundle\Helpers\ArrayFullPaginator;
use DBP\API\StarterBundle\Entity\Place; use Dbp\Relay\TemplateBundle\Entity\Place;
use DBP\API\StarterBundle\Service\PlaceProviderInterface; use Dbp\Relay\TemplateBundle\Service\PlaceProviderInterface;
final class PlaceCollectionDataProvider implements CollectionDataProviderInterface, RestrictedDataProviderInterface final class PlaceCollectionDataProvider implements CollectionDataProviderInterface, RestrictedDataProviderInterface
{ {
......
...@@ -2,12 +2,12 @@ ...@@ -2,12 +2,12 @@
declare(strict_types=1); declare(strict_types=1);
namespace DBP\API\StarterBundle\DataProvider; namespace Dbp\Relay\TemplateBundle\DataProvider;
use ApiPlatform\Core\DataProvider\ItemDataProviderInterface; use ApiPlatform\Core\DataProvider\ItemDataProviderInterface;
use ApiPlatform\Core\DataProvider\RestrictedDataProviderInterface; use ApiPlatform\Core\DataProvider\RestrictedDataProviderInterface;
use DBP\API\StarterBundle\Entity\Place; use Dbp\Relay\TemplateBundle\Entity\Place;
use DBP\API\StarterBundle\Service\PlaceProviderInterface; use Dbp\Relay\TemplateBundle\Service\PlaceProviderInterface;
final class PlaceItemDataProvider implements ItemDataProviderInterface, RestrictedDataProviderInterface final class PlaceItemDataProvider implements ItemDataProviderInterface, RestrictedDataProviderInterface
{ {
......
...@@ -2,12 +2,12 @@ ...@@ -2,12 +2,12 @@
declare(strict_types=1); declare(strict_types=1);
namespace DBP\API\StarterBundle; namespace Dbp\Relay\TemplateBundle;
use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Bundle\Bundle; use Symfony\Component\HttpKernel\Bundle\Bundle;
class DbpStarterBundle extends Bundle class DbpRelayTemplateBundle extends Bundle
{ {
public function build(ContainerBuilder $container) public function build(ContainerBuilder $container)
{ {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace DBP\API\StarterBundle\DependencyInjection; namespace Dbp\Relay\TemplateBundle\DependencyInjection;
use Symfony\Component\Config\Definition\Builder\TreeBuilder; use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface; use Symfony\Component\Config\Definition\ConfigurationInterface;
...@@ -11,7 +11,7 @@ class Configuration implements ConfigurationInterface ...@@ -11,7 +11,7 @@ class Configuration implements ConfigurationInterface
{ {
public function getConfigTreeBuilder() public function getConfigTreeBuilder()
{ {
$treeBuilder = new TreeBuilder('dbp_starter'); $treeBuilder = new TreeBuilder('dbp_relay_template');
$treeBuilder->getRootNode() $treeBuilder->getRootNode()
->children() ->children()
......
...@@ -2,14 +2,14 @@ ...@@ -2,14 +2,14 @@
declare(strict_types=1); declare(strict_types=1);
namespace DBP\API\StarterBundle\DependencyInjection; namespace Dbp\Relay\TemplateBundle\DependencyInjection;
use Symfony\Component\Config\FileLocator; use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
use Symfony\Component\HttpKernel\DependencyInjection\ConfigurableExtension; use Symfony\Component\HttpKernel\DependencyInjection\ConfigurableExtension;
class DbpStarterExtension extends ConfigurableExtension class DbpRelayTemplateExtension extends ConfigurableExtension
{ {
public function loadInternal(array $mergedConfig, ContainerBuilder $container) public function loadInternal(array $mergedConfig, ContainerBuilder $container)
{ {
...@@ -23,7 +23,7 @@ class DbpStarterExtension extends ConfigurableExtension ...@@ -23,7 +23,7 @@ class DbpStarterExtension extends ConfigurableExtension
$loader->load('services.yaml'); $loader->load('services.yaml');
// Inject the config value into the MyCustomService service // Inject the config value into the MyCustomService service
$definition = $container->getDefinition('DBP\API\StarterBundle\Service\MyCustomService'); $definition = $container->getDefinition('Dbp\Relay\TemplateBundle\Service\MyCustomService');
$definition->addArgument($mergedConfig['secret_token']); $definition->addArgument($mergedConfig['secret_token']);
} }
......
...@@ -2,37 +2,61 @@ ...@@ -2,37 +2,61 @@
declare(strict_types=1); declare(strict_types=1);
namespace DBP\API\StarterBundle\Entity; namespace Dbp\Relay\TemplateBundle\Entity;
use ApiPlatform\Core\Annotation\ApiProperty; use ApiPlatform\Core\Annotation\ApiProperty;
use ApiPlatform\Core\Annotation\ApiResource; use ApiPlatform\Core\Annotation\ApiResource;
use DBP\API\StarterBundle\Controller\LoggedInOnly; use Dbp\Relay\TemplateBundle\Controller\LoggedInOnly;
use Symfony\Component\Serializer\Annotation\Groups; use Symfony\Component\Serializer\Annotation\Groups;
/** /**
* @ApiResource( * @ApiResource(
* collectionOperations={ * collectionOperations={
* "get" * "get" = {
* "path" = "/template/places",
* "openapi_context" = {
* "tags" = {"Template"},
* },
* }
* }, * },
* itemOperations={ * itemOperations={
* "get", * "get" = {
* "put", * "path" = "/template/places/{identifier}",
* "delete", * "openapi_context" = {
* "tags" = {"Template"},
* },
* },
* "put" = {
* "path" = "/template/places/{identifier}",
* "openapi_context" = {
* "tags" = {"Template"},
* },
* },
* "delete" = {
* "path" = "/template/places/{identifier}",
* "openapi_context" = {
* "tags" = {"Template"},
* },
* },
* "loggedin_only" = { * "loggedin_only" = {
* "security" = "is_granted('IS_AUTHENTICATED_FULLY')", * "security" = "is_granted('IS_AUTHENTICATED_FULLY')",
* "method" = "GET", * "method" = "GET",
* "path" = "/places/{identifier}/loggedin-only", * "path" = "/template/places/{identifier}/loggedin-only",
* "controller" = LoggedInOnly::class, * "controller" = LoggedInOnly::class,
* "openapi_context" = {"summary" = "Only works when logged in."}, * "openapi_context" = {
* "summary" = "Only works when logged in.",
* "tags" = {"Template"},
* },
* } * }
* }, * },
* iri="https://schema.org/Place", * iri="https://schema.org/Place",
* shortName="TemplatePlace",
* normalizationContext={ * normalizationContext={
* "groups" = {"Place:output"}, * "groups" = {"TemplatePlace:output"},
* "jsonld_embed_context" = true * "jsonld_embed_context" = true
* }, * },
* denormalizationContext={ * denormalizationContext={
* "groups" = {"Place:input"}, * "groups" = {"TemplatePlace:input"},
* "jsonld_embed_context" = true * "jsonld_embed_context" = true
* } * }
* ) * )
...@@ -46,7 +70,7 @@ class Place ...@@ -46,7 +70,7 @@ class Place
/** /**
* @ApiProperty(iri="https://schema.org/name") * @ApiProperty(iri="https://schema.org/name")
* @Groups({"Place:output", "Place:input"}) * @Groups({"TemplatePlace:output", "TemplatePlace:input"})
* *
* @var string * @var string
*/ */
......
services: services:
DBP\API\StarterBundle\Command\TestCommand: Dbp\Relay\TemplateBundle\Command\TestCommand:
autowire: true autowire: true
autoconfigure: true autoconfigure: true
DBP\API\StarterBundle\Controller\: Dbp\Relay\TemplateBundle\Controller\:
resource: '../../Controller' resource: '../../Controller'
tags: ['controller.service_arguments'] tags: ['controller.service_arguments']
autowire: true autowire: true
DBP\API\StarterBundle\DataProvider\PlaceCollectionDataProvider: Dbp\Relay\TemplateBundle\DataProvider\PlaceCollectionDataProvider:
tags: [{ name: 'api_platform.collection_data_provider'}] tags: [{ name: 'api_platform.collection_data_provider'}]
autowire: true autowire: true
DBP\API\StarterBundle\DataProvider\PlaceItemDataProvider: Dbp\Relay\TemplateBundle\DataProvider\PlaceItemDataProvider:
tags: ['api_platform.item_data_provider'] tags: ['api_platform.item_data_provider']
autowire: true autowire: true
DBP\API\StarterBundle\Service\ExternalApi: Dbp\Relay\TemplateBundle\Service\ExternalApi:
autowire: true autowire: true
autoconfigure: true autoconfigure: true
DBP\API\StarterBundle\Service\MyCustomService: Dbp\Relay\TemplateBundle\Service\MyCustomService:
autowire: true autowire: true
autoconfigure: true autoconfigure: true
DBP\API\StarterBundle\Service\PlaceProviderInterface: Dbp\Relay\TemplateBundle\Service\PlaceProviderInterface:
'@DBP\API\StarterBundle\Service\ExternalApi' '@Dbp\Relay\TemplateBundle\Service\ExternalApi'
\ No newline at end of file \ No newline at end of file
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
declare(strict_types=1); declare(strict_types=1);
namespace DBP\API\StarterBundle\Service; namespace Dbp\Relay\TemplateBundle\Service;
use DBP\API\StarterBundle\Entity\Place; use Dbp\Relay\TemplateBundle\Entity\Place;
class ExternalApi implements PlaceProviderInterface class ExternalApi implements PlaceProviderInterface
{ {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace DBP\API\StarterBundle\Service; namespace Dbp\Relay\TemplateBundle\Service;
class MyCustomService class MyCustomService
{ {
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
declare(strict_types=1); declare(strict_types=1);
namespace DBP\API\StarterBundle\Service; namespace Dbp\Relay\TemplateBundle\Service;
use DBP\API\StarterBundle\Entity\Place; use Dbp\Relay\TemplateBundle\Entity\Place;
interface PlaceProviderInterface interface PlaceProviderInterface
{ {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace DBP\API\StarterBundle\Tests; namespace Dbp\Relay\TemplateBundle\Tests;
use ApiPlatform\Core\Bridge\Symfony\Bundle\Test\ApiTestCase; use ApiPlatform\Core\Bridge\Symfony\Bundle\Test\ApiTestCase;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
...@@ -12,16 +12,16 @@ class ApiTest extends ApiTestCase ...@@ -12,16 +12,16 @@ class ApiTest extends ApiTestCase
public function testBasics() public function testBasics()
{ {
$client = self::createClient(); $client = self::createClient();
$response = $client->request('GET', '/places'); $response = $client->request('GET', '/template/places');
$this->assertSame(Response::HTTP_OK, $response->getStatusCode()); $this->assertSame(Response::HTTP_OK, $response->getStatusCode());
$response = $client->request('GET', '/places/graz'); $response = $client->request('GET', '/template/places/graz');
$this->assertSame(Response::HTTP_OK, $response->getStatusCode()); $this->assertSame(Response::HTTP_OK, $response->getStatusCode());
$response = $client->request('DELETE', '/places/graz'); $response = $client->request('DELETE', '/template/places/graz');
$this->assertSame(Response::HTTP_NO_CONTENT, $response->getStatusCode()); $this->assertSame(Response::HTTP_NO_CONTENT, $response->getStatusCode());
$response = $client->request('PUT', '/places/graz', [ $response = $client->request('PUT', '/template/places/graz', [
'headers' => [ 'headers' => [
'Content-Type' => 'application/json', 'Content-Type' => 'application/json',
], ],
...@@ -34,7 +34,7 @@ class ApiTest extends ApiTestCase ...@@ -34,7 +34,7 @@ class ApiTest extends ApiTestCase
public function testNoAuth() public function testNoAuth()
{ {
$client = self::createClient(); $client = self::createClient();
$response = $client->request('GET', '/places/graz/loggedin-only'); $response = $client->request('GET', '/template/places/graz/loggedin-only');
$this->assertSame(Response::HTTP_UNAUTHORIZED, $response->getStatusCode()); $this->assertSame(Response::HTTP_UNAUTHORIZED, $response->getStatusCode());
} }
} }
...@@ -2,11 +2,11 @@ ...@@ -2,11 +2,11 @@
declare(strict_types=1); declare(strict_types=1);
namespace DBP\API\StarterBundle\Tests; namespace Dbp\Relay\TemplateBundle\Tests;
use ApiPlatform\Core\Bridge\Symfony\Bundle\ApiPlatformBundle; use ApiPlatform\Core\Bridge\Symfony\Bundle\ApiPlatformBundle;
use DBP\API\CoreBundle\DbpCoreBundle; use DBP\API\CoreBundle\DbpCoreBundle;
use DBP\API\StarterBundle\DbpStarterBundle; use Dbp\Relay\TemplateBundle\DbpRelayTemplateBundle;
use Nelmio\CorsBundle\NelmioCorsBundle; use Nelmio\CorsBundle\NelmioCorsBundle;
use Symfony\Bundle\FrameworkBundle\FrameworkBundle; use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait; use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
...@@ -28,7 +28,7 @@ class Kernel extends BaseKernel ...@@ -28,7 +28,7 @@ class Kernel extends BaseKernel
yield new TwigBundle(); yield new TwigBundle();
yield new NelmioCorsBundle(); yield new NelmioCorsBundle();
yield new ApiPlatformBundle(); yield new ApiPlatformBundle();
yield new DbpStarterBundle(); yield new DbpRelayTemplateBundle();
yield new DbpCoreBundle(); yield new DbpCoreBundle();
} }
...@@ -44,7 +44,7 @@ class Kernel extends BaseKernel ...@@ -44,7 +44,7 @@ class Kernel extends BaseKernel
'secret' => '', 'secret' => '',
]); ]);
$c->loadFromExtension('dbp_starter', [ $c->loadFromExtension('dbp_relay_template', [
'secret_token' => 'secret-test', 'secret_token' => 'secret-test',
]); ]);
} }
......
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
declare(strict_types=1); declare(strict_types=1);
namespace DBP\API\StarterBundle\Tests\Service; namespace Dbp\Relay\TemplateBundle\Tests\Service;
use DBP\API\StarterBundle\Service\ExternalApi; use Dbp\Relay\TemplateBundle\Service\ExternalApi;
use DBP\API\StarterBundle\Service\MyCustomService; use Dbp\Relay\TemplateBundle\Service\MyCustomService;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
class ExternalApiTest extends WebTestCase class ExternalApiTest extends WebTestCase
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment