Skip to content
Snippets Groups Projects
Commit a335853f authored by Steinwender, Tamara's avatar Steinwender, Tamara
Browse files

Inital bundle commit

parent 2d94fdcb
No related branches found
No related tags found
No related merge requests found
Pipeline #197060 failed
Showing with 11495 additions and 57 deletions
/vendor
/var
/.php_cs
/.idea
/*.cache
/_coverage
\ No newline at end of file
image: registry.gitlab.tugraz.at/dbp/relay/dbp-relay-core-bundle/main:v1
before_script:
- 'git config --global url."https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.tugraz.at/".insteadOf "git@gitlab.tugraz.at:"'
variables:
COMPOSER_CACHE_DIR: "$CI_PROJECT_DIR/_composer_cache"
cache:
key: ${CI_PROJECT_PATH}
paths:
- _composer_cache
stages:
- test
.test_defaults: &test_defaults
script:
- sudo update-alternatives --set php "/usr/bin/${PHP}"
- composer validate
- composer install
- composer test
test-php7.3:
stage: test
variables:
PHP: "php7.3"
<<: *test_defaults
test-php7.4:
stage: test
variables:
PHP: "php7.4"
<<: *test_defaults
test-php8.0:
stage: test
variables:
PHP: "php8.0"
<<: *test_defaults
test-php8.1:
stage: test
variables:
PHP: "php8.1"
<<: *test_defaults
test-rename:
stage: test
rules:
- if: $CI_PROJECT_PATH == "dbp/relay/dbp-relay-blob-connector-local-bundle"
script:
- sudo update-alternatives --set php "/usr/bin/php7.4"
- composer install
# remove the cache, otherwise the rename will break it
- rm -rf _composer_cache
- ./.bundle-rename --unique-name=greenlight --friendly-name="Electronic Covid Access Permits" --example-entity=Permit
- composer update --lock
- composer validate
- composer install
- composer test
- composer lint
linting:
stage: test
script:
- sudo update-alternatives --set php /usr/bin/php7.4
- composer install
- result=0
- composer run cs || result=1
- composer run phpstan || result=1
- composer run psalm || result=1
- exit $result
\ No newline at end of file
<?php
$finder = PhpCsFixer\Finder::create()
->in(__DIR__)
->exclude('var')
;
$config = new PhpCsFixer\Config();
$config->setRules([
'@Symfony' => true,
'@PHP70Migration' => true,
'@PHP71Migration' => true,
'@PHP73Migration' => true,
'@DoctrineAnnotation' => true,
'doctrine_annotation_array_assignment' => ['operator' => '='],
'yoda_style' => false,
'strict_comparison' => true,
'strict_param' => true,
'declare_strict_types' => true,
'method_argument_space' => ['on_multiline' => 'ignore'],
])
->setRiskyAllowed(true)
->setFinder($finder);
return $config;
\ No newline at end of file
{
"extends": [
"config:base",
"group:allNonMajor",
"schedule:weekends",
":automergePatch"
],
"ignorePresets": [":prHourlyLimit2"],
"rangeStrategy": "update-lockfile",
"lockFileMaintenance": {
"enabled": true
},
"packageRules": [
{
"matchPackagePrefixes": [
"symfony/"
],
"allowedVersions": "<6"
}
]
}
\ No newline at end of file
LICENSE 0 → 100644
This diff is collapsed.
# dbp-relay-blob-connector-local-bundle
Relay-API Bundle README Template
================================
<!--
This should act as a template README.md for a new Relay-API Bundle.
Just remove the parts that are not relevant to your bundle and
replace placeholders like "{{Name}}" with your bundle name and so on.
List of placeholders:
- {{name}}: Name of the bundle in lowercase, like "formalize"
- {{Name}}: Name of the bundle in camel case, like "Formalize"
- {{NAME}}: Name of the bundle in uppercase, like "FORMALIZE"
- {{bundle-path}}: GitLab bundle repository path, like "dbp/formalize/dbp-relay-formalize-bundle"
- {{package-name}}: Name of the bundle for packagist, like "dbp/relay-formalize-bundle"
- {{app-path}}: GitLab repository path of the frontend application, like "dbp/formalize/formalize"
-->
## Getting started
# DbpRelay{{Name}}Bundle
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
[GitLab](https://gitlab.tugraz.at/{{bundle-path}}) |
[Packagist](https://packagist.org/packages/{{package-name}}) |
[Frontend Application](https://gitlab.tugraz.at/{{app-path}}) |
[{{Name}} Website](https://dbp-demo.tugraz.at/site/software/{{name}}.html)
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
The {{name}} bundle provides an API for interacting with ...
## Add your files
There is a corresponding frontend application that uses this API at [{{Name}} Frontend Application](https://gitlab.tugraz.at/{{app-path}}).
- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
## Bundle installation
You can install the bundle directly from [packagist.org](https://packagist.org/packages/{{package-name}}).
```bash
composer require {{package-name}}
```
## Integration into the Relay API Server
* Add the bundle to your `config/bundles.php` in front of `DbpRelayCoreBundle`:
```php
...
Dbp\Relay\{{Name}}Bundle\DbpRelay{{Name}}Bundle::class => ['all' => true],
Dbp\Relay\CoreBundle\DbpRelayCoreBundle::class => ['all' => true],
];
```
cd existing_repo
git remote add origin https://gitlab.tugraz.at/dbp/relay/dbp-relay-blob-connector-local-bundle.git
git branch -M main
git push -uf origin main
If you were using the [DBP API Server Template](https://gitlab.tugraz.at/dbp/relay/dbp-relay-server-template)
as template for your Symfony application, then this should have already been generated for you.
* Run `composer install` to clear caches
## Configuration
The bundle has a `database_url` configuration value that you can specify in your
app, either by hard-coding it, or by referencing an environment variable.
For this create `config/packages/dbp_relay_{{name}}.yaml` in the app with the following
content:
```yaml
dbp_relay_{{name}}:
database_url: 'mysql://db:secret@mariadb:3306/db?serverVersion=mariadb-10.3.30'
# database_url: %env({{NAME}}_DATABASE_URL)%
```
## Integrate with your tools
If you were using the [DBP API Server Template](https://gitlab.tugraz.at/dbp/relay/dbp-relay-server-template)
as template for your Symfony application, then the configuration file should have already been generated for you.
For more info on bundle configuration see <https://symfony.com/doc/current/bundles/configuration.html>.
## Development & Testing
* Install dependencies: `composer install`
* Run tests: `composer test`
* Run linters: `composer run lint`
* Run cs-fixer: `composer run cs-fix`
## Bundle dependencies
- [ ] [Set up project integrations](https://gitlab.tugraz.at/dbp/relay/dbp-relay-blob-connector-local-bundle/-/settings/integrations)
Don't forget you need to pull down your dependencies in your main application if you are installing packages in a bundle.
## Collaborate with your team
```bash
# updates and installs dependencies of {{package-name}}
composer update {{package-name}}
```
## Scripts
- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
- [ ] [Automatically merge when pipeline succeeds](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
### Database migration
## Test and Deploy
Run this script to migrate the database. Run this script after installation of the bundle and
after every update to adapt the database to the new source code.
Use the built-in continuous integration in GitLab.
```bash
php bin/console doctrine:migrations:migrate --em=dbp_relay_{{name}}_bundle
```
- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing(SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
## Error codes
***
### `/{{name}}/submissions`
# Editing this README
#### POST
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thank you to [makeareadme.com](https://www.makeareadme.com/) for this template.
| relay:errorId | Status code | Description | relay:errorDetails | Example |
|-------------------------------------|-------------|-------------------------------------------------| ------------------ |----------------------------------|
| `{{name}}:submission-not-created` | 500 | The submission could not be created. | `message` | `['message' => 'Error message']` |
| `{{name}}:submission-invalid-json` | 422 | The dataFeedElement doesn't contain valid json. | `message` | |
## Suggestions for a good README
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
### `/{{name}}/submissions/{identifier}`
## Name
Choose a self-explaining name for your project.
#### GET
## Description
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
| relay:errorId | Status code | Description | relay:errorDetails | Example |
| -------------------------------- | ----------- | ------------------------- | ------------------ | ------- |
| `{{name}}:submission-not-found` | 404 | Submission was not found. | | |
## Badges
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
## Roles
## Visuals
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
This bundle needs the role `ROLE_SCOPE_{{NAME}}` assigned to the user to get permissions to fetch data.
To create a new submission entry the Symfony role `ROLE_SCOPE_{{NAME}}-POST` is required.
## Installation
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
## Events
## Usage
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
To extend the behavior of the bundle the following event is registered:
## Support
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
### CreateSubmissionPostEvent
## Roadmap
If you have ideas for releases in the future, it is a good idea to list them in the README.
This event allows you to react on submission creations.
You can use this for example to email the submitter of the submission.
## Contributing
State if you are open to contributions and what your requirements are for accepting them.
An event subscriber receives a `Dbp\Relay\{{Name}}Bundle\Event\CreateSubmissionPostEvent` instance
in a service for example in `src/EventSubscriber/CreateSubmissionSubscriber.php`:
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
```php
<?php
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
namespace App\EventSubscriber;
## Authors and acknowledgment
Show your appreciation to those who have contributed to the project.
use Dbp\Relay\{{Name}}Bundle\Event\CreateSubmissionPostEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
## License
For open source projects, say how it is licensed.
class CreateSubmissionSubscriber implements EventSubscriberInterface
{
public static function getSubscribedEvents(): array
{
return [
CreateSubmissionPostEvent::NAME => 'onPost',
];
}
## Project status
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
public function onPost(CreateSubmissionPostEvent $event)
{
$submission = $event->getSubmission();
$dataFeedElement = $submission->getDataFeedElementDecoded();
// TODO: extract email address and send email
$email = $dataFeedElement['email'];
}
}
```
{
"name": "dbp/relay-blob-connector-local-bundle",
"description": "A template bundle for the Relay API gateway",
"type": "symfony-bundle",
"license": "AGPL-3.0-or-later",
"require": {
"php": ">=7.3",
"ext-json": "*",
"api-platform/core": "^2.6",
"dbp/relay-core-bundle": "^0.1.34",
"symfony/framework-bundle": "^5.4"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.0",
"phpstan/phpstan": "^1.0.0",
"phpstan/phpstan-phpunit": "^1.0.0",
"phpstan/phpstan-symfony": "^1.2",
"phpunit/phpunit": "^9",
"symfony/browser-kit": "^5.4",
"symfony/http-client": "^5.4",
"symfony/monolog-bundle": "^3.7",
"symfony/phpunit-bridge": "^5.4",
"vimeo/psalm": "^4.2.1"
},
"autoload": {
"psr-4": {
"Dbp\\Relay\\BlobConnectorLocalBundle\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Dbp\\Relay\\BlobConnectorLocalBundle\\Tests\\": "tests/"
}
},
"config": {
"sort-packages": true,
"platform": {
"php": "7.3"
}
},
"scripts": {
"test": [
"@php vendor/bin/phpunit"
],
"phpstan": [
"@php vendor/bin/phpstan analyze --ansi"
],
"psalm": [
"@php vendor/bin/psalm"
],
"lint": [
"@composer run cs",
"@composer run phpstan",
"@composer run psalm"
],
"cs-fix": [
"@php vendor/bin/php-cs-fixer --ansi fix"
],
"cs": [
"@php vendor/bin/php-cs-fixer --ansi fix --dry-run --diff"
],
"coverage": [
"@php -dxdebug.mode=coverage vendor/bin/phpunit --coverage-html _coverage"
]
}
}
This diff is collapsed.
includes:
- vendor/phpstan/phpstan-phpunit/extension.neon
- vendor/phpstan/phpstan-symfony/extension.neon
parameters:
inferPrivatePropertyTypeFromConstructor: true
level: 3
paths:
- src
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!-- https://phpunit.de/manual/current/en/appendixes.configuration.html -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" backupGlobals="false" colors="true" bootstrap="tests/bootstrap.php">
<coverage>
<include>
<directory>src</directory>
<directory>tests</directory>
</include>
</coverage>
<php>
<ini name="error_reporting" value="-1"/>
<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\BlobConnectorLocalBundle\Tests\Kernel"/>
</php>
<testsuites>
<testsuite name="Project Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<listeners>
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener"/>
</listeners>
</phpunit>
<?xml version="1.0"?>
<psalm
errorLevel="5"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
>
<projectFiles>
<directory name="src" />
<ignoreFiles>
<directory name="vendor" />
</ignoreFiles>
</projectFiles>
<issueHandlers>
<UndefinedDocblockClass>
<errorLevel type="suppress">
<referencedClass name="UnitEnum" />
</errorLevel>
</UndefinedDocblockClass>
</issueHandlers>
</psalm>
<?php
declare(strict_types=1);
namespace Dbp\Relay\BlobConnectorLocalBundle;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Bundle\Bundle;
class DbpRelayBlobConnectorLocalBundle extends Bundle
{
public function build(ContainerBuilder $container)
{
}
}
<?php
declare(strict_types=1);
namespace Dbp\Relay\BlobConnectorLocalBundle\DependencyInjection;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
class Configuration implements ConfigurationInterface
{
public function getConfigTreeBuilder(): TreeBuilder
{
$treeBuilder = new TreeBuilder('dbp_relay_blob_connector_local');
return $treeBuilder;
}
}
<?php
declare(strict_types=1);
namespace Dbp\Relay\BlobConnectorLocalBundle\DependencyInjection;
use Dbp\Relay\CoreBundle\Extension\ExtensionTrait;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
use Symfony\Component\HttpKernel\DependencyInjection\ConfigurableExtension;
class DbpRelayBlobConnectorLocalExtension extends ConfigurableExtension
{
use ExtensionTrait;
public function loadInternal(array $mergedConfig, ContainerBuilder $container)
{
$this->addResourceClassDirectory($container, __DIR__.'/../Entity');
$loader = new YamlFileLoader(
$container,
new FileLocator(__DIR__.'/../Resources/config')
);
$loader->load('services.yaml');
}
}
<?php
declare(strict_types=1);
namespace Dbp\Relay\BlobConnectorLocalBundle\Entity;
use ApiPlatform\Core\Annotation\ApiProperty;
use ApiPlatform\Core\Annotation\ApiResource;
use Dbp\Relay\BlobConnectorLocalBundle\Controller\LoggedInOnly;
use Symfony\Component\Serializer\Annotation\Groups;
/**
* @ApiResource(
* collectionOperations={
* "get" = {
* "path" = "/blob-connector-local/entitys",
* "openapi_context" = {
* "tags" = {"Blob Connector local datasystem"},
* },
* }
* },
* itemOperations={
* "get" = {
* "path" = "/blob-connector-local/entitys/{identifier}",
* "openapi_context" = {
* "tags" = {"Blob Connector local datasystem"},
* },
* },
* "put" = {
* "path" = "/blob-connector-local/entitys/{identifier}",
* "openapi_context" = {
* "tags" = {"Blob Connector local datasystem"},
* },
* },
* "delete" = {
* "path" = "/blob-connector-local/entitys/{identifier}",
* "openapi_context" = {
* "tags" = {"Blob Connector local datasystem"},
* },
* },
* "loggedin_only" = {
* "security" = "is_granted('IS_AUTHENTICATED_FULLY')",
* "method" = "GET",
* "path" = "/blob-connector-local/entitys/{identifier}/loggedin-only",
* "controller" = LoggedInOnly::class,
* "openapi_context" = {
* "summary" = "Only works when logged in.",
* "tags" = {"Blob Connector local datasystem"},
* },
* }
* },
* iri="https://schema.org/Entity",
* shortName="BlobConnectorLocalEntity",
* normalizationContext={
* "groups" = {"BlobConnectorLocalEntity:output"},
* "jsonld_embed_context" = true
* },
* denormalizationContext={
* "groups" = {"BlobConnectorLocalEntity:input"},
* "jsonld_embed_context" = true
* }
* )
*/
class Entity
{
/**
* @ApiProperty(identifier=true)
*/
private $identifier;
/**
* @ApiProperty(iri="https://schema.org/name")
* @Groups({"BlobConnectorLocalEntity:output", "BlobConnectorLocalEntity:input"})
*
* @var string
*/
private $name;
public function getName(): string
{
return $this->name;
}
public function setName(string $name): void
{
$this->name = $name;
}
public function getIdentifier(): string
{
return $this->identifier;
}
public function setIdentifier(string $identifier): void
{
$this->identifier = $identifier;
}
}
services:
<?php
declare(strict_types=1);
namespace Dbp\Relay\BlobConnectorLocalBundle\Tests;
use ApiPlatform\Core\Bridge\Symfony\Bundle\ApiPlatformBundle;
use Dbp\Relay\CoreBundle\DbpRelayCoreBundle;
use Dbp\Relay\BlobConnectorLocalBundle\DbpRelayBlobConnectorLocalBundle;
use Nelmio\CorsBundle\NelmioCorsBundle;
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
use Symfony\Bundle\MonologBundle\MonologBundle;
use Symfony\Bundle\SecurityBundle\SecurityBundle;
use Symfony\Bundle\TwigBundle\TwigBundle;
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symfony\Component\HttpKernel\Kernel as BaseKernel;
use Symfony\Component\Routing\RouteCollectionBuilder;
class Kernel extends BaseKernel
{
use MicroKernelTrait;
public function registerBundles(): iterable
{
yield new FrameworkBundle();
yield new SecurityBundle();
yield new TwigBundle();
yield new NelmioCorsBundle();
yield new MonologBundle();
yield new ApiPlatformBundle();
yield new DbpRelayBlobConnectorLocalBundle();
yield new DbpRelayCoreBundle();
}
protected function configureRoutes(RouteCollectionBuilder $routes)
{
$routes->import('@DbpRelayCoreBundle/Resources/config/routing.yaml');
}
protected function configureContainer(ContainerConfigurator $container, LoaderInterface $loader)
{
$container->import('@DbpRelayCoreBundle/Resources/config/services_test.yaml');
$container->extension('framework', [
'test' => true,
'secret' => '',
]);
$container->extension('dbp_relay_blob_connector_local', []);
}
}
<?php
declare(strict_types=1);
namespace Dbp\Relay\BlobConnectorLocalBundle\Tests;
use PHPUnit\Framework\TestCase;
class Test extends TestCase
{
public function testExample()
{
$this->assertTrue(true);
}
}
<?php
declare(strict_types=1);
require dirname(__DIR__).'/vendor/autoload.php';
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment