mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-09-13 13:57:10 +02:00
Optimized for SPA
This commit is contained in:
28
application/symfony/.env.dist
Normal file
28
application/symfony/.env.dist
Normal file
@@ -0,0 +1,28 @@
|
||||
# This file is a "template" of which env vars need to be defined for your application
|
||||
# Copy this file to .env file for development, create environment variables when deploying to production
|
||||
# https://symfony.com/doc/current/best_practices/configuration.html#infrastructure-related-configuration
|
||||
|
||||
###> symfony/framework-bundle ###
|
||||
APP_ENV=dev
|
||||
APP_SECRET=997425e20bc2144c301a312511101613
|
||||
#TRUSTED_PROXIES=127.0.0.1,127.0.0.2
|
||||
#TRUSTED_HOSTS=localhost,example.com
|
||||
###< symfony/framework-bundle ###
|
||||
|
||||
###> doctrine/doctrine-bundle ###
|
||||
# Format described at http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
|
||||
# For an SQLite database, use: "sqlite:///%kernel.project_dir%/var/data.db"
|
||||
# Configure your db driver and server_version in config/packages/doctrine.yaml
|
||||
DATABASE_URL=mysql://DEV_USER:userpass@db:3306/DEV_DATABASE
|
||||
###< doctrine/doctrine-bundle ###
|
||||
|
||||
###> symfony/swiftmailer-bundle ###
|
||||
# For Gmail as a transport, use: "gmail://username:password@localhost"
|
||||
# For a generic SMTP server, use: "smtp://localhost:25?encryption=&auth_mode="
|
||||
# Delivery is disabled by default via "null://localhost"
|
||||
MAILER_URL=null://localhost
|
||||
|
||||
###> friendsofsymfony/user-bundle ###
|
||||
MAILER_SENDER=test@test.de
|
||||
MAILER_USER=user
|
||||
###< friendsofsymfony/user-bundle ###
|
32
application/symfony/.gitignore
vendored
32
application/symfony/.gitignore
vendored
@@ -1 +1,33 @@
|
||||
### Code Coverage
|
||||
/coverage.xml
|
||||
|
||||
###> symfony/framework-bundle ###
|
||||
/.env
|
||||
/app
|
||||
/public/bundles/
|
||||
/var/
|
||||
/vendor/
|
||||
###< symfony/framework-bundle ###
|
||||
|
||||
###> symfony/phpunit-bridge ###
|
||||
.phpunit
|
||||
/phpunit.xml
|
||||
###< symfony/phpunit-bridge ###
|
||||
|
||||
###> symfony/web-server-bundle ###
|
||||
/.web-server-pid
|
||||
###< symfony/web-server-bundle ###
|
||||
|
||||
### Eclipse
|
||||
.buildpath
|
||||
.project
|
||||
.settings/
|
||||
|
||||
###> phpunit/phpunit ###
|
||||
/phpunit.xml
|
||||
###< phpunit/phpunit ###
|
||||
|
||||
###> friendsofphp/php-cs-fixer ###
|
||||
/.php_cs
|
||||
/.php_cs.cache
|
||||
###< friendsofphp/php-cs-fixer ###
|
||||
|
11
application/symfony/.php_cs.dist
Normal file
11
application/symfony/.php_cs.dist
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
$finder = PhpCsFixer\Finder::create()
|
||||
->exclude('var')
|
||||
->in(__DIR__);
|
||||
|
||||
return PhpCsFixer\Config::create()
|
||||
->setRules([
|
||||
'@Symfony' => true,
|
||||
'array_syntax' => ['syntax' => 'short'],
|
||||
])->setFinder($finder)
|
||||
;
|
39
application/symfony/bin/console
Executable file
39
application/symfony/bin/console
Executable file
@@ -0,0 +1,39 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
use App\Kernel;
|
||||
use Symfony\Bundle\FrameworkBundle\Console\Application;
|
||||
use Symfony\Component\Console\Input\ArgvInput;
|
||||
use Symfony\Component\Debug\Debug;
|
||||
use Symfony\Component\Dotenv\Dotenv;
|
||||
|
||||
set_time_limit(0);
|
||||
|
||||
require __DIR__.'/../vendor/autoload.php';
|
||||
|
||||
if (!class_exists(Application::class)) {
|
||||
throw new \RuntimeException('You need to add "symfony/framework-bundle" as a Composer dependency.');
|
||||
}
|
||||
|
||||
if (!isset($_SERVER['APP_ENV'])) {
|
||||
if (!class_exists(Dotenv::class)) {
|
||||
throw new \RuntimeException('APP_ENV environment variable is not defined. You need to define environment variables for configuration or add "symfony/dotenv" as a Composer dependency to load variables from a .env file.');
|
||||
}
|
||||
(new Dotenv())->load(__DIR__.'/../.env');
|
||||
}
|
||||
|
||||
$input = new ArgvInput();
|
||||
$env = $input->getParameterOption(['--env', '-e'], $_SERVER['APP_ENV'] ?? 'dev', true);
|
||||
$debug = (bool) ($_SERVER['APP_DEBUG'] ?? ('prod' !== $env)) && !$input->hasParameterOption('--no-debug', true);
|
||||
|
||||
if ($debug) {
|
||||
umask(0000);
|
||||
|
||||
if (class_exists(Debug::class)) {
|
||||
Debug::enable();
|
||||
}
|
||||
}
|
||||
|
||||
$kernel = new Kernel($env, $debug);
|
||||
$application = new Application($kernel);
|
||||
$application->run($input);
|
22
application/symfony/bin/phpunit
Executable file
22
application/symfony/bin/phpunit
Executable file
@@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
if (!file_exists(dirname(__DIR__).'/vendor/symfony/phpunit-bridge/bin/simple-phpunit')) {
|
||||
echo "Unable to find the `simple-phpunit` script in `vendor/symfony/phpunit-bridge/bin/`.\n";
|
||||
exit(1);
|
||||
}
|
||||
if (false === getenv('SYMFONY_DEPRECATIONS_HELPER')) {
|
||||
// see https://symfony.com/doc/current/components/phpunit_bridge.html#making-tests-fail
|
||||
putenv('SYMFONY_DEPRECATIONS_HELPER=999999');
|
||||
}
|
||||
if (false === getenv('SYMFONY_PHPUNIT_REMOVE')) {
|
||||
putenv('SYMFONY_PHPUNIT_REMOVE=');
|
||||
}
|
||||
if (false === getenv('SYMFONY_PHPUNIT_VERSION')) {
|
||||
putenv('SYMFONY_PHPUNIT_VERSION=6.5');
|
||||
}
|
||||
if (false === getenv('SYMFONY_PHPUNIT_DIR')) {
|
||||
putenv('SYMFONY_PHPUNIT_DIR='.__DIR__.'/.phpunit');
|
||||
}
|
||||
|
||||
require dirname(__DIR__).'/vendor/symfony/phpunit-bridge/bin/simple-phpunit';
|
94
application/symfony/composer.json
Normal file
94
application/symfony/composer.json
Normal file
@@ -0,0 +1,94 @@
|
||||
{
|
||||
"type": "project",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"require": {
|
||||
"php": "^7.1.3",
|
||||
"ext-ctype": "*",
|
||||
"ext-iconv": "*",
|
||||
"fresh/doctrine-enum-bundle": "~6.2",
|
||||
"friendsofsymfony/rest-bundle": "^2.4",
|
||||
"friendsofsymfony/user-bundle": "~2.1",
|
||||
"jms/serializer-bundle": "^2.4",
|
||||
"knplabs/knp-menu-bundle": "^2.0",
|
||||
"sensio/framework-extra-bundle": "^5.1",
|
||||
"simplethings/entity-audit-bundle": "^1.0",
|
||||
"symfony/asset": "*",
|
||||
"symfony/console": "*",
|
||||
"symfony/expression-language": "*",
|
||||
"symfony/flex": "^1.1",
|
||||
"symfony/form": "*",
|
||||
"symfony/framework-bundle": "*",
|
||||
"symfony/monolog-bundle": "^3.1",
|
||||
"symfony/orm-pack": "*",
|
||||
"symfony/process": "*",
|
||||
"symfony/security-bundle": "*",
|
||||
"symfony/serializer": "*",
|
||||
"symfony/serializer-pack": "*",
|
||||
"symfony/swiftmailer-bundle": "^3.1",
|
||||
"symfony/translation": "*",
|
||||
"symfony/twig-bundle": "*",
|
||||
"symfony/validator": "*",
|
||||
"symfony/web-link": "*",
|
||||
"symfony/yaml": "*"
|
||||
},
|
||||
"require-dev": {
|
||||
"doctrine/doctrine-fixtures-bundle": "^3.0",
|
||||
"friendsofphp/php-cs-fixer": "^2.13",
|
||||
"phpunit/phpunit": "^7",
|
||||
"symfony/browser-kit": "*",
|
||||
"symfony/css-selector": "*",
|
||||
"symfony/debug-pack": "*",
|
||||
"symfony/dotenv": "*",
|
||||
"symfony/maker-bundle": "^1.0",
|
||||
"symfony/phpunit-bridge": "*",
|
||||
"symfony/profiler-pack": "*",
|
||||
"symfony/test-pack": "*",
|
||||
"symfony/var-dumper": "*",
|
||||
"symfony/web-server-bundle": "*"
|
||||
},
|
||||
"config": {
|
||||
"preferred-install": {
|
||||
"*": "dist"
|
||||
},
|
||||
"sort-packages": true
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"App\\": "src/"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"App\\Tests\\": "tests/"
|
||||
}
|
||||
},
|
||||
"replace": {
|
||||
"paragonie/random_compat": "*",
|
||||
"symfony/polyfill-ctype": "*",
|
||||
"symfony/polyfill-iconv": "*",
|
||||
"symfony/polyfill-php71": "*",
|
||||
"symfony/polyfill-php70": "*",
|
||||
"symfony/polyfill-php56": "*"
|
||||
},
|
||||
"scripts": {
|
||||
"auto-scripts": {
|
||||
"cache:clear": "symfony-cmd",
|
||||
"assets:install %PUBLIC_DIR%": "symfony-cmd"
|
||||
},
|
||||
"post-install-cmd": [
|
||||
"@auto-scripts"
|
||||
],
|
||||
"post-update-cmd": [
|
||||
"@auto-scripts"
|
||||
]
|
||||
},
|
||||
"conflict": {
|
||||
"symfony/symfony": "*"
|
||||
},
|
||||
"extra": {
|
||||
"symfony": {
|
||||
"allow-contrib": false,
|
||||
"require": "4.1.*"
|
||||
}
|
||||
}
|
||||
}
|
8372
application/symfony/composer.lock
generated
Normal file
8372
application/symfony/composer.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
23
application/symfony/config/bundles.php
Normal file
23
application/symfony/config/bundles.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
|
||||
Doctrine\Bundle\DoctrineCacheBundle\DoctrineCacheBundle::class => ['all' => true],
|
||||
Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle::class => ['all' => true],
|
||||
Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true],
|
||||
Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class => ['all' => true],
|
||||
Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true],
|
||||
Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle::class => ['all' => true],
|
||||
Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true],
|
||||
Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true],
|
||||
Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true],
|
||||
Symfony\Bundle\DebugBundle\DebugBundle::class => ['dev' => true, 'test' => true],
|
||||
Symfony\Bundle\MakerBundle\MakerBundle::class => ['dev' => true],
|
||||
Symfony\Bundle\WebServerBundle\WebServerBundle::class => ['dev' => true],
|
||||
Knp\Bundle\MenuBundle\KnpMenuBundle::class => ['all' => true],
|
||||
FOS\UserBundle\FOSUserBundle::class => ['all' => true],
|
||||
FOS\RestBundle\FOSRestBundle::class => ['all' => true],
|
||||
JMS\SerializerBundle\JMSSerializerBundle::class => ['all' => true],
|
||||
SimpleThings\EntityAudit\SimpleThingsEntityAuditBundle::class => ['all' => true],
|
||||
Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle::class => ['dev' => true, 'test' => true],
|
||||
];
|
4
application/symfony/config/packages/dev/debug.yaml
Normal file
4
application/symfony/config/packages/dev/debug.yaml
Normal file
@@ -0,0 +1,4 @@
|
||||
debug:
|
||||
# Forwards VarDumper Data clones to a centralized server allowing to inspect dumps on CLI or in your browser.
|
||||
# See the "server:dump" command to start a new server.
|
||||
dump_destination: "tcp://%env(VAR_DUMPER_SERVER)%"
|
@@ -0,0 +1,16 @@
|
||||
services:
|
||||
EasyCorp\EasyLog\EasyLogHandler:
|
||||
public: false
|
||||
arguments: ['%kernel.logs_dir%/%kernel.environment%.log']
|
||||
|
||||
#// FIXME: How to add this configuration automatically without messing up with the monolog configuration?
|
||||
#monolog:
|
||||
# handlers:
|
||||
# buffered:
|
||||
# type: buffer
|
||||
# handler: easylog
|
||||
# channels: ['!event']
|
||||
# level: debug
|
||||
# easylog:
|
||||
# type: service
|
||||
# id: EasyCorp\EasyLog\EasyLogHandler
|
@@ -0,0 +1,7 @@
|
||||
jms_serializer:
|
||||
visitors:
|
||||
json:
|
||||
options:
|
||||
- JSON_PRETTY_PRINT
|
||||
- JSON_UNESCAPED_SLASHES
|
||||
- JSON_PRESERVE_ZERO_FRACTION
|
19
application/symfony/config/packages/dev/monolog.yaml
Normal file
19
application/symfony/config/packages/dev/monolog.yaml
Normal file
@@ -0,0 +1,19 @@
|
||||
monolog:
|
||||
handlers:
|
||||
main:
|
||||
type: stream
|
||||
path: "%kernel.logs_dir%/%kernel.environment%.log"
|
||||
level: debug
|
||||
channels: ["!event"]
|
||||
# uncomment to get logging in your browser
|
||||
# you may have to allow bigger header sizes in your Web server configuration
|
||||
#firephp:
|
||||
# type: firephp
|
||||
# level: info
|
||||
#chromephp:
|
||||
# type: chromephp
|
||||
# level: info
|
||||
console:
|
||||
type: console
|
||||
process_psr_3_messages: false
|
||||
channels: ["!event", "!doctrine", "!console"]
|
3
application/symfony/config/packages/dev/routing.yaml
Normal file
3
application/symfony/config/packages/dev/routing.yaml
Normal file
@@ -0,0 +1,3 @@
|
||||
framework:
|
||||
router:
|
||||
strict_requirements: true
|
4
application/symfony/config/packages/dev/swiftmailer.yaml
Normal file
4
application/symfony/config/packages/dev/swiftmailer.yaml
Normal file
@@ -0,0 +1,4 @@
|
||||
# See https://symfony.com/doc/current/email/dev_environment.html
|
||||
swiftmailer:
|
||||
# send all emails to a specific address
|
||||
#delivery_addresses: ['me@example.com']
|
@@ -0,0 +1,6 @@
|
||||
web_profiler:
|
||||
toolbar: true
|
||||
intercept_redirects: false
|
||||
|
||||
framework:
|
||||
profiler: { only_exceptions: false }
|
31
application/symfony/config/packages/doctrine.yaml
Normal file
31
application/symfony/config/packages/doctrine.yaml
Normal file
@@ -0,0 +1,31 @@
|
||||
parameters:
|
||||
# Adds a fallback DATABASE_URL if the env var is not set.
|
||||
# This allows you to run cache:warmup even if your
|
||||
# environment variables are not available yet.
|
||||
# You should not need to change this value.
|
||||
env(DATABASE_URL): ''
|
||||
|
||||
doctrine:
|
||||
dbal:
|
||||
# configure these for your database server
|
||||
driver: 'pdo_mysql'
|
||||
server_version: '5.7'
|
||||
charset: utf8mb4
|
||||
default_table_options:
|
||||
charset: utf8mb4
|
||||
collate: utf8mb4_unicode_ci
|
||||
url: '%env(resolve:DATABASE_URL)%'
|
||||
types:
|
||||
CRUDType: App\DBAL\Types\Meta\Right\CRUDType
|
||||
LayerType: App\DBAL\Types\Meta\Right\LayerType
|
||||
orm:
|
||||
auto_generate_proxy_classes: '%kernel.debug%'
|
||||
naming_strategy: doctrine.orm.naming_strategy.underscore
|
||||
auto_mapping: true
|
||||
mappings:
|
||||
App:
|
||||
is_bundle: false
|
||||
type: annotation
|
||||
dir: '%kernel.project_dir%/src/Entity'
|
||||
prefix: 'App\Entity'
|
||||
alias: App
|
@@ -0,0 +1,5 @@
|
||||
doctrine_migrations:
|
||||
dir_name: '%kernel.project_dir%/src/Migrations'
|
||||
# namespace is arbitrary but should be different from App\Migrations
|
||||
# as migrations classes should NOT be autoloaded
|
||||
namespace: DoctrineMigrations
|
15
application/symfony/config/packages/fos_rest.yaml
Normal file
15
application/symfony/config/packages/fos_rest.yaml
Normal file
@@ -0,0 +1,15 @@
|
||||
# Read the documentation: https://symfony.com/doc/master/bundles/FOSRestBundle/index.html
|
||||
fos_rest: ~
|
||||
# param_fetcher_listener: true
|
||||
# allowed_methods_listener: true
|
||||
# routing_loader: true
|
||||
# view:
|
||||
# view_response_listener: true
|
||||
# exception:
|
||||
# codes:
|
||||
# App\Exception\MyException: 403
|
||||
# messages:
|
||||
# App\Exception\MyException: Forbidden area.
|
||||
# format_listener:
|
||||
# rules:
|
||||
# - { path: ^/api, prefer_extension: true, fallback_format: json, priorities: [ json, html ] }
|
7
application/symfony/config/packages/fos_user.yaml
Normal file
7
application/symfony/config/packages/fos_user.yaml
Normal file
@@ -0,0 +1,7 @@
|
||||
fos_user:
|
||||
db_driver: orm # other valid values are 'mongodb' and 'couchdb'
|
||||
firewall_name: main
|
||||
user_class: App\Entity\User
|
||||
from_email:
|
||||
address: "%env(MAILER_SENDER)%"
|
||||
sender_name: "%env(MAILER_USER)%"
|
32
application/symfony/config/packages/framework.yaml
Normal file
32
application/symfony/config/packages/framework.yaml
Normal file
@@ -0,0 +1,32 @@
|
||||
framework:
|
||||
secret: '%env(APP_SECRET)%'
|
||||
#default_locale: en
|
||||
#csrf_protection: true
|
||||
#http_method_override: true
|
||||
|
||||
# Enables session support. Note that the session will ONLY be started if you read or write from it.
|
||||
# Remove or comment this section to explicitly disable session support.
|
||||
session:
|
||||
handler_id: ~
|
||||
|
||||
#esi: true
|
||||
#fragments: true
|
||||
php_errors:
|
||||
log: true
|
||||
|
||||
cache:
|
||||
# Put the unique name of your app here: the prefix seed
|
||||
# is used to compute stable namespaces for cache keys.
|
||||
#prefix_seed: your_vendor_name/app_name
|
||||
|
||||
# The app cache caches to the filesystem by default.
|
||||
# Other options include:
|
||||
|
||||
# Redis
|
||||
#app: cache.adapter.redis
|
||||
#default_redis_provider: redis://localhost
|
||||
|
||||
# APCu (not recommended with heavy random-write workloads as memory fragmentation can cause perf issues)
|
||||
#app: cache.adapter.apcu
|
||||
templating:
|
||||
engines: ['twig', 'php']
|
13
application/symfony/config/packages/jms_serializer.yaml
Normal file
13
application/symfony/config/packages/jms_serializer.yaml
Normal file
@@ -0,0 +1,13 @@
|
||||
jms_serializer:
|
||||
visitors:
|
||||
xml:
|
||||
format_output: '%kernel.debug%'
|
||||
# metadata:
|
||||
# auto_detection: false
|
||||
# directories:
|
||||
# any-name:
|
||||
# namespace_prefix: "My\\FooBundle"
|
||||
# path: "@MyFooBundle/Resources/config/serializer"
|
||||
# another-name:
|
||||
# namespace_prefix: "My\\BarBundle"
|
||||
# path: "@MyBarBundle/Resources/config/serializer"
|
31
application/symfony/config/packages/prod/doctrine.yaml
Normal file
31
application/symfony/config/packages/prod/doctrine.yaml
Normal file
@@ -0,0 +1,31 @@
|
||||
doctrine:
|
||||
orm:
|
||||
metadata_cache_driver:
|
||||
type: service
|
||||
id: doctrine.system_cache_provider
|
||||
query_cache_driver:
|
||||
type: service
|
||||
id: doctrine.system_cache_provider
|
||||
result_cache_driver:
|
||||
type: service
|
||||
id: doctrine.result_cache_provider
|
||||
|
||||
services:
|
||||
doctrine.result_cache_provider:
|
||||
class: Symfony\Component\Cache\DoctrineProvider
|
||||
public: false
|
||||
arguments:
|
||||
- '@doctrine.result_cache_pool'
|
||||
doctrine.system_cache_provider:
|
||||
class: Symfony\Component\Cache\DoctrineProvider
|
||||
public: false
|
||||
arguments:
|
||||
- '@doctrine.system_cache_pool'
|
||||
|
||||
framework:
|
||||
cache:
|
||||
pools:
|
||||
doctrine.result_cache_pool:
|
||||
adapter: cache.app
|
||||
doctrine.system_cache_pool:
|
||||
adapter: cache.system
|
@@ -0,0 +1,6 @@
|
||||
jms_serializer:
|
||||
visitors:
|
||||
json:
|
||||
options:
|
||||
- JSON_UNESCAPED_SLASHES
|
||||
- JSON_PRESERVE_ZERO_FRACTION
|
25
application/symfony/config/packages/prod/monolog.yaml
Normal file
25
application/symfony/config/packages/prod/monolog.yaml
Normal file
@@ -0,0 +1,25 @@
|
||||
monolog:
|
||||
handlers:
|
||||
main:
|
||||
type: fingers_crossed
|
||||
action_level: error
|
||||
handler: nested
|
||||
excluded_404s:
|
||||
# regex: exclude all 404 errors from the logs
|
||||
- ^/
|
||||
nested:
|
||||
type: stream
|
||||
path: "%kernel.logs_dir%/%kernel.environment%.log"
|
||||
level: debug
|
||||
console:
|
||||
type: console
|
||||
process_psr_3_messages: false
|
||||
channels: ["!event", "!doctrine"]
|
||||
deprecation:
|
||||
type: stream
|
||||
path: "%kernel.logs_dir%/%kernel.environment%.deprecations.log"
|
||||
deprecation_filter:
|
||||
type: filter
|
||||
handler: deprecation
|
||||
max_level: info
|
||||
channels: ["php"]
|
3
application/symfony/config/packages/routing.yaml
Normal file
3
application/symfony/config/packages/routing.yaml
Normal file
@@ -0,0 +1,3 @@
|
||||
framework:
|
||||
router:
|
||||
strict_requirements: ~
|
33
application/symfony/config/packages/security.yaml
Normal file
33
application/symfony/config/packages/security.yaml
Normal file
@@ -0,0 +1,33 @@
|
||||
security:
|
||||
# https://symfony.com/doc/current/security.html#where-do-users-come-from-user-providers
|
||||
encoders:
|
||||
FOS\UserBundle\Model\UserInterface: bcrypt
|
||||
providers:
|
||||
fos_userbundle:
|
||||
id: fos_user.user_provider.username
|
||||
role_hierarchy:
|
||||
ROLE_ADMIN: ROLE_USER
|
||||
ROLE_SUPER_ADMIN: ROLE_ADMIN
|
||||
hide_user_not_found: false
|
||||
firewalls:
|
||||
dev:
|
||||
pattern: ^/(_(profiler|wdt)|css|images|js)/
|
||||
security: false
|
||||
main:
|
||||
anonymous: true
|
||||
form_login:
|
||||
provider: fos_userbundle
|
||||
csrf_token_generator: security.csrf.token_manager
|
||||
logout: true
|
||||
|
||||
# activate different ways to authenticate
|
||||
|
||||
# http_basic: true
|
||||
# https://symfony.com/doc/current/security.html#a-configuring-how-your-users-will-authenticate
|
||||
# Easy way to control access for large sections of your site
|
||||
# Note: Only the *first* access control that matches will be used
|
||||
access_control:
|
||||
- { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
|
||||
- { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
|
||||
- { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
|
||||
- { path: ^/admin/, role: ROLE_ADMIN }
|
@@ -0,0 +1,3 @@
|
||||
sensio_framework_extra:
|
||||
router:
|
||||
annotations: false
|
@@ -0,0 +1,5 @@
|
||||
simple_things_entity_audit:
|
||||
audited_entities:
|
||||
#- App\Entity\AbstractSource
|
||||
- App\Entity\NameSource
|
||||
- App\Entity\UserSource
|
3
application/symfony/config/packages/swiftmailer.yaml
Normal file
3
application/symfony/config/packages/swiftmailer.yaml
Normal file
@@ -0,0 +1,3 @@
|
||||
swiftmailer:
|
||||
url: '%env(MAILER_URL)%'
|
||||
spool: { type: 'memory' }
|
4
application/symfony/config/packages/test/framework.yaml
Normal file
4
application/symfony/config/packages/test/framework.yaml
Normal file
@@ -0,0 +1,4 @@
|
||||
framework:
|
||||
test: true
|
||||
session:
|
||||
storage_id: session.storage.mock_file
|
7
application/symfony/config/packages/test/monolog.yaml
Normal file
7
application/symfony/config/packages/test/monolog.yaml
Normal file
@@ -0,0 +1,7 @@
|
||||
monolog:
|
||||
handlers:
|
||||
main:
|
||||
type: stream
|
||||
path: "%kernel.logs_dir%/%kernel.environment%.log"
|
||||
level: debug
|
||||
channels: ["!event"]
|
3
application/symfony/config/packages/test/routing.yaml
Normal file
3
application/symfony/config/packages/test/routing.yaml
Normal file
@@ -0,0 +1,3 @@
|
||||
framework:
|
||||
router:
|
||||
strict_requirements: true
|
@@ -0,0 +1,2 @@
|
||||
swiftmailer:
|
||||
disable_delivery: true
|
@@ -0,0 +1,6 @@
|
||||
web_profiler:
|
||||
toolbar: false
|
||||
intercept_redirects: false
|
||||
|
||||
framework:
|
||||
profiler: { collect: false }
|
7
application/symfony/config/packages/translation.yaml
Normal file
7
application/symfony/config/packages/translation.yaml
Normal file
@@ -0,0 +1,7 @@
|
||||
framework:
|
||||
default_locale: '%locale%'
|
||||
translator:
|
||||
paths:
|
||||
- '%kernel.project_dir%/translations'
|
||||
fallbacks:
|
||||
- '%locale%'
|
5
application/symfony/config/packages/twig.yaml
Normal file
5
application/symfony/config/packages/twig.yaml
Normal file
@@ -0,0 +1,5 @@
|
||||
twig:
|
||||
paths: ['%kernel.project_dir%/templates']
|
||||
debug: '%kernel.debug%'
|
||||
strict_variables: '%kernel.debug%'
|
||||
form_themes: ['bootstrap_4_layout.html.twig']
|
3
application/symfony/config/packages/validator.yaml
Normal file
3
application/symfony/config/packages/validator.yaml
Normal file
@@ -0,0 +1,3 @@
|
||||
framework:
|
||||
validation:
|
||||
email_validation_mode: html5
|
4
application/symfony/config/routes.yaml
Normal file
4
application/symfony/config/routes.yaml
Normal file
@@ -0,0 +1,4 @@
|
||||
logout:
|
||||
path: /logout
|
||||
fos_user:
|
||||
resource: "@FOSUserBundle/Resources/config/routing/all.xml"
|
3
application/symfony/config/routes/annotations.yaml
Normal file
3
application/symfony/config/routes/annotations.yaml
Normal file
@@ -0,0 +1,3 @@
|
||||
controllers:
|
||||
resource: ../../src/Controller/
|
||||
type: annotation
|
3
application/symfony/config/routes/dev/twig.yaml
Normal file
3
application/symfony/config/routes/dev/twig.yaml
Normal file
@@ -0,0 +1,3 @@
|
||||
_errors:
|
||||
resource: '@TwigBundle/Resources/config/routing/errors.xml'
|
||||
prefix: /_error
|
7
application/symfony/config/routes/dev/web_profiler.yaml
Normal file
7
application/symfony/config/routes/dev/web_profiler.yaml
Normal file
@@ -0,0 +1,7 @@
|
||||
web_profiler_wdt:
|
||||
resource: '@WebProfilerBundle/Resources/config/routing/wdt.xml'
|
||||
prefix: /_wdt
|
||||
|
||||
web_profiler_profiler:
|
||||
resource: '@WebProfilerBundle/Resources/config/routing/profiler.xml'
|
||||
prefix: /_profiler
|
47
application/symfony/config/services.yaml
Normal file
47
application/symfony/config/services.yaml
Normal file
@@ -0,0 +1,47 @@
|
||||
# This file is the entry point to configure your own services.
|
||||
# Files in the packages/ subdirectory configure your dependencies.
|
||||
|
||||
# Put parameters here that don't need to change on each machine where the app is deployed
|
||||
# https://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration
|
||||
parameters:
|
||||
locale: 'en'
|
||||
|
||||
services:
|
||||
# default configuration for services in *this* file
|
||||
_defaults:
|
||||
autowire: true # Automatically injects dependencies in your services.
|
||||
autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.
|
||||
public: false # Allows optimizing the container by removing unused services; this also means
|
||||
# fetching services directly from the container via $container->get() won't work.
|
||||
# The best practice is to be explicit about your dependencies anyway.
|
||||
app.menu_builder:
|
||||
class: App\Menu\Menu
|
||||
app.menu.usertopbar:
|
||||
class: Knp\Menu\MenuItem
|
||||
factory: ['@app.menu_builder', 'userTopbar']
|
||||
tags:
|
||||
- { name: knp_menu.menu, alias: userTopbar }
|
||||
app.menu.source:
|
||||
class: Knp\Menu\MenuItem
|
||||
factory: ['@app.menu_builder', 'sourceNavbar']
|
||||
tags:
|
||||
- { name: knp_menu.menu, alias: sourceNavbar }
|
||||
app.menu.node:
|
||||
class: Knp\Menu\MenuItem
|
||||
factory: ['@app.menu_builder', 'nodeSubbar']
|
||||
tags:
|
||||
- { name: knp_menu.menu, alias: nodeSubbar }
|
||||
# makes classes in src/ available to be used as services
|
||||
# this creates a service per class whose id is the fully-qualified class name
|
||||
App\:
|
||||
resource: '../src/*'
|
||||
exclude: '../src/{DependencyInjection,Entity,Migrations,Tests,Kernel.php}'
|
||||
|
||||
# controllers are imported separately to make sure services can be injected
|
||||
# as action arguments even if you don't extend any base controller class
|
||||
App\Controller\:
|
||||
resource: '../src/Controller'
|
||||
tags: ['controller.service_arguments']
|
||||
|
||||
# add more service definitions when explicit configuration is needed
|
||||
# please note that last definitions always *replace* previous ones
|
42
application/symfony/phpunit.xml.dist
Normal file
42
application/symfony/phpunit.xml.dist
Normal file
@@ -0,0 +1,42 @@
|
||||
<?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="http://schema.phpunit.de/6.5/phpunit.xsd"
|
||||
backupGlobals="false"
|
||||
colors="true"
|
||||
bootstrap="vendor/autoload.php"
|
||||
>
|
||||
<php>
|
||||
<ini name="error_reporting" value="-1" />
|
||||
<env name="KERNEL_CLASS" value="App\Kernel" />
|
||||
<env name="APP_ENV" value="test" />
|
||||
<env name="APP_DEBUG" value="1" />
|
||||
<env name="APP_SECRET" value="s$cretf0rt3st" />
|
||||
<env name="SHELL_VERBOSITY" value="-1" />
|
||||
<env name="SYMFONY_DEPRECATIONS_HELPER" value="disabled" />
|
||||
<env name="DATABASE_URL" value="mysql://DEV_USER:userpass@db:3306/DEV_DATABASE" />
|
||||
</php>
|
||||
|
||||
<testsuites>
|
||||
<testsuite name="Integration Test Suite">
|
||||
<directory>./tests/Integration/</directory>
|
||||
</testsuite>
|
||||
<testsuite name="Unit Test Suite">
|
||||
<directory>./tests/Unit/</directory>
|
||||
<file>*Test.php</file>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<filter>
|
||||
<whitelist>
|
||||
<directory>./src/</directory>
|
||||
<exclude>
|
||||
<file>./src/Kernel.php</file>
|
||||
<directory>./src/DataFixtures</directory>
|
||||
</exclude>
|
||||
</whitelist>
|
||||
</filter>
|
||||
<listeners>
|
||||
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener" />
|
||||
</listeners>
|
||||
</phpunit>
|
39
application/symfony/public/index.php
Normal file
39
application/symfony/public/index.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
use App\Kernel;
|
||||
use Symfony\Component\Debug\Debug;
|
||||
use Symfony\Component\Dotenv\Dotenv;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
require __DIR__.'/../vendor/autoload.php';
|
||||
|
||||
// The check is to ensure we don't use .env in production
|
||||
if (!isset($_SERVER['APP_ENV'])) {
|
||||
if (!class_exists(Dotenv::class)) {
|
||||
throw new \RuntimeException('APP_ENV environment variable is not defined. You need to define environment variables for configuration or add "symfony/dotenv" as a Composer dependency to load variables from a .env file.');
|
||||
}
|
||||
(new Dotenv())->load(__DIR__.'/../.env');
|
||||
}
|
||||
|
||||
$env = $_SERVER['APP_ENV'] ?? 'dev';
|
||||
$debug = (bool) ($_SERVER['APP_DEBUG'] ?? ('prod' !== $env));
|
||||
|
||||
if ($debug) {
|
||||
umask(0000);
|
||||
|
||||
Debug::enable();
|
||||
}
|
||||
|
||||
if ($trustedProxies = $_SERVER['TRUSTED_PROXIES'] ?? false) {
|
||||
Request::setTrustedProxies(explode(',', $trustedProxies), Request::HEADER_X_FORWARDED_ALL ^ Request::HEADER_X_FORWARDED_HOST);
|
||||
}
|
||||
|
||||
if ($trustedHosts = $_SERVER['TRUSTED_HOSTS'] ?? false) {
|
||||
Request::setTrustedHosts(explode(',', $trustedHosts));
|
||||
}
|
||||
|
||||
$kernel = new Kernel($env, $debug);
|
||||
$request = Request::createFromGlobals();
|
||||
$response = $kernel->handle($request);
|
||||
$response->send();
|
||||
$kernel->terminate($request, $response);
|
0
application/symfony/src/Controller/.gitignore
vendored
Normal file
0
application/symfony/src/Controller/.gitignore
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller\API;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface APIControllerInterface extends CRUDControllerInterface
|
||||
{
|
||||
/**
|
||||
* @param Request $request HTTP Method GET with filtering parameters
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function list(Request $request): Response;
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller\API;
|
||||
|
||||
use App\Controller\AbstractController;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
abstract class AbstractAPIController extends AbstractController implements APIControllerInterface
|
||||
{
|
||||
}
|
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller\API;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*
|
||||
* @see https://de.wikipedia.org/wiki/CRUD
|
||||
*/
|
||||
interface CRUDControllerInterface
|
||||
{
|
||||
/**
|
||||
* @param Request $request HTTP Method POST with the object attributes as parameters
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function create(Request $request): Response;
|
||||
|
||||
/**
|
||||
* @param Request $request HTTP Method GET
|
||||
* @param int|string $identifier The slug or id of the object
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function read(Request $request, $identifier): Response;
|
||||
|
||||
/**
|
||||
* @param Request $request HTTP Method PUT
|
||||
* @param int|string $identifier The slug or id of the object
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function update(Request $request, $identifier): Response;
|
||||
|
||||
/**
|
||||
* @param Request $request HTTP Method DELETE with the object attributes as parameters
|
||||
* @param int|string $identifier The slug or id of the object
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function delete(Request $request, $identifier): Response;
|
||||
}
|
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller\API\Meta;
|
||||
|
||||
use App\Controller\API\AbstractAPIController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class HeredityApiController extends AbstractAPIController
|
||||
{
|
||||
public function read(Request $request, $identifier): Response
|
||||
{
|
||||
}
|
||||
|
||||
public function create(Request $request): Response
|
||||
{
|
||||
}
|
||||
|
||||
public function update(Request $request, $identifier): Response
|
||||
{
|
||||
}
|
||||
|
||||
public function list(Request $request): Response
|
||||
{
|
||||
}
|
||||
|
||||
public function delete(Request $request, $identifier): Response
|
||||
{
|
||||
}
|
||||
}
|
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller\API\Meta;
|
||||
|
||||
use App\Controller\API\AbstractAPIController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
class LawApiController extends AbstractAPIController
|
||||
{
|
||||
public function read(Request $request, $identifier): Response
|
||||
{
|
||||
}
|
||||
|
||||
public function create(Request $request): Response
|
||||
{
|
||||
}
|
||||
|
||||
public function update(Request $request, $identifier): Response
|
||||
{
|
||||
}
|
||||
|
||||
public function list(Request $request): Response
|
||||
{
|
||||
}
|
||||
|
||||
public function delete(Request $request, $identifier): Response
|
||||
{
|
||||
}
|
||||
}
|
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller\API\Meta;
|
||||
|
||||
use App\Controller\API\AbstractAPIController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class MemberApiController extends AbstractAPIController
|
||||
{
|
||||
public function read(Request $request, $identifier): Response
|
||||
{
|
||||
}
|
||||
|
||||
public function create(Request $request): Response
|
||||
{
|
||||
}
|
||||
|
||||
public function update(Request $request, $identifier): Response
|
||||
{
|
||||
}
|
||||
|
||||
public function list(Request $request): Response
|
||||
{
|
||||
}
|
||||
|
||||
public function delete(Request $request, $identifier): Response
|
||||
{
|
||||
}
|
||||
}
|
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller\API\Meta;
|
||||
|
||||
use App\Controller\API\AbstractAPIController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class RightApiController extends AbstractAPIController
|
||||
{
|
||||
public function read(Request $request, $identifier): Response
|
||||
{
|
||||
}
|
||||
|
||||
public function create(Request $request): Response
|
||||
{
|
||||
}
|
||||
|
||||
public function update(Request $request, $identifier): Response
|
||||
{
|
||||
}
|
||||
|
||||
public function list(Request $request): Response
|
||||
{
|
||||
}
|
||||
|
||||
public function delete(Request $request, $identifier): Response
|
||||
{
|
||||
}
|
||||
}
|
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller\API\Source;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use App\Controller\API\AbstractAPIController;
|
||||
use App\Entity\Source\PureSource;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
class SourceApiController extends AbstractAPIController
|
||||
{
|
||||
/**
|
||||
* @Route("/{_locale}/api/source/{identifier}.{_format}",
|
||||
* defaults={"_format"="json"} ,
|
||||
* methods={"GET"}
|
||||
* )
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \App\Controller\API\CRUDControllerInterface::read()
|
||||
*/
|
||||
public function read(Request $request, $identifier): Response
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/{_locale}/api/source.{_format}",
|
||||
* defaults={"_format"="json"} ,
|
||||
* methods={"POST","GET"}
|
||||
* )
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \App\Controller\API\CRUDControllerInterface::create()
|
||||
*/
|
||||
public function create(Request $request): Response
|
||||
{
|
||||
if (Request::METHOD_POST === $request->getMethod()) {
|
||||
$response = new Response();
|
||||
$response->setContent('Post Request!');
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
$response = new Response();
|
||||
$response->setContent('GET Request!');
|
||||
|
||||
return $response;
|
||||
|
||||
$requestedSource = new PureSource();
|
||||
$requestedSource->setSlug(SystemSlugType::IMPRINT);
|
||||
$requestedRight = new Right();
|
||||
$requestedRight->setSource($requestedSource);
|
||||
$requestedRight->setLayer(LayerType::SOURCE);
|
||||
$requestedRight->setType(CRUDType::READ);
|
||||
$sourceResponseManager = new SourceRESTResponseManager($this->getUser(), $entityManager, $requestedRight, $this->getViewHandler());
|
||||
|
||||
return $sourceResponseManager->getResponse();
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/{_locale}/api/source/{identifier}.{_format}",
|
||||
* defaults={"_format"="json"} ,
|
||||
* methods={"PUT"}
|
||||
* )
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \App\Controller\API\CRUDControllerInterface::update()
|
||||
*/
|
||||
public function update(Request $request, $identifier): Response
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/{_locale}/api/sources/.{_format}",
|
||||
* defaults={"_format"="json"} ,
|
||||
* methods={"GET"}
|
||||
* )
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \App\Controller\API\APIControllerInterface::list()
|
||||
*/
|
||||
public function list(Request $request): Response
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/{_locale}/api/source/{identifier}.{_format}",
|
||||
* defaults={"_format"="json"} ,
|
||||
* methods={"DELETE"}
|
||||
* )
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \App\Controller\API\CRUDControllerInterface::delete()
|
||||
*/
|
||||
public function delete(Request $request, $identifier): Response
|
||||
{
|
||||
}
|
||||
}
|
12
application/symfony/src/Controller/AbstractController.php
Normal file
12
application/symfony/src/Controller/AbstractController.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use FOS\RestBundle\Controller\FOSRestController;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
abstract class AbstractController extends FOSRestController
|
||||
{
|
||||
}
|
52
application/symfony/src/Controller/DefaultController.php
Normal file
52
application/symfony/src/Controller/DefaultController.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use App\DBAL\Types\SystemSlugType;
|
||||
use App\Entity\Source\AbstractSource;
|
||||
use App\Entity\Meta\Right;
|
||||
use App\DBAL\Types\Meta\Right\LayerType;
|
||||
use App\DBAL\Types\Meta\Right\CRUDType;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use App\Entity\Source\PureSource;
|
||||
use App\Domain\ResponseManagement\SourceRESTResponseManager;
|
||||
|
||||
/**
|
||||
* This controller offers the standart routes for the template.
|
||||
*
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
final class DefaultController extends AbstractController
|
||||
{
|
||||
/**
|
||||
* @todo Optimize function!
|
||||
* @Route("/imprint.{_format}", defaults={"_format"="json"}, name="imprint")
|
||||
*/
|
||||
public function imprint(EntityManagerInterface $entityManager): Response
|
||||
{
|
||||
$requestedSource = new PureSource();
|
||||
$requestedSource->setSlug(SystemSlugType::IMPRINT);
|
||||
$requestedRight = new Right();
|
||||
$requestedRight->setSource($requestedSource);
|
||||
$requestedRight->setLayer(LayerType::SOURCE);
|
||||
$requestedRight->setType(CRUDType::READ);
|
||||
$sourceResponseManager = new SourceRESTResponseManager($this->getUser(), $entityManager, $requestedRight, $this->getViewHandler());
|
||||
|
||||
return $sourceResponseManager->getResponse();
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/", name="homepage")
|
||||
*/
|
||||
public function homepage(): Response
|
||||
{
|
||||
return $this->render('standard/homepage.html.twig');
|
||||
}
|
||||
|
||||
protected function setEntityName(): void
|
||||
{
|
||||
$this->entityName = AbstractSource::class;
|
||||
}
|
||||
}
|
22
application/symfony/src/Controller/HtmlController.php
Normal file
22
application/symfony/src/Controller/HtmlController.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
/**
|
||||
* Offers an static webpage with bootstrap.
|
||||
*
|
||||
* @see https://getbootstrap.com/
|
||||
*
|
||||
* @author kevinfrantz
|
||||
*
|
||||
* @todo Write tests!
|
||||
*/
|
||||
final class HtmlController extends AbstractController
|
||||
{
|
||||
public function html(Request $request): Response
|
||||
{
|
||||
}
|
||||
}
|
23
application/symfony/src/Controller/SPAController.php
Normal file
23
application/symfony/src/Controller/SPAController.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
/**
|
||||
* Offers an SPA with Vue.js.
|
||||
*
|
||||
* @see https://vuejs.org/
|
||||
* @see https://de.wikipedia.org/wiki/Single-Page-Webanwendung
|
||||
*
|
||||
* @author kevinfrantz
|
||||
*
|
||||
* @todo Write tests!
|
||||
*/
|
||||
class SPAController extends AbstractController
|
||||
{
|
||||
public function spa(Request $request): Response
|
||||
{
|
||||
}
|
||||
}
|
0
application/symfony/src/DBAL/Types/.gitignore
vendored
Normal file
0
application/symfony/src/DBAL/Types/.gitignore
vendored
Normal file
31
application/symfony/src/DBAL/Types/LanguageType.php
Normal file
31
application/symfony/src/DBAL/Types/LanguageType.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\DBAL\Types;
|
||||
|
||||
use Fresh\DoctrineEnumBundle\DBAL\Types\AbstractEnumType;
|
||||
|
||||
/**
|
||||
* Containes all activated languages.
|
||||
*
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
final class LanguageType extends AbstractEnumType
|
||||
{
|
||||
public const GERMAN = 'de';
|
||||
|
||||
public const ENGLISH = 'en';
|
||||
|
||||
public const DUTCH = 'nl';
|
||||
|
||||
public const SPANISH = 'es';
|
||||
|
||||
public const ESPERANTO = 'eo';
|
||||
|
||||
protected static $choices = [
|
||||
self::GERMAN => 'German',
|
||||
self::ENGLISH => 'English',
|
||||
self::SPANISH => 'Spanish',
|
||||
self::ESPERANTO => 'Esperanto',
|
||||
self::DUTCH => 'Dutch',
|
||||
];
|
||||
}
|
29
application/symfony/src/DBAL/Types/MenuEventType.php
Normal file
29
application/symfony/src/DBAL/Types/MenuEventType.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\DBAL\Types;
|
||||
|
||||
use Fresh\DoctrineEnumBundle\DBAL\Types\AbstractEnumType;
|
||||
|
||||
/**
|
||||
* Not integrated in the db. Just used for mapping.
|
||||
* May it will be helpfull for tracking ;).
|
||||
*
|
||||
* @deprecated this class doesn't make sense here. Find an other place for it
|
||||
*
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
final class MenuEventType extends AbstractEnumType
|
||||
{
|
||||
public const USER = 'app.menu.topbar.user';
|
||||
|
||||
public const SOURCE = 'app.menu.subbar.source';
|
||||
|
||||
public const NODE = 'app.menu.subbar.node';
|
||||
|
||||
/**
|
||||
* May this will be used in the future.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected static $choices = [];
|
||||
}
|
26
application/symfony/src/DBAL/Types/Meta/Right/CRUDType.php
Normal file
26
application/symfony/src/DBAL/Types/Meta/Right/CRUDType.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\DBAL\Types\Meta\Right;
|
||||
|
||||
use Fresh\DoctrineEnumBundle\DBAL\Types\AbstractEnumType;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
final class CRUDType extends AbstractEnumType
|
||||
{
|
||||
public const CREATE = 'create';
|
||||
|
||||
public const READ = 'read';
|
||||
|
||||
public const UPDATE = 'update';
|
||||
|
||||
public const DELETE = 'delete';
|
||||
|
||||
protected static $choices = [
|
||||
self::CREATE => 'create',
|
||||
self::READ => 'read',
|
||||
self::UPDATE => 'update',
|
||||
self::DELETE => 'delete',
|
||||
];
|
||||
}
|
32
application/symfony/src/DBAL/Types/Meta/Right/LayerType.php
Normal file
32
application/symfony/src/DBAL/Types/Meta/Right/LayerType.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\DBAL\Types\Meta\Right;
|
||||
|
||||
use Fresh\DoctrineEnumBundle\DBAL\Types\AbstractEnumType;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
final class LayerType extends AbstractEnumType
|
||||
{
|
||||
public const HEREDITY = 'heredity';
|
||||
|
||||
public const RIGHT = 'right';
|
||||
|
||||
public const SOURCE = 'source';
|
||||
|
||||
public const LAW = 'law';
|
||||
|
||||
public const MEMBER = 'member';
|
||||
|
||||
/**
|
||||
* @var array Ordered by the importants of implementation
|
||||
*/
|
||||
protected static $choices = [
|
||||
self::SOURCE => 'source',
|
||||
self::LAW => 'law',
|
||||
self::RIGHT => 'right',
|
||||
self::MEMBER => 'member',
|
||||
self::HEREDITY => 'heredity',
|
||||
];
|
||||
}
|
25
application/symfony/src/DBAL/Types/RESTResponseType.php
Normal file
25
application/symfony/src/DBAL/Types/RESTResponseType.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\DBAL\Types;
|
||||
|
||||
use Fresh\DoctrineEnumBundle\DBAL\Types\AbstractEnumType;
|
||||
|
||||
/**
|
||||
* Containes the template types which the system can process.
|
||||
*
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
final class RESTResponseType extends AbstractEnumType
|
||||
{
|
||||
public const JSON = 'json';
|
||||
|
||||
public const HTML = 'html';
|
||||
|
||||
public const XML = 'xml';
|
||||
|
||||
protected static $choices = [
|
||||
self::JSON => 'json',
|
||||
self::HTML => 'html',
|
||||
self::XML => 'xml',
|
||||
];
|
||||
}
|
26
application/symfony/src/DBAL/Types/SystemSlugType.php
Normal file
26
application/symfony/src/DBAL/Types/SystemSlugType.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\DBAL\Types;
|
||||
|
||||
use Fresh\DoctrineEnumBundle\DBAL\Types\AbstractEnumType;
|
||||
|
||||
/**
|
||||
* Containes the system slugs.
|
||||
*
|
||||
* @author kevinfrantz
|
||||
*
|
||||
* @todo Organize this somehow on an other way
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
final class SystemSlugType extends AbstractEnumType
|
||||
{
|
||||
public const IMPRINT = 'IMPRINT';
|
||||
|
||||
public const GUEST_USER = 'GUEST_USER';
|
||||
|
||||
protected static $choices = [
|
||||
self::IMPRINT => 'imprint',
|
||||
self::GUEST_USER => 'guest user',
|
||||
];
|
||||
}
|
0
application/symfony/src/DataFixtures/.gitignore
vendored
Normal file
0
application/symfony/src/DataFixtures/.gitignore
vendored
Normal file
51
application/symfony/src/DataFixtures/DummyFixtures.php
Normal file
51
application/symfony/src/DataFixtures/DummyFixtures.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\DataFixtures;
|
||||
|
||||
use Doctrine\Bundle\FixturesBundle\Fixture;
|
||||
use Doctrine\Common\Persistence\ObjectManager;
|
||||
use App\Entity\User;
|
||||
use FOS\UserBundle\Doctrine\UserManager;
|
||||
use App\Entity\UserInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
|
||||
|
||||
/**
|
||||
* Never execute this fixture on a livesystem!
|
||||
*
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
class DummyFixtures extends Fixture implements ContainerAwareInterface
|
||||
{
|
||||
private $container;
|
||||
|
||||
public function setContainer(ContainerInterface $container = null)
|
||||
{
|
||||
$this->container = $container;
|
||||
}
|
||||
|
||||
public function load(ObjectManager $manager)
|
||||
{
|
||||
$manager->persist($this->getTestUser());
|
||||
$manager->flush();
|
||||
}
|
||||
|
||||
protected function getTestUser(): UserInterface
|
||||
{
|
||||
/**
|
||||
* @var UserManager
|
||||
*/
|
||||
$userManager = $this->container->get('fos_user.user_manager');
|
||||
/**
|
||||
* @var User
|
||||
*/
|
||||
$testUser = $userManager->createUser();
|
||||
$testUser->setEmail('test@test.de');
|
||||
$testUser->setUsername('test');
|
||||
$testUser->setPlainPassword('test');
|
||||
$testUser->setEnabled(true);
|
||||
$userManager->updateUser($testUser);
|
||||
|
||||
return $testUser;
|
||||
}
|
||||
}
|
79
application/symfony/src/DataFixtures/SourceFixtures.php
Normal file
79
application/symfony/src/DataFixtures/SourceFixtures.php
Normal file
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
namespace App\DataFixtures;
|
||||
|
||||
use Doctrine\Bundle\FixturesBundle\Fixture;
|
||||
use Doctrine\Common\Persistence\ObjectManager;
|
||||
use App\Entity\Source\Primitive\Text\TextSource;
|
||||
use App\Entity\Source\Primitive\Text\TextSourceInterface;
|
||||
use App\DBAL\Types\SystemSlugType;
|
||||
use App\Entity\Source\Complex\UserSource;
|
||||
use App\Entity\Source\Complex\UserSourceInterface;
|
||||
use App\Entity\Meta\Right;
|
||||
use App\DBAL\Types\Meta\Right\LayerType;
|
||||
use App\DBAL\Types\Meta\Right\CRUDType;
|
||||
use App\Entity\Meta\RightInterface;
|
||||
use App\Domain\SourceManagement\SourceRightManager;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*
|
||||
* @todo Create a collection class for all users
|
||||
*/
|
||||
class SourceFixtures extends Fixture
|
||||
{
|
||||
/**
|
||||
* @var TextSourceInterface The example source for the impressum
|
||||
*/
|
||||
private $impressumSource;
|
||||
|
||||
/**
|
||||
* @var UserSourceInterface The UserSource which should be used for the anonymous user
|
||||
*/
|
||||
private $guestUserSource;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \Doctrine\Common\DataFixtures\FixtureInterface::load()
|
||||
*/
|
||||
public function load(ObjectManager $manager)
|
||||
{
|
||||
$this->setGuestUserSource();
|
||||
$this->setImpressumSource();
|
||||
$manager->persist($this->impressumSource);
|
||||
$manager->persist($this->getImpressumRight());
|
||||
$manager->persist($this->guestUserSource);
|
||||
$manager->flush();
|
||||
}
|
||||
|
||||
private function setImpressumSource(): void
|
||||
{
|
||||
$this->impressumSource = new TextSource();
|
||||
$this->impressumSource->setText('Example Impressum');
|
||||
$this->impressumSource->setSlug(SystemSlugType::IMPRINT);
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo Implement that right gets automaticly created by persisting of law
|
||||
*
|
||||
* @return RightInterface
|
||||
*/
|
||||
private function getImpressumRight(): RightInterface
|
||||
{
|
||||
$right = new Right();
|
||||
$sourceRightManager = new SourceRightManager($this->impressumSource);
|
||||
$sourceRightManager->addRight($right);
|
||||
$right->setLayer(LayerType::SOURCE);
|
||||
$right->setType(CRUDType::READ);
|
||||
$right->setReciever($this->guestUserSource);
|
||||
|
||||
return $right;
|
||||
}
|
||||
|
||||
private function setGuestUserSource(): void
|
||||
{
|
||||
$this->guestUserSource = new UserSource();
|
||||
$this->guestUserSource->setSlug(SystemSlugType::GUEST_USER);
|
||||
}
|
||||
}
|
12
application/symfony/src/Domain/AbstractDomainService.php
Normal file
12
application/symfony/src/Domain/AbstractDomainService.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain;
|
||||
|
||||
/**
|
||||
* @deprecated Doesn't make sense!
|
||||
*
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
abstract class AbstractDomainService
|
||||
{
|
||||
}
|
63
application/symfony/src/Domain/FormManagement/FormMeta.php
Normal file
63
application/symfony/src/Domain/FormManagement/FormMeta.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\FormManagement;
|
||||
|
||||
use App\Domain\SourceManagement\SourceMetaInterface;
|
||||
use App\Domain\TemplateManagement\TemplateMetaInterface;
|
||||
use App\Domain\TemplateManagement\TemplateMeta;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*
|
||||
* @todo Optimize contructor parameter!
|
||||
*/
|
||||
class FormMeta implements FormMetaInterface
|
||||
{
|
||||
const FOLDER = 'form';
|
||||
|
||||
/**
|
||||
* @var SourceMetaInterface
|
||||
*/
|
||||
private $sourceMeta;
|
||||
|
||||
/**
|
||||
* @var TemplateMetaInterface
|
||||
*/
|
||||
private $templateMeta;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $formClass;
|
||||
|
||||
public function __construct(SourceMetaInterface $sourceMeta)
|
||||
{
|
||||
$this->sourceMeta = $sourceMeta;
|
||||
$this->setMeta();
|
||||
$this->setFormClass();
|
||||
}
|
||||
|
||||
private function setFormClass(): void
|
||||
{
|
||||
$this->formClass = 'App\\Form';
|
||||
foreach ($this->sourceMeta->getBasicPathArray() as $element) {
|
||||
$this->formClass .= '\\'.ucfirst($element);
|
||||
}
|
||||
$this->formClass .= '\\'.ucfirst($this->sourceMeta->getBasicName()).'Type';
|
||||
}
|
||||
|
||||
private function setMeta(): void
|
||||
{
|
||||
$this->templateMeta = new TemplateMeta($this->sourceMeta->getBasicPathArray(), $this->sourceMeta->getBasicName(), self::FOLDER);
|
||||
}
|
||||
|
||||
public function getFormClass(): string
|
||||
{
|
||||
return $this->formClass;
|
||||
}
|
||||
|
||||
public function getTemplateMeta(): TemplateMetaInterface
|
||||
{
|
||||
return $this->templateMeta;
|
||||
}
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\FormManagement;
|
||||
|
||||
use App\Domain\TemplateManagement\TemplateMetaInterface;
|
||||
|
||||
interface FormMetaInterface
|
||||
{
|
||||
public function getFormClass(): string;
|
||||
|
||||
public function getTemplateMeta(): TemplateMetaInterface;
|
||||
}
|
@@ -0,0 +1,160 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\LawManagement;
|
||||
|
||||
use PhpCollection\CollectionInterface;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use App\Entity\Meta\RightInterface;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use App\Entity\Meta\LawInterface;
|
||||
use App\Domain\RightManagement\RightChecker;
|
||||
use App\Entity\Source\SourceInterface;
|
||||
use App\Domain\SourceManagement\SourceMemberInformation;
|
||||
|
||||
/**
|
||||
* @todo Implement checking by operation sources
|
||||
* @todo chek if recievers are still neccessary and if they should be implemented
|
||||
*
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
final class LawPermissionCheckerService implements LawPermissionCheckerServiceInterface
|
||||
{
|
||||
/**
|
||||
* @var LawInterface
|
||||
*/
|
||||
private $law;
|
||||
|
||||
/**
|
||||
* @param Collection|RightInterface[] $rights
|
||||
* @param string $value
|
||||
* @param string $attribut
|
||||
*
|
||||
* @return Collection|RightInterface[]
|
||||
*/
|
||||
private function getFilteredRights(Collection $rights, string $value, string $attribut): Collection
|
||||
{
|
||||
$result = new ArrayCollection();
|
||||
foreach ($rights as $right) {
|
||||
if ($right->{'get'.$attribut}() === $value) {
|
||||
$result->add($right);
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Collection|RightInterface[] $rights
|
||||
* @param string $type
|
||||
*
|
||||
* @return Collection|RightInterface[]
|
||||
*/
|
||||
private function getRightsByType(Collection $rights, string $type): Collection
|
||||
{
|
||||
return $this->getFilteredRights($rights, $type, 'Type');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Collection|RightInterface[] $rights
|
||||
* @param SourceInterface $reciever
|
||||
*
|
||||
* @return Collection|RightInterface[]
|
||||
*/
|
||||
private function getRightsByReciever(Collection $rights, SourceInterface $reciever): Collection
|
||||
{
|
||||
$result = new ArrayCollection();
|
||||
foreach ($rights as $right) {
|
||||
if ($right->getReciever() === $reciever || $this->memberExist($right, $reciever)) {
|
||||
$result->add($right);
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo Implement!
|
||||
*
|
||||
* @param RightInterface $right
|
||||
* @param SourceInterface $recieverSource
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function memberExist(RightInterface $right, SourceInterface $recieverSource): bool
|
||||
{
|
||||
$rightMemberInformation = new SourceMemberInformation($right->getReciever());
|
||||
$rightMemberSources = $rightMemberInformation->getAllMembers();
|
||||
foreach ($rightMemberSources as $memberSource) {
|
||||
if ($memberSource === $recieverSource) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Collection|RightInterface[] $rights
|
||||
* @param string $layer
|
||||
*
|
||||
* @return Collection|RightInterface[]
|
||||
*/
|
||||
private function getRightsByLayer(Collection $rights, string $layer): Collection
|
||||
{
|
||||
return $this->getFilteredRights($rights, $layer, 'Layer');
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo seems like this can be solved on a nicer way
|
||||
*
|
||||
* @param Collection|RightInterface[] $rights
|
||||
*
|
||||
* @return Collection|RightInterface[]
|
||||
*/
|
||||
private function sortByPriority(Collection $rights): Collection
|
||||
{
|
||||
$iterator = $rights->getIterator();
|
||||
$iterator->uasort(function ($first, $second) {
|
||||
return (int) $first->getPriority() > (int) $second->getPriority() ? 1 : -1;
|
||||
});
|
||||
$sorted = new ArrayCollection();
|
||||
foreach ($iterator as $right) {
|
||||
$sorted->add($right);
|
||||
}
|
||||
|
||||
return $sorted;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CollectionInterface|RightInterface[] $rights
|
||||
* the rights which exist
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function isGranted(Collection $rights, RightInterface $client): bool
|
||||
{
|
||||
if (0 === $rights->count()) {
|
||||
return $this->law->getGrant();
|
||||
}
|
||||
$right = $rights[0];
|
||||
$rightChecker = new RightChecker($right);
|
||||
|
||||
return $rightChecker->isGranted($client->getLayer(), $client->getType(), $client->getReciever());
|
||||
}
|
||||
|
||||
public function __construct(LawInterface $law)
|
||||
{
|
||||
$this->law = $law;
|
||||
}
|
||||
|
||||
public function hasPermission(RightInterface $clientRight): bool
|
||||
{
|
||||
$rights = clone $this->law->getRights();
|
||||
$rights = $this->getRightsByType($rights, $clientRight->getType());
|
||||
$rights = $this->getRightsByLayer($rights, $clientRight->getLayer());
|
||||
$rights = $this->getRightsByReciever($rights, $clientRight->getReciever());
|
||||
$rights = $this->sortByPriority($rights);
|
||||
|
||||
return $this->isGranted($rights, $clientRight);
|
||||
}
|
||||
}
|
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\LawManagement;
|
||||
|
||||
use App\Entity\Meta\RightInterface;
|
||||
|
||||
/**
|
||||
* Allows to check if a source has rights on a source.
|
||||
*
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface LawPermissionCheckerServiceInterface
|
||||
{
|
||||
/**
|
||||
* Checks if the client has the right for executing.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasPermission(RightInterface $clientRight): bool;
|
||||
}
|
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\MemberManagement;
|
||||
|
||||
use App\Entity\Meta\Relation\Member\MemberRelationInterface;
|
||||
|
||||
final class MemberManager implements MemberManagerInterface
|
||||
{
|
||||
/**
|
||||
* @var MemberRelationInterface
|
||||
*/
|
||||
private $memberRelation;
|
||||
|
||||
public function __construct(MemberRelationInterface $memberRelation)
|
||||
{
|
||||
$this->memberRelation = $memberRelation;
|
||||
}
|
||||
|
||||
public function addMember(MemberRelationInterface $member): void
|
||||
{
|
||||
if (!$this->memberRelation->getMembers()->contains($member)) {
|
||||
$this->memberRelation->getMembers()[] = $member;
|
||||
(new self($member))->addMembership($this->memberRelation);
|
||||
}
|
||||
}
|
||||
|
||||
public function removeMember(MemberRelationInterface $member): void
|
||||
{
|
||||
if ($this->memberRelation->getMembers()->contains($member)) {
|
||||
$this->memberRelation->getMembers()->removeElement($member);
|
||||
(new self($member))->removeMembership($this->memberRelation);
|
||||
}
|
||||
}
|
||||
|
||||
public function addMembership(MemberRelationInterface $membership): void
|
||||
{
|
||||
if (!$this->memberRelation->getMemberships()->contains($membership)) {
|
||||
$this->memberRelation->getMemberships()[] = $membership;
|
||||
(new self($membership))->addMember($this->memberRelation);
|
||||
}
|
||||
}
|
||||
|
||||
public function removeMembership(MemberRelationInterface $membership): void
|
||||
{
|
||||
if ($this->memberRelation->getMemberships()->contains($membership)) {
|
||||
$this->memberRelation->getMemberships()->removeElement($membership);
|
||||
(new self($membership))->removeMember($this->memberRelation);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\MemberManagement;
|
||||
|
||||
use App\Entity\Meta\Relation\Member\MemberRelationInterface;
|
||||
|
||||
interface MemberManagerInterface
|
||||
{
|
||||
/**
|
||||
* @param MemberRelationInterface $member
|
||||
*/
|
||||
public function addMember(MemberRelationInterface $member): void;
|
||||
|
||||
/**
|
||||
* @param MemberRelationInterface $member
|
||||
*/
|
||||
public function removeMember(MemberRelationInterface $member): void;
|
||||
|
||||
/**
|
||||
* @param MemberRelationInterface $membership
|
||||
*/
|
||||
public function addMembership(MemberRelationInterface $membership): void;
|
||||
|
||||
/**
|
||||
* @param MemberRelationInterface $membership
|
||||
*/
|
||||
public function removeMembership(MemberRelationInterface $membership): void;
|
||||
}
|
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\ResponseManagement;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use App\Entity\UserInterface;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use App\Entity\Meta\RightInterface;
|
||||
use App\Domain\UserManagement\UserIdentityManager;
|
||||
use FOS\RestBundle\View\ViewHandlerInterface;
|
||||
use App\Entity\Source\SourceInterface;
|
||||
use App\Domain\SecureLoadManagement\SecureSourceLoader;
|
||||
use FOS\RestBundle\View\View;
|
||||
use App\Exception\AllreadyDefinedException;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
class SourceRESTResponseManager implements SourceRESTResponseManagerInterface
|
||||
{
|
||||
/**
|
||||
* @var UserInterface
|
||||
*/
|
||||
private $user;
|
||||
|
||||
/**
|
||||
* @var EntityManagerInterface
|
||||
*/
|
||||
private $entityManager;
|
||||
|
||||
/**
|
||||
* @var RightInterface
|
||||
*/
|
||||
private $requestedRight;
|
||||
|
||||
/**
|
||||
* @var ViewHandlerInterface
|
||||
*/
|
||||
private $viewHandler;
|
||||
|
||||
/**
|
||||
* @var SourceInterface
|
||||
*/
|
||||
private $loadedSource;
|
||||
|
||||
/**
|
||||
* @var View
|
||||
*/
|
||||
private $view;
|
||||
|
||||
/**
|
||||
* @param UserInterface $user
|
||||
* @param EntityManagerInterface $entityManager
|
||||
* @param RightInterface $requestedRight
|
||||
* @param ViewHandlerInterface $viewHandler
|
||||
*/
|
||||
public function __construct(?UserInterface $user, EntityManagerInterface $entityManager, RightInterface $requestedRight, ViewHandlerInterface $viewHandler)
|
||||
{
|
||||
$this->entityManager = $entityManager;
|
||||
$this->viewHandler = $viewHandler;
|
||||
$this->setUser($user);
|
||||
$this->setRequestedRight($requestedRight);
|
||||
$this->setLoadedSource();
|
||||
$this->setView();
|
||||
}
|
||||
|
||||
protected function setView(): void
|
||||
{
|
||||
$this->view = new View($this->loadedSource, 200);
|
||||
}
|
||||
|
||||
private function setLoadedSource(): void
|
||||
{
|
||||
$secureSourceLoader = new SecureSourceLoader($this->entityManager, $this->requestedRight);
|
||||
$this->loadedSource = $secureSourceLoader->getSource();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param UserInterface $user
|
||||
*/
|
||||
private function setUser(?UserInterface $user): void
|
||||
{
|
||||
$userIdentityManager = new UserIdentityManager($this->entityManager, $user);
|
||||
$this->user = $userIdentityManager->getUser();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param RightInterface $requestedRight
|
||||
*
|
||||
* @throws AllreadyDefinedException
|
||||
*/
|
||||
private function setRequestedRight(RightInterface $requestedRight): void
|
||||
{
|
||||
try {
|
||||
$requestedRight->getReciever();
|
||||
throw new AllreadyDefinedException('The reciever is allready defined.');
|
||||
} catch (\TypeError $error) {
|
||||
$requestedRight->setReciever($this->user->getSource());
|
||||
$this->requestedRight = $requestedRight;
|
||||
}
|
||||
}
|
||||
|
||||
public function getResponse(): Response
|
||||
{
|
||||
return $this->viewHandler->handle($this->view);
|
||||
}
|
||||
}
|
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\ResponseManagement;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
interface SourceRESTResponseManagerInterface
|
||||
{
|
||||
/**
|
||||
* @return Response
|
||||
*/
|
||||
public function getResponse(): Response;
|
||||
}
|
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\RightManagement;
|
||||
|
||||
use App\Entity\Meta\RightInterface;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use App\Entity\Source\SourceInterface;
|
||||
use App\Domain\SourceManagement\SourceMemberInformation;
|
||||
|
||||
/**
|
||||
* @todo Implement the check of conditions!
|
||||
*
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
final class RightChecker implements RightCheckerInterface
|
||||
{
|
||||
/**
|
||||
* @var RightInterface
|
||||
*/
|
||||
private $right;
|
||||
|
||||
/**
|
||||
* @todo Implement a performant solution
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
private function getAllSourcesToWhichRightApplies(): Collection
|
||||
{
|
||||
$rightSourceMemberInformation = new SourceMemberInformation($this->right->getReciever());
|
||||
$allSourcesToWhichRightApplies = clone $rightSourceMemberInformation->getAllMembers();
|
||||
$allSourcesToWhichRightApplies->add($this->right->getReciever());
|
||||
|
||||
return $allSourcesToWhichRightApplies;
|
||||
}
|
||||
|
||||
private function hasClientSource(SourceInterface $clientSource): bool
|
||||
{
|
||||
return $this->getAllSourcesToWhichRightApplies()->contains($clientSource);
|
||||
}
|
||||
|
||||
private function isLayerEqual(string $layer): bool
|
||||
{
|
||||
return $this->right->getLayer() === $layer;
|
||||
}
|
||||
|
||||
private function isTypeEqual(string $type): bool
|
||||
{
|
||||
return $this->right->getType() === $type;
|
||||
}
|
||||
|
||||
private function checkPermission(): bool
|
||||
{
|
||||
return $this->right->getGrant();
|
||||
}
|
||||
|
||||
public function __construct(RightInterface $right)
|
||||
{
|
||||
$this->right = $right;
|
||||
}
|
||||
|
||||
public function isGranted(string $layer, string $type, SourceInterface $source): bool
|
||||
{
|
||||
return $this->isLayerEqual($layer) && $this->isTypeEqual($type) && $this->hasClientSource($source) && $this->checkPermission();
|
||||
}
|
||||
}
|
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\RightManagement;
|
||||
|
||||
use App\Entity\Source\SourceInterface;
|
||||
|
||||
interface RightCheckerInterface
|
||||
{
|
||||
public function isGranted(string $layer, string $type, SourceInterface $source): bool;
|
||||
}
|
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\SecureLoadManagement;
|
||||
|
||||
use App\Entity\Source\SourceInterface;
|
||||
use App\Entity\Meta\RightInterface;
|
||||
use Doctrine\Common\Persistence\ObjectRepository;
|
||||
use App\Domain\SecureManagement\SecureSourceChecker;
|
||||
use App\Exception\SourceAccessDenied;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use App\Entity\Source\AbstractSource;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
final class SecureSourceLoader implements SecureSourceLoaderInterface
|
||||
{
|
||||
/**
|
||||
* @todo It would be better to specify the type
|
||||
*
|
||||
* @var ObjectRepository
|
||||
*/
|
||||
private $sourceRepository;
|
||||
|
||||
/**
|
||||
* The source attribute of the right needs a slug OR id.
|
||||
*
|
||||
* @var RightInterface the right which is requested
|
||||
*/
|
||||
private $requestedRight;
|
||||
|
||||
/**
|
||||
* @param SourceInterface $source
|
||||
*
|
||||
* @return RightInterface
|
||||
*/
|
||||
private function getClonedRightWithModifiedSource(SourceInterface $source): RightInterface
|
||||
{
|
||||
$requestedRight = clone $this->requestedRight;
|
||||
$requestedRight->setSource($source);
|
||||
|
||||
return $requestedRight;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SourceInterface
|
||||
*/
|
||||
private function loadSource(): SourceInterface
|
||||
{
|
||||
try {
|
||||
return $this->sourceRepository->find($this->requestedRight->getSource()->getId());
|
||||
} catch (\Error $error) {
|
||||
return $this->sourceRepository->findOneBySlug($this->requestedRight->getSource()->getSlug());
|
||||
}
|
||||
}
|
||||
|
||||
public function __construct(EntityManagerInterface $entityManager, RightInterface $requestedRight)
|
||||
{
|
||||
$this->sourceRepository = $entityManager->getRepository(AbstractSource::class);
|
||||
$this->requestedRight = $requestedRight;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \App\Domain\SecureLoadManagement\SecureSourceLoaderInterface::getSource()
|
||||
*/
|
||||
public function getSource(): SourceInterface
|
||||
{
|
||||
$source = $this->loadSource();
|
||||
$requestedRight = $this->getClonedRightWithModifiedSource($source);
|
||||
$secureSourceChecker = new SecureSourceChecker($source);
|
||||
if ($secureSourceChecker->hasPermission($requestedRight)) {
|
||||
return $source;
|
||||
}
|
||||
throw new SourceAccessDenied();
|
||||
}
|
||||
}
|
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\SecureLoadManagement;
|
||||
|
||||
use App\Entity\Source\SourceInterface;
|
||||
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface SecureSourceLoaderInterface
|
||||
{
|
||||
/**
|
||||
* @throws AccessDeniedHttpException
|
||||
*
|
||||
* @return SourceInterface
|
||||
*/
|
||||
public function getSource(): SourceInterface;
|
||||
}
|
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\SecureManagement;
|
||||
|
||||
use App\Entity\Meta\RightInterface;
|
||||
use App\Entity\Source\SourceInterface;
|
||||
use App\Domain\LawManagement\LawPermissionCheckerService;
|
||||
use App\Exception\SourceAccessDenied;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
final class SecureSourceChecker implements SecureSourceCheckerInterface
|
||||
{
|
||||
/**
|
||||
* @var SourceInterface
|
||||
*/
|
||||
private $source;
|
||||
|
||||
/**
|
||||
* @param SourceInterface $source
|
||||
*/
|
||||
public function __construct(SourceInterface $source)
|
||||
{
|
||||
$this->source = $source;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $methodName
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function isGetter(string $methodName): bool
|
||||
{
|
||||
return 'get' === substr($methodName, 0, 3);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function isSource($value): bool
|
||||
{
|
||||
return $value instanceof SourceInterface;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $methodName
|
||||
*
|
||||
* @return SourceInterface|null
|
||||
*/
|
||||
private function getExpectedSource(string $methodName): ?SourceInterface
|
||||
{
|
||||
try {
|
||||
return $this->source->{$methodName}();
|
||||
} catch (\TypeError $typeError) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param RightInterface $requestedRight
|
||||
*
|
||||
* @throws SourceAccessDenied It's important to fire this exception to reduce complexity in debuging
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function itterateOverSourceAttributs(RightInterface $requestedRight): bool
|
||||
{
|
||||
foreach (get_class_methods($this->source) as $methodName) {
|
||||
if ($this->isGetter($methodName)) {
|
||||
$attributExpectedSource = $this->getExpectedSource($methodName);
|
||||
if ($attributExpectedSource) {
|
||||
$requestedSubSourceRight = clone $requestedRight;
|
||||
$requestedSubSourceRight->setSource($attributExpectedSource);
|
||||
if ($this->isSource($attributExpectedSource)) {
|
||||
$methodSecureSourceChecker = new self($attributExpectedSource);
|
||||
if (!$methodSecureSourceChecker->hasPermission($requestedSubSourceRight)) {
|
||||
throw new SourceAccessDenied('Access denied for subsource!');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \App\Domain\SecureManagement\SecureSourceCheckerInterface::hasPermission()
|
||||
*/
|
||||
public function hasPermission(RightInterface $requestedRight): bool
|
||||
{
|
||||
$law = new LawPermissionCheckerService($this->source->getLaw());
|
||||
|
||||
return $law->hasPermission($requestedRight) && $this->itterateOverSourceAttributs($requestedRight);
|
||||
}
|
||||
}
|
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\SecureManagement;
|
||||
|
||||
use App\Entity\Meta\RightInterface;
|
||||
use App\Exception\SourceAccessDenied;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface SecureSourceCheckerInterface
|
||||
{
|
||||
/**
|
||||
* @throws SourceAccessDenied
|
||||
*
|
||||
* @param RightInterface $right
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasPermission(RightInterface $requestedRight): bool;
|
||||
}
|
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\SourceManagement;
|
||||
|
||||
use App\Domain\AbstractDomainService;
|
||||
|
||||
abstract class AbstractSourceService extends AbstractDomainService
|
||||
{
|
||||
}
|
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\SourceManagement;
|
||||
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use App\Entity\Source\SourceInterface;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use App\Entity\Meta\Relation\Member\MemberRelationInterface;
|
||||
|
||||
final class SourceMemberInformation implements SourceMemberInformationInterface
|
||||
{
|
||||
/**
|
||||
* @var SourceInterface
|
||||
*/
|
||||
private $source;
|
||||
|
||||
/**
|
||||
* @var Collection|SourceInterface[]
|
||||
*/
|
||||
private $members;
|
||||
|
||||
public function __construct(SourceInterface $source)
|
||||
{
|
||||
$this->source = $source;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Collection|MemberRelationInterface[] $members
|
||||
*/
|
||||
private function itterateOverMembers(Collection $members): void
|
||||
{
|
||||
foreach ($members as $member) {
|
||||
if (!$this->members->contains($member->getSource())) {
|
||||
$this->members->add($member->getSource());
|
||||
$this->itterateOverMembers($member->getMembers());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \App\Domain\SourceManagement\SourceMemberInformationInterface::getAllMembers()
|
||||
*/
|
||||
public function getAllMembers(): Collection
|
||||
{
|
||||
$this->members = new ArrayCollection();
|
||||
$this->itterateOverMembers($this->source->getMemberRelation()->getMembers());
|
||||
|
||||
return $this->members;
|
||||
}
|
||||
}
|
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\SourceManagement;
|
||||
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use App\Entity\Source\SourceInterface;
|
||||
|
||||
interface SourceMemberInformationInterface
|
||||
{
|
||||
/**
|
||||
* @return Collection|SourceInterface[] All Members which belong to a source
|
||||
*/
|
||||
public function getAllMembers(): Collection;
|
||||
}
|
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\SourceManagement;
|
||||
|
||||
use App\Entity\Source\SourceInterface;
|
||||
use App\Domain\MemberManagement\MemberManagerInterface;
|
||||
use App\Domain\MemberManagement\MemberManager;
|
||||
|
||||
final class SourceMemberManager implements SourceMemberManagerInterface
|
||||
{
|
||||
/**
|
||||
* @var SourceInterface
|
||||
*/
|
||||
private $source;
|
||||
|
||||
/**
|
||||
* @var MemberManagerInterface
|
||||
*/
|
||||
private $memberManager;
|
||||
|
||||
public function __construct(SourceInterface $source)
|
||||
{
|
||||
$this->source = $source;
|
||||
$this->memberManager = new MemberManager($this->source->getMemberRelation());
|
||||
}
|
||||
|
||||
public function addMember(SourceInterface $member): void
|
||||
{
|
||||
$this->memberManager->addMember($member->getMemberRelation());
|
||||
}
|
||||
|
||||
public function removeMember(SourceInterface $member): void
|
||||
{
|
||||
$this->memberManager->removeMember($member->getMemberRelation());
|
||||
}
|
||||
|
||||
public function addMembership(SourceInterface $membership): void
|
||||
{
|
||||
$this->memberManager->addMembership($membership->getMemberRelation());
|
||||
}
|
||||
|
||||
public function removeMembership(SourceInterface $membership): void
|
||||
{
|
||||
$this->memberManager->removeMembership($membership->getMemberRelation());
|
||||
}
|
||||
}
|
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\SourceManagement;
|
||||
|
||||
use App\Entity\Source\SourceInterface;
|
||||
|
||||
interface SourceMemberManagerInterface
|
||||
{
|
||||
/**
|
||||
* @param SourceInterface $member
|
||||
*/
|
||||
public function addMember(SourceInterface $member): void;
|
||||
|
||||
/**
|
||||
* @param SourceInterface $member
|
||||
*/
|
||||
public function removeMember(SourceInterface $member): void;
|
||||
|
||||
/**
|
||||
* @param SourceInterface $membership
|
||||
*/
|
||||
public function addMembership(SourceInterface $membership): void;
|
||||
|
||||
/**
|
||||
* @param SourceInterface $membership
|
||||
*/
|
||||
public function removeMembership(SourceInterface $membership): void;
|
||||
}
|
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\SourceManagement;
|
||||
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use App\Entity\Source\SourceInterface;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use App\Entity\Meta\Relation\Member\MemberRelationInterface;
|
||||
|
||||
final class SourceMembershipInformation implements SourceMembershipInformationInterface
|
||||
{
|
||||
/**
|
||||
* @var SourceInterface
|
||||
*/
|
||||
private $source;
|
||||
|
||||
/**
|
||||
* @var Collection|SourceInterface[]
|
||||
*/
|
||||
private $memberships;
|
||||
|
||||
public function __construct(SourceInterface $source)
|
||||
{
|
||||
$this->source = $source;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Collection|MemberRelationInterface[] $memberships
|
||||
*/
|
||||
private function itterateOverMemberships(Collection $memberships): void
|
||||
{
|
||||
foreach ($memberships as $membership) {
|
||||
if (!$this->memberships->contains($membership->getSource())) {
|
||||
$this->memberships->add($membership->getSource());
|
||||
$this->itterateOverMemberships($membership->getMemberships());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \App\Domain\SourceManagement\SourceMembershipInformationInterface::getAllMemberships()
|
||||
*/
|
||||
public function getAllMemberships(): Collection
|
||||
{
|
||||
$this->memberships = new ArrayCollection();
|
||||
$this->itterateOverMemberships($this->source->getMemberRelation()->getMemberships());
|
||||
|
||||
return $this->memberships;
|
||||
}
|
||||
}
|
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\SourceManagement;
|
||||
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use App\Entity\Source\SourceInterface;
|
||||
|
||||
interface SourceMembershipInformationInterface
|
||||
{
|
||||
/**
|
||||
* @return Collection|SourceInterface[] all Sources which a Source belongs to
|
||||
*/
|
||||
public function getAllMemberships(): Collection;
|
||||
}
|
126
application/symfony/src/Domain/SourceManagement/SourceMeta.php
Normal file
126
application/symfony/src/Domain/SourceManagement/SourceMeta.php
Normal file
@@ -0,0 +1,126 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\SourceManagement;
|
||||
|
||||
use App\Domain\FormManagement\FormMetaInterface;
|
||||
use App\Domain\TemplateManagement\TemplateMetaInterface;
|
||||
use App\Entity\Source\SourceInterface;
|
||||
use App\Domain\TemplateManagement\TemplateMeta;
|
||||
use App\Domain\FormManagement\FormMeta;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
final class SourceMeta implements SourceMetaInterface
|
||||
{
|
||||
const FOLDER = 'entity';
|
||||
|
||||
/**
|
||||
* @var \ReflectionClass
|
||||
*/
|
||||
private $sourceReflection;
|
||||
|
||||
/**
|
||||
* @var \ReflectionClass
|
||||
*/
|
||||
private $interfaceReflection;
|
||||
|
||||
/**
|
||||
* @var TemplateMetaInterface
|
||||
*/
|
||||
private $templateMeta;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $basicPathArray;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $basicName;
|
||||
|
||||
/**
|
||||
* @var SourceInterface
|
||||
*/
|
||||
private $source;
|
||||
|
||||
/**
|
||||
* @var FormMetaInterface
|
||||
*/
|
||||
private $formMeta;
|
||||
|
||||
public function __construct(SourceInterface $source)
|
||||
{
|
||||
$this->source = $source;
|
||||
$this->sourceReflection = new \ReflectionClass($source);
|
||||
$this->setBasicPathArray();
|
||||
$this->setBasicName();
|
||||
$this->setInterfaceReflection();
|
||||
$this->setTemplateMeta();
|
||||
$this->formMeta = new FormMeta($this);
|
||||
}
|
||||
|
||||
private function setTemplateMeta(): void
|
||||
{
|
||||
$this->templateMeta = new TemplateMeta($this->basicPathArray, $this->basicName, self::FOLDER);
|
||||
}
|
||||
|
||||
private function setBasicPathArray(): void
|
||||
{
|
||||
$namespace = $this->sourceReflection->getNamespaceName();
|
||||
$namespaceWithoutRoot = str_replace('App\\Entity\\', '', $namespace);
|
||||
$this->basicPathArray = [];
|
||||
foreach (explode('\\', $namespaceWithoutRoot) as $element) {
|
||||
$this->basicPathArray[] = strtolower($element);
|
||||
}
|
||||
}
|
||||
|
||||
private function setInterfaceReflection(): void
|
||||
{
|
||||
$namespace = str_replace('\Abstract', '\\', $this->sourceReflection->getName()).'Interface';
|
||||
$this->interfaceReflection = new \ReflectionClass($namespace);
|
||||
}
|
||||
|
||||
private function setBasicName(): void
|
||||
{
|
||||
$withoutAbstract = str_replace('Abstract', '', $this->sourceReflection->getShortName());
|
||||
$withoutSource = str_replace('Source', '', $withoutAbstract);
|
||||
$this->basicName = strtolower($withoutSource);
|
||||
}
|
||||
|
||||
public function getBasicPathArray(): array
|
||||
{
|
||||
return $this->basicPathArray;
|
||||
}
|
||||
|
||||
public function getInterfaceReflection(): \ReflectionClass
|
||||
{
|
||||
return $this->interfaceReflection;
|
||||
}
|
||||
|
||||
public function getSourceReflection(): \ReflectionClass
|
||||
{
|
||||
return $this->sourceReflection;
|
||||
}
|
||||
|
||||
public function getTemplateMeta(): TemplateMetaInterface
|
||||
{
|
||||
return $this->templateMeta;
|
||||
}
|
||||
|
||||
public function getBasicName(): string
|
||||
{
|
||||
return $this->basicName;
|
||||
}
|
||||
|
||||
public function getSource(): SourceInterface
|
||||
{
|
||||
return $this->source;
|
||||
}
|
||||
|
||||
public function getFormMeta(): FormMetaInterface
|
||||
{
|
||||
return $this->formMeta;
|
||||
}
|
||||
}
|
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\SourceManagement;
|
||||
|
||||
use App\Domain\TemplateManagement\TemplateMetaInterface;
|
||||
use App\Entity\Source\SourceInterface;
|
||||
use App\Domain\FormManagement\FormMetaInterface;
|
||||
|
||||
/**
|
||||
* A meta source offers informations, which the system needs to handle the source.
|
||||
*
|
||||
* @deprecated
|
||||
*
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface SourceMetaInterface
|
||||
{
|
||||
public function getSourceReflection(): \ReflectionClass;
|
||||
|
||||
public function getInterfaceReflection(): \ReflectionClass;
|
||||
|
||||
public function getTemplateMeta(): TemplateMetaInterface;
|
||||
|
||||
/**
|
||||
* @return array the namespace elements without the root
|
||||
*/
|
||||
public function getBasicPathArray(): array;
|
||||
|
||||
/**
|
||||
* @return string Short class name in lower case without "Abstract" and "Source"
|
||||
*/
|
||||
public function getBasicName(): string;
|
||||
|
||||
/**
|
||||
* @return SourceInterface The source to which the meta object belongs to
|
||||
*/
|
||||
public function getSource(): SourceInterface;
|
||||
|
||||
public function getFormMeta(): FormMetaInterface;
|
||||
}
|
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\SourceManagement;
|
||||
|
||||
use App\Entity\Meta\RightInterface;
|
||||
use App\Entity\Source\SourceInterface;
|
||||
use App\Exception\AllreadySetException;
|
||||
use App\Entity\Source\AbstractSource;
|
||||
use App\Entity\Meta\Law;
|
||||
use App\Exception\AllreadyDefinedException;
|
||||
use App\Exception\NotSetException;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
final class SourceRightManager implements SourceRightManagerInterface
|
||||
{
|
||||
/**
|
||||
* @var SourceInterface
|
||||
*/
|
||||
private $source;
|
||||
|
||||
/**
|
||||
* @param SourceInterface $source
|
||||
*/
|
||||
public function __construct(SourceInterface $source)
|
||||
{
|
||||
$this->source = $source;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws AllreadyDefinedException If the attribut is allready defined
|
||||
*/
|
||||
private function checkRightAttributes(RightInterface $right): void
|
||||
{
|
||||
$attributes = ['source', 'law'];
|
||||
foreach ($attributes as $attribut) {
|
||||
try {
|
||||
$right->{'get'.ucfirst($attribut)}();
|
||||
throw new AllreadyDefinedException("The attribut \"$attribut\" is allready defined!");
|
||||
} catch (\Error $error) {
|
||||
//Expected
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ArrayCollection|RightInterface[]
|
||||
*/
|
||||
private function getRights(): ArrayCollection
|
||||
{
|
||||
return $this->source->getLaw()->getRights();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \App\Domain\SourceManagement\SourceRightManagerInterface::addRight()
|
||||
*/
|
||||
public function addRight(RightInterface $right): void
|
||||
{
|
||||
if ($this->getRights()->contains($right)) {
|
||||
throw new AllreadySetException('The right was allready added.');
|
||||
}
|
||||
$this->checkRightAttributes($right);
|
||||
$right->setSource($this->source);
|
||||
$right->setLaw($this->source->getLaw());
|
||||
$this->getRights()->add($right);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \App\Domain\SourceManagement\SourceRightManagerInterface::removeRight()
|
||||
*/
|
||||
public function removeRight(RightInterface $right): void
|
||||
{
|
||||
$right->setSource(new class() extends AbstractSource {
|
||||
});
|
||||
$right->setLaw(new Law());
|
||||
if (!$this->getRights()->removeElement($right)) {
|
||||
throw new NotSetException('The right to remove is not set.');
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\SourceManagement;
|
||||
|
||||
use App\Entity\Meta\RightInterface;
|
||||
use App\Exception\AllreadySetException;
|
||||
use App\Exception\AllreadyDefinedException;
|
||||
use App\Exception\NotSetException;
|
||||
|
||||
interface SourceRightManagerInterface
|
||||
{
|
||||
/**
|
||||
* @param RightInterface $right
|
||||
*
|
||||
* @throws AllreadySetException
|
||||
* @throws AllreadyDefinedException
|
||||
*/
|
||||
public function addRight(RightInterface $right): void;
|
||||
|
||||
/**
|
||||
* @param RightInterface $right
|
||||
*
|
||||
* @throws NotSetException
|
||||
*/
|
||||
public function removeRight(RightInterface $right): void;
|
||||
}
|
@@ -0,0 +1,115 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\SourceManagement;
|
||||
|
||||
use App\Entity\Source\Complex\Collection\TreeCollectionSourceInterface;
|
||||
use App\Entity\Source\Complex\Collection\TreeCollectionSource;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use App\Entity\Source\SourceInterface;
|
||||
|
||||
/**
|
||||
* Allows to iterate over a tree.
|
||||
*
|
||||
* @author kevinfrantz
|
||||
*
|
||||
* @todo Maybe lazy loading would be helpfull for performance
|
||||
*/
|
||||
final class TreeSourceService extends AbstractSourceService implements TreeSourceServiceInterface
|
||||
{
|
||||
/**
|
||||
* @var TreeCollectionSourceInterface
|
||||
*/
|
||||
private $source;
|
||||
|
||||
/**
|
||||
* Containes all branches of the actual level of the tree.
|
||||
*
|
||||
* @var Collection
|
||||
*/
|
||||
private $branches;
|
||||
|
||||
/**
|
||||
* Containes all leaves of the actual level of the tree.
|
||||
*
|
||||
* @var Collection
|
||||
*/
|
||||
private $leaves;
|
||||
|
||||
public function __construct(TreeCollectionSource $source)
|
||||
{
|
||||
$this->source = $source;
|
||||
$this->branches = new ArrayCollection();
|
||||
$this->leaves = new ArrayCollection();
|
||||
$this->basicSort();
|
||||
}
|
||||
|
||||
private function sortMember(SourceInterface $member): bool
|
||||
{
|
||||
if ($member instanceof TreeCollectionSource) {
|
||||
return $this->branches->add($member);
|
||||
}
|
||||
|
||||
return $this->leaves->add($member);
|
||||
}
|
||||
|
||||
private function basicSort(): void
|
||||
{
|
||||
foreach ($this->source->getCollection() as $member) {
|
||||
$this->sortMember($member);
|
||||
}
|
||||
}
|
||||
|
||||
public function getBranches(): Collection
|
||||
{
|
||||
return $this->branches;
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo Remove the optional parameter and put the logic in a private funtion.
|
||||
* @todo Remove the getAllBranches use inside the function.
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \App\Domain\SourceManagement\TreeSourceServiceInterface::getAllBranches()
|
||||
*/
|
||||
public function getAllBranches(): Collection
|
||||
{
|
||||
$allBranches = new ArrayCollection($this->branches->toArray());
|
||||
foreach ($this->branches->toArray() as $branch) {
|
||||
$this->itterateOverBranch($branch, $allBranches);
|
||||
}
|
||||
|
||||
return $allBranches;
|
||||
}
|
||||
|
||||
private function itterateOverBranch(TreeCollectionSourceInterface $branch, ArrayCollection $allBranches): void
|
||||
{
|
||||
foreach ((new self($branch))->getBranches() as $branchBranch) {
|
||||
if (!$allBranches->contains($branchBranch)) {
|
||||
$allBranches->add($branchBranch);
|
||||
if ($branchBranch instanceof TreeCollectionSourceInterface) {
|
||||
$this->itterateOverBranch($branchBranch, $allBranches);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getLeaves(): Collection
|
||||
{
|
||||
return $this->leaves;
|
||||
}
|
||||
|
||||
public function getAllLeaves(): Collection
|
||||
{
|
||||
$leaves = new ArrayCollection($this->getLeaves()->toArray());
|
||||
foreach ($this->getAllBranches() as $branch) {
|
||||
foreach ((new self($branch))->getLeaves() as $leave) {
|
||||
if (!$leaves->contains($leave)) {
|
||||
$leaves->add($leave);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $leaves;
|
||||
}
|
||||
}
|
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\SourceManagement;
|
||||
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
|
||||
interface TreeSourceServiceInterface
|
||||
{
|
||||
/**
|
||||
* Delivers the branches of the actual tree back.
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getBranches(): Collection;
|
||||
|
||||
/**
|
||||
* Delivers the members of the actual tree back.
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getLeaves(): Collection;
|
||||
|
||||
/**
|
||||
* Delivers all members till a infinite level of the tree back.
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getAllLeaves(): Collection;
|
||||
|
||||
/**
|
||||
* Delivers all branches till a infinite level of the actual tree back.
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getAllBranches(): Collection;
|
||||
}
|
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\TemplateManagement;
|
||||
|
||||
use App\DBAL\Types\RESTResponseType;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
final class TemplateMeta implements TemplateMetaInterface
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $basicPathArray;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $basicName;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $type = RESTResponseType::HTML;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $pathSuffix;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $frameTemplatePath;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $contentTemplatePath;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $folder;
|
||||
|
||||
public function __construct(array $basicPathArray, string $basicName, string $folder)
|
||||
{
|
||||
$this->basicPathArray = $basicPathArray;
|
||||
$this->basicName = $basicName;
|
||||
$this->folder = $folder;
|
||||
$this->init();
|
||||
}
|
||||
|
||||
private function init()
|
||||
{
|
||||
$this->setPathSuffix();
|
||||
$this->setFrameTemplatePath();
|
||||
$this->setContentTemplatePath();
|
||||
}
|
||||
|
||||
private function setPathSuffix(): void
|
||||
{
|
||||
$this->pathSuffix = $this->folder.'/'.implode('/', $this->basicPathArray).'/'.$this->basicName.'.'.$this->type.'.twig';
|
||||
}
|
||||
|
||||
private function setFrameTemplatePath(): void
|
||||
{
|
||||
$this->frameTemplatePath = 'frame/'.$this->pathSuffix;
|
||||
}
|
||||
|
||||
private function setContentTemplatePath(): void
|
||||
{
|
||||
$this->contentTemplatePath = 'content/'.$this->pathSuffix;
|
||||
}
|
||||
|
||||
public function getFrameTemplatePath(): string
|
||||
{
|
||||
return $this->frameTemplatePath;
|
||||
}
|
||||
|
||||
public function getContentTemplatePath(): string
|
||||
{
|
||||
return $this->contentTemplatePath;
|
||||
}
|
||||
|
||||
public function setTemplateType(string $type): void
|
||||
{
|
||||
$this->type = $type;
|
||||
$this->init();
|
||||
}
|
||||
|
||||
public function getTemplateType(): string
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
}
|
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\TemplateManagement;
|
||||
|
||||
/**
|
||||
* Manages all informations which are needed to process templates.
|
||||
*
|
||||
* @deprecated
|
||||
*
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface TemplateMetaInterface
|
||||
{
|
||||
/**
|
||||
* Sets the template type which should be processed(General html);.
|
||||
*/
|
||||
public function setTemplateType(string $type): void;
|
||||
|
||||
public function getTemplateType(): string;
|
||||
|
||||
/**
|
||||
* Returns a template inclusiv frame.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFrameTemplatePath(): string;
|
||||
|
||||
/**
|
||||
* Returns a template without a frame.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getContentTemplatePath(): string;
|
||||
}
|
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\UserManagement;
|
||||
|
||||
use App\Entity\UserInterface;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use App\DBAL\Types\SystemSlugType;
|
||||
use App\Entity\User;
|
||||
use App\Entity\Source\AbstractSource;
|
||||
use App\Repository\Source\SourceRepository;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
final class UserIdentityManager implements UserIdentityManagerInterface
|
||||
{
|
||||
/**
|
||||
* @var UserInterface
|
||||
*/
|
||||
private $user;
|
||||
|
||||
/**
|
||||
* @var SourceRepository
|
||||
*/
|
||||
private $sourceRepository;
|
||||
|
||||
/**
|
||||
* @param EntityManagerInterface $entityManager
|
||||
*/
|
||||
private function setSourceRepository(EntityManagerInterface $entityManager): void
|
||||
{
|
||||
$this->sourceRepository = $entityManager->getRepository(AbstractSource::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param UserInterface $user
|
||||
*/
|
||||
private function setUser(?UserInterface $user): void
|
||||
{
|
||||
if ($user) {
|
||||
$this->user = $user;
|
||||
|
||||
return;
|
||||
}
|
||||
$this->user = new User();
|
||||
$this->user->setSource($this->sourceRepository->findOneBySlug(SystemSlugType::GUEST_USER));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param EntityManagerInterface $entityManager
|
||||
* @param UserInterface $user
|
||||
*/
|
||||
public function __construct(EntityManagerInterface $entityManager, ?UserInterface $user)
|
||||
{
|
||||
$this->setSourceRepository($entityManager);
|
||||
$this->setUser($user);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \App\Domain\UserManagement\UserIdentityManagerInterface::getUser()
|
||||
*/
|
||||
public function getUser(): UserInterface
|
||||
{
|
||||
return $this->user;
|
||||
}
|
||||
}
|
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\UserManagement;
|
||||
|
||||
use App\Entity\UserInterface;
|
||||
|
||||
interface UserIdentityManagerInterface
|
||||
{
|
||||
/**
|
||||
* @return UserInterface
|
||||
*/
|
||||
public function getUser(): UserInterface;
|
||||
}
|
0
application/symfony/src/Entity/.gitignore
vendored
Normal file
0
application/symfony/src/Entity/.gitignore
vendored
Normal file
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user