Merge pull request 'feature/users-roles' (#5) from feature/users-roles into main
Reviewed-on: #5pull/6/head
commit
9aa0514720
|
@ -0,0 +1,6 @@
|
||||||
|
# define your env variables for the test env here
|
||||||
|
KERNEL_CLASS='App\Kernel'
|
||||||
|
APP_SECRET='$ecretf0rt3st'
|
||||||
|
SYMFONY_DEPRECATIONS_HELPER=999999
|
||||||
|
PANTHER_APP_ENV=panther
|
||||||
|
PANTHER_ERROR_SCREENSHOT_DIR=./var/error-screenshots
|
|
@ -15,3 +15,13 @@
|
||||||
###> lexik/jwt-authentication-bundle ###
|
###> lexik/jwt-authentication-bundle ###
|
||||||
/config/jwt/*.pem
|
/config/jwt/*.pem
|
||||||
###< lexik/jwt-authentication-bundle ###
|
###< lexik/jwt-authentication-bundle ###
|
||||||
|
|
||||||
|
###> symfony/phpunit-bridge ###
|
||||||
|
.phpunit.result.cache
|
||||||
|
/phpunit.xml
|
||||||
|
###< symfony/phpunit-bridge ###
|
||||||
|
|
||||||
|
###> phpunit/phpunit ###
|
||||||
|
/phpunit.xml
|
||||||
|
.phpunit.result.cache
|
||||||
|
###< phpunit/phpunit ###
|
||||||
|
|
52
README.md
52
README.md
|
@ -5,6 +5,14 @@
|
||||||
ogCore es el servicio central de OpenGnsys, diseñado para proporcionar funcionalidades a través de una API RESTful. Esta herramienta utiliza tecnología PHP, aprovechando el framework Symfony y el ORM Doctrine para gestionar la base de datos.
|
ogCore es el servicio central de OpenGnsys, diseñado para proporcionar funcionalidades a través de una API RESTful. Esta herramienta utiliza tecnología PHP, aprovechando el framework Symfony y el ORM Doctrine para gestionar la base de datos.
|
||||||
A continuación, se detallan los pasos necesarios para desplegar el proyecto en un entorno de desarrollo.
|
A continuación, se detallan los pasos necesarios para desplegar el proyecto en un entorno de desarrollo.
|
||||||
|
|
||||||
|
## Versiones y tecnologías utilizadas
|
||||||
|
|
||||||
|
- PHP 8.3
|
||||||
|
- Symfony 6.4
|
||||||
|
- Doctrine 2.19
|
||||||
|
- API Platform 3.2
|
||||||
|
- MariaDB 10.11
|
||||||
|
|
||||||
## Requisitos
|
## Requisitos
|
||||||
|
|
||||||
Antes de comenzar, asegúrate de tener los siguientes requisitos:
|
Antes de comenzar, asegúrate de tener los siguientes requisitos:
|
||||||
|
@ -39,14 +47,14 @@ Y deberiamos ver algo parecido a :
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
docker exec ogcore-php composer install
|
docker exec ogcore-php composer install
|
||||||
docker exec ogcore-php symfony console lexik:jwt:generate-keypair --overwrite
|
docker exec ogcore-php php bin/console lexik:jwt:generate-keypair --overwrite
|
||||||
```
|
```
|
||||||
|
|
||||||
Comprobamos, que el contenedor de Nginx, tiene el puerto 8080 levantado correctamente, asi que tan solo tendremos que
|
Comprobamos, que el contenedor de Nginx, tiene el puerto 8080 levantado correctamente, asi que tan solo tendremos que
|
||||||
acceder a la siguiente URL:
|
acceder a la siguiente URL:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
http://127.0.0.1:8080/api/docs
|
http://127.0.0.1:8080/docs
|
||||||
```
|
```
|
||||||
Si todo ha ido bien, deberiamos ver la documentación de la API de ogCore.
|
Si todo ha ido bien, deberiamos ver la documentación de la API de ogCore.
|
||||||
|
|
||||||
|
@ -55,9 +63,45 @@ Para poder actualizar la base de datos:
|
||||||
Para inicializar la base de datos:
|
Para inicializar la base de datos:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
docker exec ogcore-php symfony console doctrine:migrations:migrate --no-interaction
|
docker exec ogcore-php php bin/console doctrine:migrations:migrate --no-interaction
|
||||||
```
|
```
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
docker exec ogcore-php symfony console doctrine:fixtures:load --no-interaction
|
docker exec ogcore-php php bin/console doctrine:fixtures:load --no-interaction
|
||||||
|
docker exec ogcore-php php bin/console app:load-default-user-groups
|
||||||
|
```
|
||||||
|
|
||||||
|
## UX Api Platform
|
||||||
|
|
||||||
|
Api Platform proporciona una interfaz de usuario para interactuar con la API de ogCore. Para acceder a la interfaz de usuario, accede a la siguiente URL:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
http://127.0.0.1:8080/docs
|
||||||
|
```
|
||||||
|
|
||||||
|
Para poder autenticarte, necesitas un token JWT. Para obtenerlo, accedemos al endpoint de autenticación "auth/login":
|
||||||
|
|
||||||
|

|
||||||
|

|
||||||
|
Obtenemos el token y lo introducimos en la interfaz de usuario de Api Platform de la siguiente manera:
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Ahora, ya podemos interactuar con la API de ogCore. Para comprobar que todo está correcto, podemos fijarnos en los headers de las llamadas Curl, y ver que el token JWT se ha introducido correctamente.
|
||||||
|
|
||||||
|
## Test
|
||||||
|
|
||||||
|
Para ejecutar los test, ejecutamos el siguiente comando:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
docker compose exec php bin/phpunit
|
||||||
|
```
|
||||||
|
|
||||||
|
## Reiniciar base de datos
|
||||||
|
|
||||||
|
Es posible que en momentos de desarrollo, sea necesario volver a cargar la base de datos y actualizar los esquemas de la misma, para ello, ejecutamos el siguiente comando:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
docker exec ogcore-php php bin/console doctrine:database:drop --force
|
||||||
|
docker exec ogcore-php php bin/console doctrine:database:create
|
||||||
```
|
```
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
#!/usr/bin/env php
|
||||||
|
<?php
|
||||||
|
|
||||||
|
if (!ini_get('date.timezone')) {
|
||||||
|
ini_set('date.timezone', 'UTC');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_file(dirname(__DIR__).'/vendor/phpunit/phpunit/phpunit')) {
|
||||||
|
if (PHP_VERSION_ID >= 80000) {
|
||||||
|
require dirname(__DIR__).'/vendor/phpunit/phpunit/phpunit';
|
||||||
|
} else {
|
||||||
|
define('PHPUNIT_COMPOSER_INSTALL', dirname(__DIR__).'/vendor/autoload.php');
|
||||||
|
require PHPUNIT_COMPOSER_INSTALL;
|
||||||
|
PHPUnit\TextUI\Command::main();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!is_file(dirname(__DIR__).'/vendor/symfony/phpunit-bridge/bin/simple-phpunit.php')) {
|
||||||
|
echo "Unable to find the `simple-phpunit.php` script in `vendor/symfony/phpunit-bridge/bin/`.\n";
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
require dirname(__DIR__).'/vendor/symfony/phpunit-bridge/bin/simple-phpunit.php';
|
||||||
|
}
|
|
@ -11,12 +11,14 @@
|
||||||
"doctrine/dbal": "^3",
|
"doctrine/dbal": "^3",
|
||||||
"doctrine/doctrine-bundle": "^2.12",
|
"doctrine/doctrine-bundle": "^2.12",
|
||||||
"doctrine/doctrine-migrations-bundle": "^3.3",
|
"doctrine/doctrine-migrations-bundle": "^3.3",
|
||||||
"doctrine/orm": "^3.1",
|
"doctrine/orm": "^2.19.5",
|
||||||
"gesdinet/jwt-refresh-token-bundle": "^1.3",
|
"gesdinet/jwt-refresh-token-bundle": "^1.3",
|
||||||
"lexik/jwt-authentication-bundle": "^3.0",
|
"lexik/jwt-authentication-bundle": "^3.0",
|
||||||
"nelmio/cors-bundle": "^2.4",
|
"nelmio/cors-bundle": "^2.4",
|
||||||
"phpdocumentor/reflection-docblock": "^5.4",
|
"phpdocumentor/reflection-docblock": "^5.4",
|
||||||
"phpstan/phpdoc-parser": "^1.29",
|
"phpstan/phpdoc-parser": "^1.29",
|
||||||
|
"ramsey/uuid-doctrine": "^2.0",
|
||||||
|
"stof/doctrine-extensions-bundle": "^1.10",
|
||||||
"symfony/asset": "6.4.*",
|
"symfony/asset": "6.4.*",
|
||||||
"symfony/console": "6.4.*",
|
"symfony/console": "6.4.*",
|
||||||
"symfony/dotenv": "6.4.*",
|
"symfony/dotenv": "6.4.*",
|
||||||
|
@ -81,8 +83,14 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
|
"dama/doctrine-test-bundle": "^8.1",
|
||||||
"doctrine/doctrine-fixtures-bundle": "^3.6",
|
"doctrine/doctrine-fixtures-bundle": "^3.6",
|
||||||
|
"phpunit/phpunit": "^9.5",
|
||||||
|
"symfony/browser-kit": "6.4.*",
|
||||||
|
"symfony/css-selector": "6.4.*",
|
||||||
|
"symfony/http-client": "6.4.*",
|
||||||
"symfony/maker-bundle": "^1.59",
|
"symfony/maker-bundle": "^1.59",
|
||||||
|
"symfony/phpunit-bridge": "^7.0",
|
||||||
"symfony/web-profiler-bundle": "^6.4",
|
"symfony/web-profiler-bundle": "^6.4",
|
||||||
"zenstruck/foundry": "^1.37"
|
"zenstruck/foundry": "^1.37"
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,27 @@
|
||||||
|
resources:
|
||||||
|
App\Entity\OrganizationalUnit:
|
||||||
|
processor: App\State\Processor\OrganizationalUnitProcessor
|
||||||
|
input: App\Dto\Input\OrganizationalUnitInput
|
||||||
|
output: App\Dto\Output\OrganizationalUnitOutput
|
||||||
|
normalization_context:
|
||||||
|
groups: ['default', 'organizational-unit:read']
|
||||||
|
denormalization_context:
|
||||||
|
groups: ['organizational-unit:write']
|
||||||
|
operations:
|
||||||
|
ApiPlatform\Metadata\GetCollection:
|
||||||
|
provider: App\State\Provider\OrganizationalUnitProvider
|
||||||
|
ApiPlatform\Metadata\Get:
|
||||||
|
provider: App\State\Provider\OrganizationalUnitProvider
|
||||||
|
ApiPlatform\Metadata\Put:
|
||||||
|
provider: App\State\Provider\OrganizationalUnitProvider
|
||||||
|
ApiPlatform\Metadata\Patch:
|
||||||
|
provider: App\State\Provider\OrganizationalUnitProvider
|
||||||
|
ApiPlatform\Metadata\Post: ~
|
||||||
|
ApiPlatform\Metadata\Delete: ~
|
||||||
|
|
||||||
|
properties:
|
||||||
|
App\Entity\OrganizationalUnit:
|
||||||
|
id:
|
||||||
|
identifier: false
|
||||||
|
uuid:
|
||||||
|
identifier: true
|
|
@ -0,0 +1,35 @@
|
||||||
|
resources:
|
||||||
|
App\Entity\User:
|
||||||
|
security: 'is_granted("ROLE_SUPER_ADMIN")'
|
||||||
|
input: App\Dto\Input\UserInput
|
||||||
|
output: App\Dto\Output\UserOutput
|
||||||
|
processor: App\State\Processor\UserProcessor
|
||||||
|
normalization_context:
|
||||||
|
groups: ['default', 'user:read']
|
||||||
|
denormalization_context:
|
||||||
|
groups: ['user:write']
|
||||||
|
|
||||||
|
operations:
|
||||||
|
ApiPlatform\Metadata\GetCollection:
|
||||||
|
provider: App\State\Provider\UserProvider
|
||||||
|
filters:
|
||||||
|
- 'api_platform.filter.user.order'
|
||||||
|
- 'api_platform.filter.user.search'
|
||||||
|
- 'api_platform.filter.user.boolean'
|
||||||
|
ApiPlatform\Metadata\Get:
|
||||||
|
provider: App\State\Provider\UserProvider
|
||||||
|
ApiPlatform\Metadata\Put:
|
||||||
|
provider: App\State\Provider\UserProvider
|
||||||
|
ApiPlatform\Metadata\Patch:
|
||||||
|
provider: App\State\Provider\UserProvider
|
||||||
|
ApiPlatform\Metadata\Post:
|
||||||
|
validationContext:
|
||||||
|
groups: [ 'default', 'user:post' ]
|
||||||
|
ApiPlatform\Metadata\Delete: ~
|
||||||
|
|
||||||
|
properties:
|
||||||
|
App\Entity\User:
|
||||||
|
id:
|
||||||
|
identifier: false
|
||||||
|
uuid:
|
||||||
|
identifier: true
|
|
@ -0,0 +1,32 @@
|
||||||
|
resources:
|
||||||
|
App\Entity\UserGroup:
|
||||||
|
security: 'is_granted("ROLE_SUPER_ADMIN")'
|
||||||
|
processor: App\State\Processor\UserGroupProcessor
|
||||||
|
input: App\Dto\Input\UserGroupInput
|
||||||
|
output: App\Dto\Output\UserGroupOutput
|
||||||
|
normalization_context:
|
||||||
|
groups: ['default', 'user-group:read']
|
||||||
|
denormalization_context:
|
||||||
|
groups: ['user-group:write']
|
||||||
|
operations:
|
||||||
|
ApiPlatform\Metadata\GetCollection:
|
||||||
|
provider: App\State\Provider\UserGroupProvider
|
||||||
|
filters:
|
||||||
|
- 'api_platform.filter.user_group.order'
|
||||||
|
- 'api_platform.filter.user_group.search'
|
||||||
|
- 'api_platform.filter.user_group.boolean'
|
||||||
|
ApiPlatform\Metadata\Get:
|
||||||
|
provider: App\State\Provider\UserGroupProvider
|
||||||
|
ApiPlatform\Metadata\Put:
|
||||||
|
provider: App\State\Provider\UserGroupProvider
|
||||||
|
ApiPlatform\Metadata\Patch:
|
||||||
|
provider: App\State\Provider\UserGroupProvider
|
||||||
|
ApiPlatform\Metadata\Post: ~
|
||||||
|
ApiPlatform\Metadata\Delete: ~
|
||||||
|
|
||||||
|
properties:
|
||||||
|
App\Entity\UserGroup:
|
||||||
|
id:
|
||||||
|
identifier: false
|
||||||
|
uuid:
|
||||||
|
identifier: true
|
|
@ -14,4 +14,6 @@ return [
|
||||||
Zenstruck\Foundry\ZenstruckFoundryBundle::class => ['dev' => true, 'test' => true],
|
Zenstruck\Foundry\ZenstruckFoundryBundle::class => ['dev' => true, 'test' => true],
|
||||||
Gesdinet\JWTRefreshTokenBundle\GesdinetJWTRefreshTokenBundle::class => ['all' => true],
|
Gesdinet\JWTRefreshTokenBundle\GesdinetJWTRefreshTokenBundle::class => ['all' => true],
|
||||||
Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true],
|
Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true],
|
||||||
|
Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle::class => ['all' => true],
|
||||||
|
DAMA\DoctrineTestBundle\DAMADoctrineTestBundle::class => ['test' => true],
|
||||||
];
|
];
|
||||||
|
|
|
@ -2,14 +2,28 @@ api_platform:
|
||||||
title: 'OgCore API'
|
title: 'OgCore API'
|
||||||
description: 'API Documentation for OgCore'
|
description: 'API Documentation for OgCore'
|
||||||
version: 1.0.0
|
version: 1.0.0
|
||||||
|
path_segment_name_generator: 'api_platform.path_segment_name_generator.dash'
|
||||||
formats:
|
formats:
|
||||||
jsonld: ['application/ld+json']
|
jsonld: ['application/ld+json', 'application/json']
|
||||||
|
patch_formats:
|
||||||
|
jsonld: ['application/ld+json', 'application/json']
|
||||||
|
mapping:
|
||||||
|
paths: ['%kernel.project_dir%/config/api_platform', '%kernel.project_dir%/src/Dto']
|
||||||
|
defaults:
|
||||||
|
pagination_client_items_per_page: true
|
||||||
|
denormalization_context:
|
||||||
|
allow_extra_attributes: false
|
||||||
|
cache_headers:
|
||||||
|
vary: [ 'Content-Type', 'Authorization', 'Origin' ]
|
||||||
|
extra_properties:
|
||||||
|
standard_put: true
|
||||||
|
rfc_7807_compliant_errors: true
|
||||||
|
event_listeners_backward_compatibility_layer: false
|
||||||
|
keep_legacy_inflector: true
|
||||||
docs_formats:
|
docs_formats:
|
||||||
jsonld: ['application/ld+json']
|
jsonld: ['application/ld+json']
|
||||||
jsonopenapi: ['application/vnd.openapi+json']
|
jsonopenapi: ['application/vnd.openapi+json']
|
||||||
html: ['text/html']
|
html: ['text/html']
|
||||||
keep_legacy_inflector: false
|
|
||||||
use_symfony_listeners: true
|
|
||||||
swagger:
|
swagger:
|
||||||
versions: [3]
|
versions: [3]
|
||||||
api_keys:
|
api_keys:
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
when@test:
|
||||||
|
dama_doctrine_test:
|
||||||
|
enable_static_connection: true
|
||||||
|
enable_static_meta_data_cache: true
|
||||||
|
enable_static_query_cache: true
|
|
@ -1,13 +1,10 @@
|
||||||
doctrine:
|
doctrine:
|
||||||
dbal:
|
dbal:
|
||||||
url: '%env(resolve:DATABASE_URL)%'
|
url: '%env(resolve:DATABASE_URL)%'
|
||||||
|
|
||||||
# IMPORTANT: You MUST configure your server version,
|
|
||||||
# either here or in the DATABASE_URL env var (see .env file)
|
|
||||||
#server_version: '16'
|
|
||||||
|
|
||||||
profiling_collect_backtrace: '%kernel.debug%'
|
profiling_collect_backtrace: '%kernel.debug%'
|
||||||
use_savepoints: true
|
use_savepoints: true
|
||||||
|
mapping_types:
|
||||||
|
enum: string
|
||||||
orm:
|
orm:
|
||||||
auto_generate_proxy_classes: true
|
auto_generate_proxy_classes: true
|
||||||
enable_lazy_ghost_objects: true
|
enable_lazy_ghost_objects: true
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
doctrine:
|
||||||
|
dbal:
|
||||||
|
types:
|
||||||
|
uuid: 'Ramsey\Uuid\Doctrine\UuidType'
|
|
@ -27,7 +27,7 @@ security:
|
||||||
|
|
||||||
access_control:
|
access_control:
|
||||||
- { path: ^/$, roles: PUBLIC_ACCESS } # Allows accessing the Swagger UI
|
- { path: ^/$, roles: PUBLIC_ACCESS } # Allows accessing the Swagger UI
|
||||||
- { path: ^/api/docs, roles: PUBLIC_ACCESS } # Allows accessing the Swagger UI docs
|
- { path: ^/docs, roles: PUBLIC_ACCESS } # Allows accessing the Swagger UI docs
|
||||||
- { path: ^/auth/login, roles: PUBLIC_ACCESS }
|
- { path: ^/auth/login, roles: PUBLIC_ACCESS }
|
||||||
- { path: ^/auth/refresh, roles: PUBLIC_ACCESS }
|
- { path: ^/auth/refresh, roles: PUBLIC_ACCESS }
|
||||||
- { path: ^/, roles: IS_AUTHENTICATED_FULLY }
|
- { path: ^/, roles: IS_AUTHENTICATED_FULLY }
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
stof_doctrine_extensions:
|
||||||
|
default_locale: es_ES
|
||||||
|
orm:
|
||||||
|
default:
|
||||||
|
timestampable: true
|
||||||
|
blameable: true
|
||||||
|
tree: true
|
||||||
|
sluggable: true
|
|
@ -1,4 +1,3 @@
|
||||||
api_platform:
|
api_platform:
|
||||||
resource: .
|
resource: .
|
||||||
type: api_platform
|
type: api_platform
|
||||||
prefix: /api
|
|
||||||
|
|
|
@ -24,3 +24,18 @@ services:
|
||||||
decorates: 'api_platform.openapi.factory'
|
decorates: 'api_platform.openapi.factory'
|
||||||
arguments: [ '@App\OpenApi\OpenApiFactory.inner' ]
|
arguments: [ '@App\OpenApi\OpenApiFactory.inner' ]
|
||||||
autoconfigure: false
|
autoconfigure: false
|
||||||
|
|
||||||
|
App\State\Provider\UserProvider:
|
||||||
|
bind:
|
||||||
|
$collectionProvider: '@api_platform.doctrine.orm.state.collection_provider'
|
||||||
|
$itemProvider: '@api_platform.doctrine.orm.state.item_provider'
|
||||||
|
|
||||||
|
App\State\Provider\UserGroupProvider:
|
||||||
|
bind:
|
||||||
|
$collectionProvider: '@api_platform.doctrine.orm.state.collection_provider'
|
||||||
|
$itemProvider: '@api_platform.doctrine.orm.state.item_provider'
|
||||||
|
|
||||||
|
App\State\Provider\OrganizationalUnitProvider:
|
||||||
|
bind:
|
||||||
|
$collectionProvider: '@api_platform.doctrine.orm.state.collection_provider'
|
||||||
|
$itemProvider: '@api_platform.doctrine.orm.state.item_provider'
|
|
@ -0,0 +1,40 @@
|
||||||
|
services:
|
||||||
|
api_platform.filter.user.order:
|
||||||
|
parent: 'api_platform.doctrine.orm.order_filter'
|
||||||
|
arguments:
|
||||||
|
$properties: { 'id' : ~, 'username': ~ }
|
||||||
|
$orderParameterName: 'order'
|
||||||
|
tags:
|
||||||
|
- ['api_platform.filter' ]
|
||||||
|
|
||||||
|
api_platform.filter.user.search:
|
||||||
|
parent: 'api_platform.doctrine.orm.search_filter'
|
||||||
|
arguments: [ { 'id': 'exact', 'username': 'partial' }]
|
||||||
|
tags:
|
||||||
|
- ['api_platform.filter' ]
|
||||||
|
|
||||||
|
api_platform.filter.user.boolean:
|
||||||
|
parent: 'api_platform.doctrine.orm.boolean_filter'
|
||||||
|
arguments: [ { 'enabled': ~ } ]
|
||||||
|
tags:
|
||||||
|
- [ 'api_platform.filter' ]
|
||||||
|
|
||||||
|
api_platform.filter.user_group.order:
|
||||||
|
parent: 'api_platform.doctrine.orm.order_filter'
|
||||||
|
arguments:
|
||||||
|
$properties: { 'id': ~, 'name': ~ }
|
||||||
|
$orderParameterName: 'order'
|
||||||
|
tags:
|
||||||
|
- [ 'api_platform.filter' ]
|
||||||
|
|
||||||
|
api_platform.filter.user_group.search:
|
||||||
|
parent: 'api_platform.doctrine.orm.search_filter'
|
||||||
|
arguments: [ { 'id': 'exact', 'name': 'partial' } ]
|
||||||
|
tags:
|
||||||
|
- [ 'api_platform.filter' ]
|
||||||
|
|
||||||
|
api_platform.filter.user_group.boolean:
|
||||||
|
parent: 'api_platform.doctrine.orm.boolean_filter'
|
||||||
|
arguments: [ { 'enabled': ~ } ]
|
||||||
|
tags:
|
||||||
|
- [ 'api_platform.filter' ]
|
|
@ -18,8 +18,3 @@ RUN apk add --no-cache bash git jq moreutils openssh rsync yq
|
||||||
ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
|
ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
|
||||||
RUN chmod +x /usr/local/bin/install-php-extensions
|
RUN chmod +x /usr/local/bin/install-php-extensions
|
||||||
RUN install-php-extensions sockets
|
RUN install-php-extensions sockets
|
||||||
|
|
||||||
# Install Symfony binary
|
|
||||||
RUN apk add --no-cache bash \
|
|
||||||
&& curl -1sLf 'https://dl.cloudsmith.io/public/symfony/stable/setup.alpine.sh' | bash \
|
|
||||||
&& apk add symfony-cli
|
|
||||||
|
|
|
@ -1,31 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace DoctrineMigrations;
|
|
||||||
|
|
||||||
use Doctrine\DBAL\Schema\Schema;
|
|
||||||
use Doctrine\Migrations\AbstractMigration;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Auto-generated Migration: Please modify to your needs!
|
|
||||||
*/
|
|
||||||
final class Version20240517085550 extends AbstractMigration
|
|
||||||
{
|
|
||||||
public function getDescription(): string
|
|
||||||
{
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function up(Schema $schema): void
|
|
||||||
{
|
|
||||||
// this up() migration is auto-generated, please modify it to your needs
|
|
||||||
$this->addSql('CREATE TABLE user (id INT AUTO_INCREMENT NOT NULL, username VARCHAR(180) NOT NULL, roles JSON NOT NULL COMMENT \'(DC2Type:json)\', password VARCHAR(255) NOT NULL, UNIQUE INDEX UNIQ_IDENTIFIER_USERNAME (username), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function down(Schema $schema): void
|
|
||||||
{
|
|
||||||
// this down() migration is auto-generated, please modify it to your needs
|
|
||||||
$this->addSql('DROP TABLE user');
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,31 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace DoctrineMigrations;
|
|
||||||
|
|
||||||
use Doctrine\DBAL\Schema\Schema;
|
|
||||||
use Doctrine\Migrations\AbstractMigration;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Auto-generated Migration: Please modify to your needs!
|
|
||||||
*/
|
|
||||||
final class Version20240517101651 extends AbstractMigration
|
|
||||||
{
|
|
||||||
public function getDescription(): string
|
|
||||||
{
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function up(Schema $schema): void
|
|
||||||
{
|
|
||||||
// this up() migration is auto-generated, please modify it to your needs
|
|
||||||
$this->addSql('CREATE TABLE refresh_tokens (id INT AUTO_INCREMENT NOT NULL, refresh_token VARCHAR(128) NOT NULL, username VARCHAR(255) NOT NULL, valid DATETIME NOT NULL, UNIQUE INDEX UNIQ_9BACE7E1C74F2195 (refresh_token), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function down(Schema $schema): void
|
|
||||||
{
|
|
||||||
// this down() migration is auto-generated, please modify it to your needs
|
|
||||||
$this->addSql('DROP TABLE refresh_tokens');
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,67 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace DoctrineMigrations;
|
||||||
|
|
||||||
|
use Doctrine\DBAL\Schema\Schema;
|
||||||
|
use Doctrine\Migrations\AbstractMigration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Auto-generated Migration: Please modify to your needs!
|
||||||
|
*/
|
||||||
|
final class Version20240528093352 extends AbstractMigration
|
||||||
|
{
|
||||||
|
public function getDescription(): string
|
||||||
|
{
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function up(Schema $schema): void
|
||||||
|
{
|
||||||
|
// this up() migration is auto-generated, please modify it to your needs
|
||||||
|
$this->addSql('CREATE TABLE aulas (idaula INT AUTO_INCREMENT NOT NULL, nombreaula VARCHAR(255) NOT NULL, idcentro INT NOT NULL, urlfoto VARCHAR(255) NOT NULL, cagnon TINYINT(1) NOT NULL, pizarra TINYINT(1) NOT NULL, grupoid INT NOT NULL, ubicacion VARCHAR(255) NOT NULL, comentarios VARCHAR(255) NOT NULL, puestos INT NOT NULL, horaresevini TINYINT(1) NOT NULL, horaresevfin TINYINT(1) NOT NULL, modomul TINYINT(1) NOT NULL, ipmul VARCHAR(255) NOT NULL, pormul VARCHAR(255) NOT NULL, velmul VARCHAR(255) NOT NULL, router VARCHAR(255) NOT NULL, netmask VARCHAR(255) NOT NULL, dns VARCHAR(255) NOT NULL, proxy VARCHAR(255) NOT NULL, ntp VARCHAR(255) NOT NULL, modp2p VARCHAR(255) NOT NULL, timep2p VARCHAR(255) NOT NULL, validacion TINYINT(1) NOT NULL, paginalogin VARCHAR(255) NOT NULL, paginavalidacion VARCHAR(255) NOT NULL, inremotepc VARCHAR(255) NOT NULL, oglivedir VARCHAR(255) NOT NULL, PRIMARY KEY(idaula)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
|
||||||
|
$this->addSql('CREATE TABLE centros (idcentro INT AUTO_INCREMENT NOT NULL, nombrecentro VARCHAR(255) NOT NULL, identidad INT NOT NULL, comentarios VARCHAR(255) DEFAULT NULL, directorio VARCHAR(255) DEFAULT NULL, PRIMARY KEY(idcentro)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
|
||||||
|
$this->addSql('CREATE TABLE client (id INT AUTO_INCREMENT NOT NULL, organizational_unit_id INT DEFAULT NULL, uuid CHAR(36) NOT NULL COMMENT \'(DC2Type:uuid)\', migration_id VARCHAR(255) DEFAULT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, created_by VARCHAR(255) DEFAULT NULL, updated_by VARCHAR(255) DEFAULT NULL, name VARCHAR(255) DEFAULT NULL, serial_number VARCHAR(255) DEFAULT NULL, netiface VARCHAR(255) DEFAULT NULL, net_driver VARCHAR(255) DEFAULT NULL, mac VARCHAR(255) DEFAULT NULL, ip VARCHAR(255) DEFAULT NULL, status VARCHAR(255) DEFAULT NULL, UNIQUE INDEX UNIQ_C7440455D17F50A6 (uuid), INDEX IDX_C7440455FB84408A (organizational_unit_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
|
||||||
|
$this->addSql('CREATE TABLE gruposordenadores (idgrupo INT AUTO_INCREMENT NOT NULL, nombregrupoordenador VARCHAR(255) NOT NULL, idaula VARCHAR(255) NOT NULL, grupoid VARCHAR(255) NOT NULL, comentarios VARCHAR(255) NOT NULL, PRIMARY KEY(idgrupo)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
|
||||||
|
$this->addSql('CREATE TABLE network_settings (id INT AUTO_INCREMENT NOT NULL, uuid CHAR(36) NOT NULL COMMENT \'(DC2Type:uuid)\', migration_id VARCHAR(255) DEFAULT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, created_by VARCHAR(255) DEFAULT NULL, updated_by VARCHAR(255) DEFAULT NULL, proxy VARCHAR(255) DEFAULT NULL, dns VARCHAR(255) DEFAULT NULL, netmask VARCHAR(255) DEFAULT NULL, router VARCHAR(255) DEFAULT NULL, ntp VARCHAR(255) DEFAULT NULL, p2p_time INT DEFAULT NULL, p2p_mode VARCHAR(255) DEFAULT NULL, mcast_ip VARCHAR(255) DEFAULT NULL, mcast_speed INT NOT NULL, mcast_mode VARCHAR(255) DEFAULT NULL, mcast_port INT DEFAULT NULL, UNIQUE INDEX UNIQ_48869B54D17F50A6 (uuid), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
|
||||||
|
$this->addSql('CREATE TABLE ordenadores (idordenador INT AUTO_INCREMENT NOT NULL, PRIMARY KEY(idordenador)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
|
||||||
|
$this->addSql('CREATE TABLE organizational_unit (id INT AUTO_INCREMENT NOT NULL, parent_id INT DEFAULT NULL, network_settings_id INT DEFAULT NULL, uuid CHAR(36) NOT NULL COMMENT \'(DC2Type:uuid)\', migration_id VARCHAR(255) DEFAULT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, created_by VARCHAR(255) DEFAULT NULL, updated_by VARCHAR(255) DEFAULT NULL, description VARCHAR(255) DEFAULT NULL, comments VARCHAR(255) DEFAULT NULL, path VARCHAR(255) DEFAULT NULL, level INT DEFAULT NULL, slug VARCHAR(255) DEFAULT NULL, name VARCHAR(255) NOT NULL, UNIQUE INDEX UNIQ_749AEB2DD17F50A6 (uuid), INDEX IDX_749AEB2D727ACA70 (parent_id), INDEX IDX_749AEB2D9B9A36D0 (network_settings_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
|
||||||
|
$this->addSql('CREATE TABLE refresh_tokens (id INT AUTO_INCREMENT NOT NULL, refresh_token VARCHAR(128) NOT NULL, username VARCHAR(255) NOT NULL, valid DATETIME NOT NULL, UNIQUE INDEX UNIQ_9BACE7E1C74F2195 (refresh_token), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
|
||||||
|
$this->addSql('CREATE TABLE user (id INT AUTO_INCREMENT NOT NULL, uuid CHAR(36) NOT NULL COMMENT \'(DC2Type:uuid)\', migration_id VARCHAR(255) DEFAULT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, created_by VARCHAR(255) DEFAULT NULL, updated_by VARCHAR(255) DEFAULT NULL, username VARCHAR(180) NOT NULL, roles JSON NOT NULL COMMENT \'(DC2Type:json)\', password VARCHAR(255) NOT NULL, enabled TINYINT(1) NOT NULL, UNIQUE INDEX UNIQ_8D93D649D17F50A6 (uuid), UNIQUE INDEX UNIQ_IDENTIFIER_USERNAME (username), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
|
||||||
|
$this->addSql('CREATE TABLE user_organizational_unit (user_id INT NOT NULL, organizational_unit_id INT NOT NULL, INDEX IDX_5E59845FA76ED395 (user_id), INDEX IDX_5E59845FFB84408A (organizational_unit_id), PRIMARY KEY(user_id, organizational_unit_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
|
||||||
|
$this->addSql('CREATE TABLE user_group (id INT AUTO_INCREMENT NOT NULL, uuid CHAR(36) NOT NULL COMMENT \'(DC2Type:uuid)\', migration_id VARCHAR(255) DEFAULT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, created_by VARCHAR(255) DEFAULT NULL, updated_by VARCHAR(255) DEFAULT NULL, permissions JSON NOT NULL COMMENT \'(DC2Type:json)\', name VARCHAR(255) NOT NULL, enabled TINYINT(1) NOT NULL, UNIQUE INDEX UNIQ_8F02BF9DD17F50A6 (uuid), UNIQUE INDEX UNIQ_IDENTIFIER_NAME (name), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
|
||||||
|
$this->addSql('CREATE TABLE user_group_user (user_group_id INT NOT NULL, user_id INT NOT NULL, INDEX IDX_3AE4BD51ED93D47 (user_group_id), INDEX IDX_3AE4BD5A76ED395 (user_id), PRIMARY KEY(user_group_id, user_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
|
||||||
|
$this->addSql('ALTER TABLE client ADD CONSTRAINT FK_C7440455FB84408A FOREIGN KEY (organizational_unit_id) REFERENCES organizational_unit (id)');
|
||||||
|
$this->addSql('ALTER TABLE organizational_unit ADD CONSTRAINT FK_749AEB2D727ACA70 FOREIGN KEY (parent_id) REFERENCES organizational_unit (id)');
|
||||||
|
$this->addSql('ALTER TABLE organizational_unit ADD CONSTRAINT FK_749AEB2D9B9A36D0 FOREIGN KEY (network_settings_id) REFERENCES network_settings (id)');
|
||||||
|
$this->addSql('ALTER TABLE user_organizational_unit ADD CONSTRAINT FK_5E59845FA76ED395 FOREIGN KEY (user_id) REFERENCES user (id) ON DELETE CASCADE');
|
||||||
|
$this->addSql('ALTER TABLE user_organizational_unit ADD CONSTRAINT FK_5E59845FFB84408A FOREIGN KEY (organizational_unit_id) REFERENCES organizational_unit (id) ON DELETE CASCADE');
|
||||||
|
$this->addSql('ALTER TABLE user_group_user ADD CONSTRAINT FK_3AE4BD51ED93D47 FOREIGN KEY (user_group_id) REFERENCES user_group (id) ON DELETE CASCADE');
|
||||||
|
$this->addSql('ALTER TABLE user_group_user ADD CONSTRAINT FK_3AE4BD5A76ED395 FOREIGN KEY (user_id) REFERENCES user (id) ON DELETE CASCADE');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(Schema $schema): void
|
||||||
|
{
|
||||||
|
// this down() migration is auto-generated, please modify it to your needs
|
||||||
|
$this->addSql('ALTER TABLE client DROP FOREIGN KEY FK_C7440455FB84408A');
|
||||||
|
$this->addSql('ALTER TABLE organizational_unit DROP FOREIGN KEY FK_749AEB2D727ACA70');
|
||||||
|
$this->addSql('ALTER TABLE organizational_unit DROP FOREIGN KEY FK_749AEB2D9B9A36D0');
|
||||||
|
$this->addSql('ALTER TABLE user_organizational_unit DROP FOREIGN KEY FK_5E59845FA76ED395');
|
||||||
|
$this->addSql('ALTER TABLE user_organizational_unit DROP FOREIGN KEY FK_5E59845FFB84408A');
|
||||||
|
$this->addSql('ALTER TABLE user_group_user DROP FOREIGN KEY FK_3AE4BD51ED93D47');
|
||||||
|
$this->addSql('ALTER TABLE user_group_user DROP FOREIGN KEY FK_3AE4BD5A76ED395');
|
||||||
|
$this->addSql('DROP TABLE aulas');
|
||||||
|
$this->addSql('DROP TABLE centros');
|
||||||
|
$this->addSql('DROP TABLE client');
|
||||||
|
$this->addSql('DROP TABLE gruposordenadores');
|
||||||
|
$this->addSql('DROP TABLE network_settings');
|
||||||
|
$this->addSql('DROP TABLE ordenadores');
|
||||||
|
$this->addSql('DROP TABLE organizational_unit');
|
||||||
|
$this->addSql('DROP TABLE refresh_tokens');
|
||||||
|
$this->addSql('DROP TABLE user');
|
||||||
|
$this->addSql('DROP TABLE user_organizational_unit');
|
||||||
|
$this->addSql('DROP TABLE user_group');
|
||||||
|
$this->addSql('DROP TABLE user_group_user');
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,34 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace DoctrineMigrations;
|
||||||
|
|
||||||
|
use Doctrine\DBAL\Schema\Schema;
|
||||||
|
use Doctrine\Migrations\AbstractMigration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Auto-generated Migration: Please modify to your needs!
|
||||||
|
*/
|
||||||
|
final class Version20240529131520 extends AbstractMigration
|
||||||
|
{
|
||||||
|
public function getDescription(): string
|
||||||
|
{
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function up(Schema $schema): void
|
||||||
|
{
|
||||||
|
// this up() migration is auto-generated, please modify it to your needs
|
||||||
|
|
||||||
|
$this->addSql('ALTER TABLE organizational_unit DROP FOREIGN KEY FK_749AEB2D727ACA70');
|
||||||
|
$this->addSql('ALTER TABLE organizational_unit ADD CONSTRAINT FK_749AEB2D727ACA70 FOREIGN KEY (parent_id) REFERENCES organizational_unit (id) ON DELETE SET NULL');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(Schema $schema): void
|
||||||
|
{
|
||||||
|
// this down() migration is auto-generated, please modify it to your needs
|
||||||
|
$this->addSql('ALTER TABLE organizational_unit DROP FOREIGN KEY FK_749AEB2D727ACA70');
|
||||||
|
$this->addSql('ALTER TABLE organizational_unit ADD CONSTRAINT FK_749AEB2D727ACA70 FOREIGN KEY (parent_id) REFERENCES organizational_unit (id)');
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,39 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<!-- https://phpunit.readthedocs.io/en/latest/configuration.html -->
|
||||||
|
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
|
||||||
|
backupGlobals="false"
|
||||||
|
colors="true"
|
||||||
|
bootstrap="tests/bootstrap.php"
|
||||||
|
convertDeprecationsToExceptions="false"
|
||||||
|
>
|
||||||
|
<php>
|
||||||
|
<ini name="display_errors" value="1" />
|
||||||
|
<ini name="error_reporting" value="-1" />
|
||||||
|
<server name="APP_ENV" value="test" force="true" />
|
||||||
|
<server name="SHELL_VERBOSITY" value="-1" />
|
||||||
|
<server name="SYMFONY_PHPUNIT_REMOVE" value="" />
|
||||||
|
<server name="SYMFONY_PHPUNIT_VERSION" value="9.6" />
|
||||||
|
</php>
|
||||||
|
|
||||||
|
<testsuites>
|
||||||
|
<testsuite name="Project Test Suite">
|
||||||
|
<directory>tests</directory>
|
||||||
|
</testsuite>
|
||||||
|
</testsuites>
|
||||||
|
|
||||||
|
<coverage processUncoveredFiles="true">
|
||||||
|
<include>
|
||||||
|
<directory suffix=".php">src</directory>
|
||||||
|
</include>
|
||||||
|
</coverage>
|
||||||
|
|
||||||
|
<listeners>
|
||||||
|
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener" />
|
||||||
|
</listeners>
|
||||||
|
|
||||||
|
<extensions>
|
||||||
|
<extension class="DAMA\DoctrineTestBundle\PHPUnit\PHPUnitExtension"/>
|
||||||
|
</extensions>
|
||||||
|
</phpunit>
|
|
@ -0,0 +1,59 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Command;
|
||||||
|
|
||||||
|
use App\Entity\UserGroup;
|
||||||
|
use App\Model\UserGroupPermissions;
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
use Symfony\Component\Console\Command\Command;
|
||||||
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
|
||||||
|
class LoadDefaultUserGroupsCommand extends Command
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
private readonly EntityManagerInterface $entityManager,
|
||||||
|
)
|
||||||
|
{
|
||||||
|
parent::__construct('app:load-default-user-groups');
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||||
|
{
|
||||||
|
$userGroups = [
|
||||||
|
[
|
||||||
|
'name' => 'Super Admin',
|
||||||
|
'permissions' => [UserGroupPermissions::ROLE_SUPER_ADMIN],
|
||||||
|
'enabled' => true
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'name' => 'Administrador de aulas',
|
||||||
|
'permissions' => [UserGroupPermissions::ROLE_ORGANIZATIONAL_UNIT_ADMIN],
|
||||||
|
'enabled' => true
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'name' => 'Operador de aulas',
|
||||||
|
'permissions' => [UserGroupPermissions::ROLE_ORGANIZATIONAL_UNIT_OPERATOR],
|
||||||
|
'enabled' => true
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'name' => 'Usuario básico de aulas',
|
||||||
|
'permissions' => [UserGroupPermissions::ROLE_ORGANIZATIONAL_UNIT_MINIMAL],
|
||||||
|
'enabled' => true
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach ($userGroups as $userGroup) {
|
||||||
|
$entity = new UserGroup();
|
||||||
|
$entity->setName($userGroup['name']);
|
||||||
|
$entity->setPermissions($userGroup['permissions']);
|
||||||
|
$entity->setEnabled($userGroup['enabled']);
|
||||||
|
|
||||||
|
$this->entityManager->persist($entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->entityManager->flush();
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,152 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Command\Migration;
|
||||||
|
|
||||||
|
use App\Entity\Client;
|
||||||
|
use App\Entity\Migration\Aulas;
|
||||||
|
use App\Entity\Migration\Centros;
|
||||||
|
use App\Entity\Migration\Gruposordenadores;
|
||||||
|
use App\Entity\Migration\Ordenadores;
|
||||||
|
use App\Entity\NetworkSettings;
|
||||||
|
use App\Entity\OrganizationalUnit;
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
use Symfony\Component\Console\Attribute\AsCommand;
|
||||||
|
use Symfony\Component\Console\Command\Command;
|
||||||
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
|
||||||
|
#[AsCommand(name: 'opengnsys:migration:organizational-unit', description: 'Migration data to new entities')]
|
||||||
|
class MigrateOrganizationalUnitCommand extends Command
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
private readonly EntityManagerInterface $entityManager,
|
||||||
|
private readonly EntityManagerInterface $entityManagerSlave
|
||||||
|
)
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||||
|
{
|
||||||
|
$centers = $this->entityManagerSlave->getRepository(Centros::class)->findAll();
|
||||||
|
$rooms = $this->entityManagerSlave->getRepository(Aulas::class)->findAll();
|
||||||
|
$pcGroups = $this->entityManagerSlave->getRepository(Gruposordenadores::class)->findAll();
|
||||||
|
$pcs = $this->entityManagerSlave->getRepository(Ordenadores::class)->findAll();
|
||||||
|
|
||||||
|
$organizationalUnitRepository = $this->entityManager->getRepository(OrganizationalUnit::class);
|
||||||
|
$clientRepository = $this->entityManager->getRepository(Client::class);
|
||||||
|
|
||||||
|
/** Centros **/
|
||||||
|
$output->writeln("CENTROS TOTAL: ". count($centers));
|
||||||
|
foreach ($centers as $center){
|
||||||
|
$centerOrganizationalUnit = null;
|
||||||
|
$centerOrganizationalUnit = $organizationalUnitRepository->findOneBy(['migrationId' => $center->getIdcentro()]);
|
||||||
|
if(!$centerOrganizationalUnit){
|
||||||
|
$centerOrganizationalUnit = new OrganizationalUnit();
|
||||||
|
$centerOrganizationalUnit->setMigrationId($center->getIdcentro());
|
||||||
|
$centerOrganizationalUnit->setName($center->getNombrecentro());
|
||||||
|
$centerOrganizationalUnit->setComments($center->getComentarios());
|
||||||
|
$this->entityManager->persist($centerOrganizationalUnit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$this->entityManager->flush();
|
||||||
|
|
||||||
|
/** Aulas **/
|
||||||
|
$output->writeln("AULAS TOTAL: ". count($rooms));
|
||||||
|
foreach ($rooms as $room){
|
||||||
|
$roomOrganizationalUnit = null;
|
||||||
|
$roomOrganizationalUnit = $organizationalUnitRepository->findOneBy(['migrationId' => $room->getIdaula()]);
|
||||||
|
if(!$roomOrganizationalUnit){
|
||||||
|
$roomOrganizationalUnit = new OrganizationalUnit();
|
||||||
|
$roomOrganizationalUnit->setMigrationId($room->getIdaula());
|
||||||
|
$roomOrganizationalUnit->setName($room->getNombreaula());
|
||||||
|
$roomOrganizationalUnitParent = $organizationalUnitRepository->findOneBy(['migrationId' => $room->getIdcentro()]);
|
||||||
|
$roomOrganizationalUnit->setParent($roomOrganizationalUnitParent);
|
||||||
|
$this->entityManager->persist($roomOrganizationalUnit);
|
||||||
|
}
|
||||||
|
|
||||||
|
$networkSettings = $roomOrganizationalUnit->getNetworkSettings();
|
||||||
|
if(!$networkSettings){
|
||||||
|
$networkSettings = new NetworkSettings();
|
||||||
|
$roomOrganizationalUnit->setNetworkSettings($networkSettings);
|
||||||
|
$this->entityManager->persist($networkSettings);
|
||||||
|
}
|
||||||
|
$networkSettings->setProxy($room->getProxy());
|
||||||
|
$networkSettings->setDns($room->getDns());
|
||||||
|
$networkSettings->setNetmask($room->getNetmask());
|
||||||
|
$networkSettings->setRouter($room->getRouter());
|
||||||
|
$networkSettings->setNtp($room->getNtp());
|
||||||
|
$networkSettings->setP2pTime($room->getTimep2p());
|
||||||
|
$networkSettings->setP2pMode($room->getModp2p());
|
||||||
|
$networkSettings->setMcastIp($room->getIpmul());
|
||||||
|
$networkSettings->setMcastSpeed($room->getVelmul());
|
||||||
|
$networkSettings->setMcastPort($room->getPormul());
|
||||||
|
$networkSettings->setMcastMode($room->getModomul());
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->entityManager->flush();
|
||||||
|
|
||||||
|
/** Grupo Ordenador **/
|
||||||
|
$output->writeln("GRUPOS ORDENADORES ". count($rooms));
|
||||||
|
foreach ($pcGroups as $group){
|
||||||
|
$groupPcOrganizationalUnit = null;
|
||||||
|
$migrateParentId = ($group->getGrupoid() == 0) ? $group->getIdaula() : $group->getGrupoid();
|
||||||
|
$groupPcOrganizationalUnit = $organizationalUnitRepository->findOneBy(['migrationId' => $group->getIdgrupo()]);
|
||||||
|
if(!$groupPcOrganizationalUnit){
|
||||||
|
$groupPcOrganizationalUnit = new OrganizationalUnit();
|
||||||
|
$groupPcOrganizationalUnit->setMigrationId($group->getIdgrupo());
|
||||||
|
$groupPcOrganizationalUnit->setName($group->getNombregrupoordenador());
|
||||||
|
$groupPcOrganizationalUnit->setComments($group->getComentarios());
|
||||||
|
$groupPcOrganizationalUnitParent = $organizationalUnitRepository->findOneBy(['migrationId' => $migrateParentId]);
|
||||||
|
$groupPcOrganizationalUnit->setParent($groupPcOrganizationalUnitParent);
|
||||||
|
$this->entityManager->persist($groupPcOrganizationalUnit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$this->entityManager->flush();
|
||||||
|
|
||||||
|
/** Ordenadores **/
|
||||||
|
foreach ($pcs as $pc){
|
||||||
|
$newClient = $clientRepository->findOneBy(['migrationId' => $pc->getIdordenador()]);
|
||||||
|
if(!$newClient){
|
||||||
|
$newClient = new Client();
|
||||||
|
$newClient->setMigrationId($pc->getIdordenador());
|
||||||
|
$this->entityManager->persist($newClient);
|
||||||
|
}
|
||||||
|
$newClient->setName($pc->getNombreordenador());
|
||||||
|
$newClient->setSerialNumber($pc->getNumserie());
|
||||||
|
$newClient->setNetiface($pc->getNetiface());
|
||||||
|
$newClient->setNetdriver($pc->getNetdriver());
|
||||||
|
$newClient->setMac($pc->getMac());
|
||||||
|
$newClient->setIp($pc->getIp());
|
||||||
|
//$client->setStatus();
|
||||||
|
//$newClient->setCache($pc->getCache());
|
||||||
|
//$newClient->setIdproautoexec($pc->getIdproautoexec());
|
||||||
|
//$newClient->setOglive($pc->getOglivedir());
|
||||||
|
|
||||||
|
// Netboot
|
||||||
|
|
||||||
|
//$migrationId = ""
|
||||||
|
|
||||||
|
// HardwareProfile
|
||||||
|
//$hardwareProfile = $hardwareProfileRepository->findOneBy(['migrationId' => $pc->getIdperfilhard()]);
|
||||||
|
//$newClient->setHardwareProfile($hardwareProfile);
|
||||||
|
|
||||||
|
// Menu
|
||||||
|
//$menu = $menuRepository->findOneBy(['migrationId' => $pc->getIdmenu()]);
|
||||||
|
//$newClient->setMenu($menu);
|
||||||
|
|
||||||
|
// Repository
|
||||||
|
//$repository = $repositoryRepository->findOneBy(['migrationId' => $pc->getIdrepositorio()]);
|
||||||
|
//$newClient->setRepository($repository);
|
||||||
|
|
||||||
|
// OrganizationalUnit
|
||||||
|
$migrationId = $pc->getGrupoid() == 0 ? $pc->getIdaula() : $pc->getGrupoid();
|
||||||
|
$organizationalUnit = $organizationalUnitRepository->findOneBy(['migrationId' => $migrationId]);
|
||||||
|
$newClient->setOrganizationalUnit($organizationalUnit);
|
||||||
|
|
||||||
|
}
|
||||||
|
$this->entityManager->flush();
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,7 +2,10 @@
|
||||||
|
|
||||||
namespace App\DataFixtures;
|
namespace App\DataFixtures;
|
||||||
|
|
||||||
|
use App\Entity\OrganizationalUnit;
|
||||||
|
use App\Factory\OrganizationalUnitFactory;
|
||||||
use App\Factory\UserFactory;
|
use App\Factory\UserFactory;
|
||||||
|
use App\Model\UserGroupPermissions;
|
||||||
use Doctrine\Bundle\FixturesBundle\Fixture;
|
use Doctrine\Bundle\FixturesBundle\Fixture;
|
||||||
use Doctrine\Persistence\ObjectManager;
|
use Doctrine\Persistence\ObjectManager;
|
||||||
|
|
||||||
|
@ -10,8 +13,22 @@ class AppFixtures extends Fixture
|
||||||
{
|
{
|
||||||
CONST ADMIN_USER = 'ogadmin';
|
CONST ADMIN_USER = 'ogadmin';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws \Exception
|
||||||
|
*/
|
||||||
public function load(ObjectManager $manager): void
|
public function load(ObjectManager $manager): void
|
||||||
{
|
{
|
||||||
UserFactory::createOne(['username' => self::ADMIN_USER]);
|
UserFactory::createOne(['username' => self::ADMIN_USER, 'roles'=> [UserGroupPermissions::ROLE_SUPER_ADMIN]]);
|
||||||
|
$rootUnit = OrganizationalUnitFactory::createOne(['name' => 'Centro de Computación', 'parent' => null]);
|
||||||
|
|
||||||
|
$roomUnit = OrganizationalUnitFactory::createOne([
|
||||||
|
'name' => 'Aula 1',
|
||||||
|
'parent' => $rootUnit
|
||||||
|
]);
|
||||||
|
|
||||||
|
OrganizationalUnitFactory::createOne([
|
||||||
|
'name' => 'Aula 2',
|
||||||
|
'parent' => $roomUnit
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Dto\Input;
|
||||||
|
|
||||||
|
use App\Entity\OrganizationalUnit;
|
||||||
|
use Symfony\Component\Serializer\Annotation\Groups;
|
||||||
|
use Symfony\Component\Validator\Constraints as Assert;
|
||||||
|
|
||||||
|
final class OrganizationalUnitInput
|
||||||
|
{
|
||||||
|
#[Assert\NotBlank]
|
||||||
|
#[Groups(['organizational-unit:write'])]
|
||||||
|
public ?string $name = null;
|
||||||
|
|
||||||
|
public function __construct(?OrganizationalUnit $organizationalUnit = null)
|
||||||
|
{
|
||||||
|
if (!$organizationalUnit) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->name = $organizationalUnit->getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function createOrUpdateEntity(?OrganizationalUnit $organizationalUnit = null): OrganizationalUnit
|
||||||
|
{
|
||||||
|
if (!$organizationalUnit) {
|
||||||
|
$organizationalUnit = new OrganizationalUnit();
|
||||||
|
}
|
||||||
|
|
||||||
|
$organizationalUnit->setName($this->name);
|
||||||
|
|
||||||
|
return $organizationalUnit;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,47 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Dto\Input;
|
||||||
|
|
||||||
|
use App\Entity\UserGroup;
|
||||||
|
use App\Validator\Constraints\UserGroupsValidPermission;
|
||||||
|
use Symfony\Component\Serializer\Annotation\Groups;
|
||||||
|
use Symfony\Component\Validator\Constraints as Assert;
|
||||||
|
|
||||||
|
final class UserGroupInput
|
||||||
|
{
|
||||||
|
#[Assert\NotBlank]
|
||||||
|
#[Groups(['user-group:write'])]
|
||||||
|
public ?string $name = null;
|
||||||
|
|
||||||
|
#[Groups(['user-group:write'])]
|
||||||
|
#[UserGroupsValidPermission]
|
||||||
|
public ?array $permissions = [];
|
||||||
|
|
||||||
|
#[Assert\NotNull]
|
||||||
|
#[Groups(['user-group:write'])]
|
||||||
|
public ?bool $enabled = false;
|
||||||
|
|
||||||
|
public function __construct(?UserGroup $userGroupGroup = null)
|
||||||
|
{
|
||||||
|
if (!$userGroupGroup) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->name = $userGroupGroup->getName();
|
||||||
|
$this->permissions = $userGroupGroup->getPermissions();
|
||||||
|
$this->enabled= $userGroupGroup->isEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function createOrUpdateEntity(?UserGroup $userGroup = null): UserGroup
|
||||||
|
{
|
||||||
|
if (!$userGroup) {
|
||||||
|
$userGroup = new UserGroup();
|
||||||
|
}
|
||||||
|
|
||||||
|
$userGroup->setName($this->name);
|
||||||
|
$userGroup->setPermissions($this->permissions);
|
||||||
|
$userGroup->setEnabled($this->enabled);
|
||||||
|
|
||||||
|
return $userGroup;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,79 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Dto\Input;
|
||||||
|
|
||||||
|
use ApiPlatform\Metadata\ApiProperty;
|
||||||
|
use App\Dto\Output\UserGroupOutput;
|
||||||
|
use App\Entity\OrganizationalUnit;
|
||||||
|
use App\Entity\User;
|
||||||
|
use App\Entity\UserGroup;
|
||||||
|
use Symfony\Component\Serializer\Annotation\Groups;
|
||||||
|
use Symfony\Component\Validator\Constraints as Assert;
|
||||||
|
|
||||||
|
final class UserInput
|
||||||
|
{
|
||||||
|
#[Assert\NotBlank]
|
||||||
|
#[Groups(['user:write'])]
|
||||||
|
public ?string $username = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var OrganizationalUnit[]
|
||||||
|
*/
|
||||||
|
#[Groups(['user:write'])]
|
||||||
|
#[ApiProperty(readableLink: false, writableLink: false)]
|
||||||
|
public array $allowedOrganizationalUnits = [];
|
||||||
|
|
||||||
|
#[Assert\NotBlank(groups: ['user:post'])]
|
||||||
|
#[Assert\Length(min: 8, groups: ['user:write', 'user:post'])]
|
||||||
|
#[Groups(['user:write'])]
|
||||||
|
public ?string $password = null;
|
||||||
|
|
||||||
|
#[Assert\NotNull]
|
||||||
|
#[Groups(['user:write'])]
|
||||||
|
public ?bool $enabled = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var UserGroup[]
|
||||||
|
*/
|
||||||
|
#[Groups(['user:write'])]
|
||||||
|
#[ApiProperty(readableLink: false, writableLink: false)]
|
||||||
|
public array $userGroups = [];
|
||||||
|
|
||||||
|
public function __construct(?User $user = null)
|
||||||
|
{
|
||||||
|
if (!$user) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->username = $user->getUsername();
|
||||||
|
$this->enabled= $user->isEnabled();
|
||||||
|
$this->userGroups = $user->getUserGroups()->toArray();
|
||||||
|
$this->allowedOrganizationalUnits = $user->getAllowedOrganizationalUnits()->toArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function createOrUpdateEntity(?User $user = null): User
|
||||||
|
{
|
||||||
|
if (!$user) {
|
||||||
|
$user = new User();
|
||||||
|
}
|
||||||
|
|
||||||
|
$user->setUsername($this->username);
|
||||||
|
$user->setEnabled($this->enabled);
|
||||||
|
|
||||||
|
foreach ($this->userGroups as $userGroup) {
|
||||||
|
$userGroupsToAdd[] = $userGroup->getEntity();
|
||||||
|
}
|
||||||
|
$user->setUserGroups( $userGroupsToAdd ?? [] );
|
||||||
|
|
||||||
|
if ($this->password !== null) {
|
||||||
|
$user->setPassword($this->password);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($this->allowedOrganizationalUnits as $allowedOrganizationalUnit) {
|
||||||
|
$allowedOrganizationalUnitToAdd[] = $allowedOrganizationalUnit->getEntity();
|
||||||
|
}
|
||||||
|
$user->setAllowedOrganizationalUnits( $allowedOrganizationalUnitToAdd ?? [] );
|
||||||
|
|
||||||
|
return $user;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Dto\Output;
|
||||||
|
|
||||||
|
use ApiPlatform\Metadata\ApiProperty;
|
||||||
|
use App\Entity\AbstractEntity;
|
||||||
|
use Ramsey\Uuid\UuidInterface;
|
||||||
|
use Symfony\Component\Serializer\Annotation\Groups;
|
||||||
|
|
||||||
|
abstract class AbstractOutput
|
||||||
|
{
|
||||||
|
#[ApiProperty(identifier: true)]
|
||||||
|
#[Groups('default')]
|
||||||
|
public UuidInterface $uuid;
|
||||||
|
|
||||||
|
#[ApiProperty(identifier: false)]
|
||||||
|
#[Groups('default')]
|
||||||
|
public int $id;
|
||||||
|
|
||||||
|
public function __construct(private readonly AbstractEntity $entity)
|
||||||
|
{
|
||||||
|
$this->id = $entity->getId();
|
||||||
|
$this->uuid = $entity->getUuid();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[ApiProperty(readable: false)]
|
||||||
|
public function getEntity(): ?AbstractEntity
|
||||||
|
{
|
||||||
|
return $this->entity;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Dto\Output;
|
||||||
|
|
||||||
|
use ApiPlatform\Metadata\Get;
|
||||||
|
use App\Entity\OrganizationalUnit;
|
||||||
|
use Symfony\Component\Serializer\Annotation\Groups;
|
||||||
|
|
||||||
|
#[Get(shortName: 'OrganizationalUnit')]
|
||||||
|
final class OrganizationalUnitOutput extends AbstractOutput
|
||||||
|
{
|
||||||
|
#[Groups(['organizational-unit:read'])]
|
||||||
|
public string $name;
|
||||||
|
|
||||||
|
#[Groups(['organizational-unit:read'])]
|
||||||
|
public \DateTime $createAt;
|
||||||
|
|
||||||
|
#[Groups(['organizational-unit:read'])]
|
||||||
|
public ?string $createBy = null;
|
||||||
|
|
||||||
|
public function __construct(OrganizationalUnit $organizationalUnit)
|
||||||
|
{
|
||||||
|
parent::__construct($organizationalUnit);
|
||||||
|
|
||||||
|
$this->name = $organizationalUnit->getName();
|
||||||
|
$this->createAt = $organizationalUnit->getCreatedAt();
|
||||||
|
$this->createBy = $organizationalUnit->getCreatedBy();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,38 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Dto\Output;
|
||||||
|
|
||||||
|
use ApiPlatform\Metadata\Get;
|
||||||
|
use App\Entity\User;
|
||||||
|
use App\Entity\UserGroup;
|
||||||
|
use Symfony\Component\Serializer\Annotation\Groups;
|
||||||
|
|
||||||
|
#[Get(shortName: 'UserGroup')]
|
||||||
|
final class UserGroupOutput extends AbstractOutput
|
||||||
|
{
|
||||||
|
#[Groups(['user-group:read'])]
|
||||||
|
public string $name;
|
||||||
|
|
||||||
|
#[Groups(['user-group:read'])]
|
||||||
|
public array $permissions;
|
||||||
|
|
||||||
|
#[Groups(['user-group:read'])]
|
||||||
|
public bool $enabled;
|
||||||
|
|
||||||
|
#[Groups(['user-group:read'])]
|
||||||
|
public \DateTime $createAt;
|
||||||
|
|
||||||
|
#[Groups(['user-group:read'])]
|
||||||
|
public ?string $createBy = null;
|
||||||
|
|
||||||
|
public function __construct(UserGroup $userGroup)
|
||||||
|
{
|
||||||
|
parent::__construct($userGroup);
|
||||||
|
|
||||||
|
$this->name = $userGroup->getName();
|
||||||
|
$this->permissions = $userGroup->getPermissions();
|
||||||
|
$this->enabled = $userGroup->isEnabled();
|
||||||
|
$this->createAt = $userGroup->getCreatedAt();
|
||||||
|
$this->createBy = $userGroup->getCreatedBy();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,43 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Dto\Output;
|
||||||
|
|
||||||
|
use ApiPlatform\Metadata\Get;
|
||||||
|
use App\Entity\User;
|
||||||
|
use Symfony\Component\Serializer\Annotation\Groups;
|
||||||
|
|
||||||
|
#[Get(shortName: 'User')]
|
||||||
|
final class UserOutput extends AbstractOutput
|
||||||
|
{
|
||||||
|
#[Groups(['user:read'])]
|
||||||
|
public string $username;
|
||||||
|
|
||||||
|
#[Groups(['user:read'])]
|
||||||
|
public array $roles;
|
||||||
|
|
||||||
|
#[Groups(['user:read'])]
|
||||||
|
public bool $enabled;
|
||||||
|
#[Groups(['user:read'])]
|
||||||
|
public array $allowedOrganizationalUnits;
|
||||||
|
#[Groups(['user:read'])]
|
||||||
|
public array $userGroups;
|
||||||
|
|
||||||
|
#[Groups(['user:read'])]
|
||||||
|
public \DateTime $createAt;
|
||||||
|
|
||||||
|
#[Groups(['user:read'])]
|
||||||
|
public ?string $createBy = null;
|
||||||
|
|
||||||
|
public function __construct(User $user)
|
||||||
|
{
|
||||||
|
parent::__construct($user);
|
||||||
|
|
||||||
|
$this->username = $user->getUsername();
|
||||||
|
$this->roles = $user->getRoles();
|
||||||
|
$this->enabled = $user->isEnabled();
|
||||||
|
$this->userGroups = $user->getUserGroups()->toArray();
|
||||||
|
$this->allowedOrganizationalUnits = $user->getAllowedOrganizationalUnits()->toArray();
|
||||||
|
$this->createAt = $user->getCreatedAt();
|
||||||
|
$this->createBy = $user->getCreatedBy();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,55 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Entity;
|
||||||
|
|
||||||
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
use Gedmo\Blameable\Traits\BlameableEntity;
|
||||||
|
use Gedmo\Timestampable\Traits\TimestampableEntity;
|
||||||
|
use Ramsey\Uuid\Uuid;
|
||||||
|
use Ramsey\Uuid\UuidInterface;
|
||||||
|
use Symfony\Bridge\Doctrine\Types\UuidType;
|
||||||
|
|
||||||
|
#[ORM\MappedSuperclass]
|
||||||
|
abstract class AbstractEntity
|
||||||
|
{
|
||||||
|
use TimestampableEntity;
|
||||||
|
use BlameableEntity;
|
||||||
|
|
||||||
|
#[ORM\Id]
|
||||||
|
#[ORM\GeneratedValue]
|
||||||
|
#[ORM\Column]
|
||||||
|
protected ?int $id = null;
|
||||||
|
|
||||||
|
#[ORM\Column(type: UuidType::NAME, unique: true)]
|
||||||
|
protected UuidInterface $uuid;
|
||||||
|
|
||||||
|
#[ORM\Column(length: 255, nullable: true)]
|
||||||
|
protected ?string $migrationId = '';
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->uuid = Uuid::uuid7();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getId(): ?int
|
||||||
|
{
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getUuid(): UuidInterface
|
||||||
|
{
|
||||||
|
return $this->uuid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getMigrationId(): ?string
|
||||||
|
{
|
||||||
|
return $this->migrationId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setMigrationId(?string $migrationId): self
|
||||||
|
{
|
||||||
|
$this->migrationId = $migrationId;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,131 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Entity;
|
||||||
|
|
||||||
|
use App\Repository\ClientRepository;
|
||||||
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
|
||||||
|
#[ORM\Entity(repositoryClass: ClientRepository::class)]
|
||||||
|
class Client extends AbstractEntity
|
||||||
|
{
|
||||||
|
#[ORM\Column(length: 255, nullable: true)]
|
||||||
|
private ?string $name = null;
|
||||||
|
|
||||||
|
#[ORM\Column(length: 255, nullable: true)]
|
||||||
|
private ?string $serialNumber = null;
|
||||||
|
|
||||||
|
#[ORM\Column(length: 255, nullable: true)]
|
||||||
|
private ?string $netiface = null;
|
||||||
|
|
||||||
|
#[ORM\Column(length: 255, nullable: true)]
|
||||||
|
private ?string $netDriver = null;
|
||||||
|
|
||||||
|
#[ORM\Column(length: 255, nullable: true)]
|
||||||
|
private ?string $mac = null;
|
||||||
|
|
||||||
|
#[ORM\Column(length: 255, nullable: true)]
|
||||||
|
private ?string $ip = null;
|
||||||
|
|
||||||
|
#[ORM\Column(length: 255, nullable: true)]
|
||||||
|
private ?string $status = null;
|
||||||
|
|
||||||
|
#[ORM\ManyToOne(inversedBy: 'clients')]
|
||||||
|
private ?OrganizationalUnit $organizationalUnit = null;
|
||||||
|
|
||||||
|
|
||||||
|
public function getName(): ?string
|
||||||
|
{
|
||||||
|
return $this->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setName(?string $name): static
|
||||||
|
{
|
||||||
|
$this->name = $name;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getSerialNumber(): ?string
|
||||||
|
{
|
||||||
|
return $this->serialNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setSerialNumber(?string $serialNumber): static
|
||||||
|
{
|
||||||
|
$this->serialNumber = $serialNumber;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getNetiface(): ?string
|
||||||
|
{
|
||||||
|
return $this->netiface;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setNetiface(?string $netiface): static
|
||||||
|
{
|
||||||
|
$this->netiface = $netiface;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getNetDriver(): ?string
|
||||||
|
{
|
||||||
|
return $this->netDriver;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setNetDriver(string $netDriver): static
|
||||||
|
{
|
||||||
|
$this->netDriver = $netDriver;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getMac(): ?string
|
||||||
|
{
|
||||||
|
return $this->mac;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setMac(?string $mac): static
|
||||||
|
{
|
||||||
|
$this->mac = $mac;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getIp(): ?string
|
||||||
|
{
|
||||||
|
return $this->ip;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setIp(?string $ip): static
|
||||||
|
{
|
||||||
|
$this->ip = $ip;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getStatus(): ?string
|
||||||
|
{
|
||||||
|
return $this->status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setStatus(?string $status): static
|
||||||
|
{
|
||||||
|
$this->status = $status;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getOrganizationalUnit(): ?OrganizationalUnit
|
||||||
|
{
|
||||||
|
return $this->organizationalUnit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setOrganizationalUnit(?OrganizationalUnit $organizationalUnit): static
|
||||||
|
{
|
||||||
|
$this->organizationalUnit = $organizationalUnit;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,753 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Entity\Migration;
|
||||||
|
|
||||||
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
|
||||||
|
#[ORM\Entity]
|
||||||
|
class Aulas
|
||||||
|
{
|
||||||
|
#[ORM\Column(length: 255)]
|
||||||
|
private string $nombreaula = '';
|
||||||
|
|
||||||
|
#[ORM\Column(length: 255)]
|
||||||
|
private ?int $idcentro = null;
|
||||||
|
|
||||||
|
#[ORM\Column(length: 255)]
|
||||||
|
private string $urlfoto;
|
||||||
|
|
||||||
|
#[ORM\Column]
|
||||||
|
private ?bool $cagnon = false;
|
||||||
|
|
||||||
|
#[ORM\Column]
|
||||||
|
private bool $pizarra = false;
|
||||||
|
|
||||||
|
#[ORM\Column(length: 255)]
|
||||||
|
private ?int $grupoid = null;
|
||||||
|
|
||||||
|
#[ORM\Column(length: 255)]
|
||||||
|
private ?string $ubicacion = null;
|
||||||
|
|
||||||
|
#[ORM\Column(length: 255)]
|
||||||
|
private ?string $comentarios = null;
|
||||||
|
|
||||||
|
#[ORM\Column]
|
||||||
|
private ?int $puestos = 0;
|
||||||
|
|
||||||
|
#[ORM\Column]
|
||||||
|
private ?bool $horaresevini = false;
|
||||||
|
|
||||||
|
#[ORM\Column]
|
||||||
|
private ?bool $horaresevfin = false;
|
||||||
|
|
||||||
|
#[ORM\Column]
|
||||||
|
private bool $modomul;
|
||||||
|
|
||||||
|
#[ORM\Column(length: 255)]
|
||||||
|
private $ipmul;
|
||||||
|
|
||||||
|
#[ORM\Column]
|
||||||
|
private $pormul;
|
||||||
|
|
||||||
|
#[ORM\Column]
|
||||||
|
private $velmul = '70';
|
||||||
|
|
||||||
|
#[ORM\Column(length: 255)]
|
||||||
|
private ?string $router = null;
|
||||||
|
|
||||||
|
#[ORM\Column(length: 255)]
|
||||||
|
private ?string $netmask = null;
|
||||||
|
|
||||||
|
#[ORM\Column(length: 255)]
|
||||||
|
private ?string $dns = null;
|
||||||
|
|
||||||
|
#[ORM\Column(length: 255)]
|
||||||
|
private ?string $proxy = null;
|
||||||
|
|
||||||
|
#[ORM\Column(length: 255)]
|
||||||
|
private ?string $ntp = null;
|
||||||
|
|
||||||
|
#[ORM\Column(length: 255)]
|
||||||
|
private ?string $modp2p = 'peer';
|
||||||
|
|
||||||
|
#[ORM\Column]
|
||||||
|
private $timep2p = '60';
|
||||||
|
|
||||||
|
#[ORM\Column]
|
||||||
|
private ?bool $validacion = false;
|
||||||
|
|
||||||
|
#[ORM\Column(length: 255)]
|
||||||
|
private $paginalogin;
|
||||||
|
|
||||||
|
#[ORM\Column(length: 255)]
|
||||||
|
private $paginavalidacion;
|
||||||
|
|
||||||
|
#[ORM\Column(length: 255)]
|
||||||
|
private $inremotepc = '0';
|
||||||
|
|
||||||
|
#[ORM\Column(length: 255)]
|
||||||
|
private $oglivedir = 'ogLive';
|
||||||
|
|
||||||
|
#[ORM\Id]
|
||||||
|
#[ORM\GeneratedValue]
|
||||||
|
#[ORM\Column]
|
||||||
|
protected ?int $idaula = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set nombreaula.
|
||||||
|
*
|
||||||
|
* @param string $nombreaula
|
||||||
|
*
|
||||||
|
* @return Aulas
|
||||||
|
*/
|
||||||
|
public function setNombreaula($nombreaula)
|
||||||
|
{
|
||||||
|
$this->nombreaula = $nombreaula;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get nombreaula.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getNombreaula()
|
||||||
|
{
|
||||||
|
return $this->nombreaula;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set idcentro.
|
||||||
|
*
|
||||||
|
* @param int $idcentro
|
||||||
|
*
|
||||||
|
* @return Aulas
|
||||||
|
*/
|
||||||
|
public function setIdcentro($idcentro)
|
||||||
|
{
|
||||||
|
$this->idcentro = $idcentro;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get idcentro.
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getIdcentro()
|
||||||
|
{
|
||||||
|
return $this->idcentro;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set urlfoto.
|
||||||
|
*
|
||||||
|
* @param string|null $urlfoto
|
||||||
|
*
|
||||||
|
* @return Aulas
|
||||||
|
*/
|
||||||
|
public function setUrlfoto($urlfoto = null)
|
||||||
|
{
|
||||||
|
$this->urlfoto = $urlfoto;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get urlfoto.
|
||||||
|
*
|
||||||
|
* @return string|null
|
||||||
|
*/
|
||||||
|
public function getUrlfoto()
|
||||||
|
{
|
||||||
|
return $this->urlfoto;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set cagnon.
|
||||||
|
*
|
||||||
|
* @param bool|null $cagnon
|
||||||
|
*
|
||||||
|
* @return Aulas
|
||||||
|
*/
|
||||||
|
public function setCagnon($cagnon = null)
|
||||||
|
{
|
||||||
|
$this->cagnon = $cagnon;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get cagnon.
|
||||||
|
*
|
||||||
|
* @return bool|null
|
||||||
|
*/
|
||||||
|
public function getCagnon()
|
||||||
|
{
|
||||||
|
return $this->cagnon;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set pizarra.
|
||||||
|
*
|
||||||
|
* @param bool|null $pizarra
|
||||||
|
*
|
||||||
|
* @return Aulas
|
||||||
|
*/
|
||||||
|
public function setPizarra($pizarra = null)
|
||||||
|
{
|
||||||
|
$this->pizarra = $pizarra;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get pizarra.
|
||||||
|
*
|
||||||
|
* @return bool|null
|
||||||
|
*/
|
||||||
|
public function getPizarra()
|
||||||
|
{
|
||||||
|
return $this->pizarra;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set grupoid.
|
||||||
|
*
|
||||||
|
* @param int|null $grupoid
|
||||||
|
*
|
||||||
|
* @return Aulas
|
||||||
|
*/
|
||||||
|
public function setGrupoid($grupoid = null)
|
||||||
|
{
|
||||||
|
$this->grupoid = $grupoid;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get grupoid.
|
||||||
|
*
|
||||||
|
* @return int|null
|
||||||
|
*/
|
||||||
|
public function getGrupoid()
|
||||||
|
{
|
||||||
|
return $this->grupoid;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set ubicacion.
|
||||||
|
*
|
||||||
|
* @param string|null $ubicacion
|
||||||
|
*
|
||||||
|
* @return Aulas
|
||||||
|
*/
|
||||||
|
public function setUbicacion($ubicacion = null)
|
||||||
|
{
|
||||||
|
$this->ubicacion = $ubicacion;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get ubicacion.
|
||||||
|
*
|
||||||
|
* @return string|null
|
||||||
|
*/
|
||||||
|
public function getUbicacion()
|
||||||
|
{
|
||||||
|
return $this->ubicacion;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set comentarios.
|
||||||
|
*
|
||||||
|
* @param string|null $comentarios
|
||||||
|
*
|
||||||
|
* @return Aulas
|
||||||
|
*/
|
||||||
|
public function setComentarios($comentarios = null)
|
||||||
|
{
|
||||||
|
$this->comentarios = $comentarios;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get comentarios.
|
||||||
|
*
|
||||||
|
* @return string|null
|
||||||
|
*/
|
||||||
|
public function getComentarios()
|
||||||
|
{
|
||||||
|
return $this->comentarios;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set puestos.
|
||||||
|
*
|
||||||
|
* @param int|null $puestos
|
||||||
|
*
|
||||||
|
* @return Aulas
|
||||||
|
*/
|
||||||
|
public function setPuestos($puestos = null)
|
||||||
|
{
|
||||||
|
$this->puestos = $puestos;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get puestos.
|
||||||
|
*
|
||||||
|
* @return int|null
|
||||||
|
*/
|
||||||
|
public function getPuestos()
|
||||||
|
{
|
||||||
|
return $this->puestos;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set horaresevini.
|
||||||
|
*
|
||||||
|
* @param bool|null $horaresevini
|
||||||
|
*
|
||||||
|
* @return Aulas
|
||||||
|
*/
|
||||||
|
public function setHoraresevini($horaresevini = null)
|
||||||
|
{
|
||||||
|
$this->horaresevini = $horaresevini;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get horaresevini.
|
||||||
|
*
|
||||||
|
* @return bool|null
|
||||||
|
*/
|
||||||
|
public function getHoraresevini()
|
||||||
|
{
|
||||||
|
return $this->horaresevini;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set horaresevfin.
|
||||||
|
*
|
||||||
|
* @param bool|null $horaresevfin
|
||||||
|
*
|
||||||
|
* @return Aulas
|
||||||
|
*/
|
||||||
|
public function setHoraresevfin($horaresevfin = null)
|
||||||
|
{
|
||||||
|
$this->horaresevfin = $horaresevfin;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get horaresevfin.
|
||||||
|
*
|
||||||
|
* @return bool|null
|
||||||
|
*/
|
||||||
|
public function getHoraresevfin()
|
||||||
|
{
|
||||||
|
return $this->horaresevfin;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set modomul.
|
||||||
|
*
|
||||||
|
* @param bool $modomul
|
||||||
|
*
|
||||||
|
* @return Aulas
|
||||||
|
*/
|
||||||
|
public function setModomul($modomul)
|
||||||
|
{
|
||||||
|
$this->modomul = $modomul;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get modomul.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function getModomul()
|
||||||
|
{
|
||||||
|
return $this->modomul;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set ipmul.
|
||||||
|
*
|
||||||
|
* @param string $ipmul
|
||||||
|
*
|
||||||
|
* @return Aulas
|
||||||
|
*/
|
||||||
|
public function setIpmul($ipmul)
|
||||||
|
{
|
||||||
|
$this->ipmul = $ipmul;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get ipmul.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getIpmul()
|
||||||
|
{
|
||||||
|
return $this->ipmul;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set pormul.
|
||||||
|
*
|
||||||
|
* @param int $pormul
|
||||||
|
*
|
||||||
|
* @return Aulas
|
||||||
|
*/
|
||||||
|
public function setPormul($pormul)
|
||||||
|
{
|
||||||
|
$this->pormul = $pormul;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get pormul.
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getPormul()
|
||||||
|
{
|
||||||
|
return $this->pormul;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set velmul.
|
||||||
|
*
|
||||||
|
* @param int $velmul
|
||||||
|
*
|
||||||
|
* @return Aulas
|
||||||
|
*/
|
||||||
|
public function setVelmul($velmul)
|
||||||
|
{
|
||||||
|
$this->velmul = $velmul;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get velmul.
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getVelmul()
|
||||||
|
{
|
||||||
|
return $this->velmul;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set router.
|
||||||
|
*
|
||||||
|
* @param string|null $router
|
||||||
|
*
|
||||||
|
* @return Aulas
|
||||||
|
*/
|
||||||
|
public function setRouter($router = null)
|
||||||
|
{
|
||||||
|
$this->router = $router;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get router.
|
||||||
|
*
|
||||||
|
* @return string|null
|
||||||
|
*/
|
||||||
|
public function getRouter()
|
||||||
|
{
|
||||||
|
return $this->router;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set netmask.
|
||||||
|
*
|
||||||
|
* @param string|null $netmask
|
||||||
|
*
|
||||||
|
* @return Aulas
|
||||||
|
*/
|
||||||
|
public function setNetmask($netmask = null)
|
||||||
|
{
|
||||||
|
$this->netmask = $netmask;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get netmask.
|
||||||
|
*
|
||||||
|
* @return string|null
|
||||||
|
*/
|
||||||
|
public function getNetmask()
|
||||||
|
{
|
||||||
|
return $this->netmask;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set dns.
|
||||||
|
*
|
||||||
|
* @param string|null $dns
|
||||||
|
*
|
||||||
|
* @return Aulas
|
||||||
|
*/
|
||||||
|
public function setDns($dns = null)
|
||||||
|
{
|
||||||
|
$this->dns = $dns;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get dns.
|
||||||
|
*
|
||||||
|
* @return string|null
|
||||||
|
*/
|
||||||
|
public function getDns()
|
||||||
|
{
|
||||||
|
return $this->dns;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set proxy.
|
||||||
|
*
|
||||||
|
* @param string|null $proxy
|
||||||
|
*
|
||||||
|
* @return Aulas
|
||||||
|
*/
|
||||||
|
public function setProxy($proxy = null)
|
||||||
|
{
|
||||||
|
$this->proxy = $proxy;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get proxy.
|
||||||
|
*
|
||||||
|
* @return string|null
|
||||||
|
*/
|
||||||
|
public function getProxy()
|
||||||
|
{
|
||||||
|
return $this->proxy;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set ntp.
|
||||||
|
*
|
||||||
|
* @param string|null $ntp
|
||||||
|
*
|
||||||
|
* @return Aulas
|
||||||
|
*/
|
||||||
|
public function setNtp($ntp = null)
|
||||||
|
{
|
||||||
|
$this->ntp = $ntp;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get ntp.
|
||||||
|
*
|
||||||
|
* @return string|null
|
||||||
|
*/
|
||||||
|
public function getNtp()
|
||||||
|
{
|
||||||
|
return $this->ntp;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set modp2p.
|
||||||
|
*
|
||||||
|
* @param string|null $modp2p
|
||||||
|
*
|
||||||
|
* @return Aulas
|
||||||
|
*/
|
||||||
|
public function setModp2p($modp2p = null)
|
||||||
|
{
|
||||||
|
$this->modp2p = $modp2p;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get modp2p.
|
||||||
|
*
|
||||||
|
* @return string|null
|
||||||
|
*/
|
||||||
|
public function getModp2p()
|
||||||
|
{
|
||||||
|
return $this->modp2p;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set timep2p.
|
||||||
|
*
|
||||||
|
* @param int $timep2p
|
||||||
|
*
|
||||||
|
* @return Aulas
|
||||||
|
*/
|
||||||
|
public function setTimep2p($timep2p)
|
||||||
|
{
|
||||||
|
$this->timep2p = $timep2p;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get timep2p.
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getTimep2p()
|
||||||
|
{
|
||||||
|
return $this->timep2p;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set validacion.
|
||||||
|
*
|
||||||
|
* @param bool|null $validacion
|
||||||
|
*
|
||||||
|
* @return Aulas
|
||||||
|
*/
|
||||||
|
public function setValidacion($validacion = null)
|
||||||
|
{
|
||||||
|
$this->validacion = $validacion;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get validacion.
|
||||||
|
*
|
||||||
|
* @return bool|null
|
||||||
|
*/
|
||||||
|
public function getValidacion()
|
||||||
|
{
|
||||||
|
return $this->validacion;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set paginalogin.
|
||||||
|
*
|
||||||
|
* @param string|null $paginalogin
|
||||||
|
*
|
||||||
|
* @return Aulas
|
||||||
|
*/
|
||||||
|
public function setPaginalogin($paginalogin = null)
|
||||||
|
{
|
||||||
|
$this->paginalogin = $paginalogin;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get paginalogin.
|
||||||
|
*
|
||||||
|
* @return string|null
|
||||||
|
*/
|
||||||
|
public function getPaginalogin()
|
||||||
|
{
|
||||||
|
return $this->paginalogin;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set paginavalidacion.
|
||||||
|
*
|
||||||
|
* @param string|null $paginavalidacion
|
||||||
|
*
|
||||||
|
* @return Aulas
|
||||||
|
*/
|
||||||
|
public function setPaginavalidacion($paginavalidacion = null)
|
||||||
|
{
|
||||||
|
$this->paginavalidacion = $paginavalidacion;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get paginavalidacion.
|
||||||
|
*
|
||||||
|
* @return string|null
|
||||||
|
*/
|
||||||
|
public function getPaginavalidacion()
|
||||||
|
{
|
||||||
|
return $this->paginavalidacion;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set inremotepc.
|
||||||
|
*
|
||||||
|
* @param bool|null $inremotepc
|
||||||
|
*
|
||||||
|
* @return Aulas
|
||||||
|
*/
|
||||||
|
public function setInremotepc($inremotepc = null)
|
||||||
|
{
|
||||||
|
$this->inremotepc = $inremotepc;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get inremotepc.
|
||||||
|
*
|
||||||
|
* @return bool|null
|
||||||
|
*/
|
||||||
|
public function getInremotepc()
|
||||||
|
{
|
||||||
|
return $this->inremotepc;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set oglivedir.
|
||||||
|
*
|
||||||
|
* @param string $oglivedir
|
||||||
|
*
|
||||||
|
* @return Aulas
|
||||||
|
*/
|
||||||
|
public function setOglivedir($oglivedir)
|
||||||
|
{
|
||||||
|
$this->oglivedir = $oglivedir;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get oglivedir.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getOglivedir()
|
||||||
|
{
|
||||||
|
return $this->oglivedir;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get idaula.
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getIdaula()
|
||||||
|
{
|
||||||
|
return $this->idaula;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,133 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Entity\Migration;
|
||||||
|
|
||||||
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
|
||||||
|
#[ORM\Entity]
|
||||||
|
class Centros
|
||||||
|
{
|
||||||
|
|
||||||
|
#[ORM\Column(length: 255)]
|
||||||
|
private ?string $nombrecentro = '';
|
||||||
|
|
||||||
|
#[ORM\Column]
|
||||||
|
private ?int $identidad;
|
||||||
|
|
||||||
|
#[ORM\Column(length: 255, nullable: true)]
|
||||||
|
private ?string $comentarios = '';
|
||||||
|
|
||||||
|
#[ORM\Column(length: 255, nullable: true)]
|
||||||
|
private ?string $directorio = '';
|
||||||
|
|
||||||
|
#[ORM\Id]
|
||||||
|
#[ORM\GeneratedValue]
|
||||||
|
#[ORM\Column]
|
||||||
|
protected ?int $idcentro = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set nombrecentro.
|
||||||
|
*
|
||||||
|
* @param string $nombrecentro
|
||||||
|
*
|
||||||
|
* @return Centros
|
||||||
|
*/
|
||||||
|
public function setNombrecentro($nombrecentro)
|
||||||
|
{
|
||||||
|
$this->nombrecentro = $nombrecentro;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get nombrecentro.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getNombrecentro()
|
||||||
|
{
|
||||||
|
return $this->nombrecentro;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set identidad.
|
||||||
|
*
|
||||||
|
* @param int|null $identidad
|
||||||
|
*
|
||||||
|
* @return Centros
|
||||||
|
*/
|
||||||
|
public function setIdentidad($identidad = null)
|
||||||
|
{
|
||||||
|
$this->identidad = $identidad;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get identidad.
|
||||||
|
*
|
||||||
|
* @return int|null
|
||||||
|
*/
|
||||||
|
public function getIdentidad()
|
||||||
|
{
|
||||||
|
return $this->identidad;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set comentarios.
|
||||||
|
*
|
||||||
|
* @param string|null $comentarios
|
||||||
|
*
|
||||||
|
* @return Centros
|
||||||
|
*/
|
||||||
|
public function setComentarios($comentarios = null)
|
||||||
|
{
|
||||||
|
$this->comentarios = $comentarios;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get comentarios.
|
||||||
|
*
|
||||||
|
* @return string|null
|
||||||
|
*/
|
||||||
|
public function getComentarios()
|
||||||
|
{
|
||||||
|
return $this->comentarios;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set directorio.
|
||||||
|
*
|
||||||
|
* @param string|null $directorio
|
||||||
|
*
|
||||||
|
* @return Centros
|
||||||
|
*/
|
||||||
|
public function setDirectorio($directorio = null)
|
||||||
|
{
|
||||||
|
$this->directorio = $directorio;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get directorio.
|
||||||
|
*
|
||||||
|
* @return string|null
|
||||||
|
*/
|
||||||
|
public function getDirectorio()
|
||||||
|
{
|
||||||
|
return $this->directorio;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get idcentro.
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getIdcentro()
|
||||||
|
{
|
||||||
|
return $this->idcentro;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,133 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Entity\Migration;
|
||||||
|
|
||||||
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
|
||||||
|
#[ORM\Entity]
|
||||||
|
class Gruposordenadores
|
||||||
|
{
|
||||||
|
#[ORM\Column(length: 255)]
|
||||||
|
private $nombregrupoordenador = '';
|
||||||
|
|
||||||
|
#[ORM\Column]
|
||||||
|
private $idaula = '0';
|
||||||
|
|
||||||
|
#[ORM\Column]
|
||||||
|
private $grupoid;
|
||||||
|
|
||||||
|
#[ORM\Column(length: 255)]
|
||||||
|
private ?string $comentarios = null;
|
||||||
|
|
||||||
|
#[ORM\Id]
|
||||||
|
#[ORM\GeneratedValue]
|
||||||
|
#[ORM\Column]
|
||||||
|
protected ?int $idgrupo = null;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set nombregrupoordenador.
|
||||||
|
*
|
||||||
|
* @param string $nombregrupoordenador
|
||||||
|
*
|
||||||
|
* @return Gruposordenadores
|
||||||
|
*/
|
||||||
|
public function setNombregrupoordenador($nombregrupoordenador)
|
||||||
|
{
|
||||||
|
$this->nombregrupoordenador = $nombregrupoordenador;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get nombregrupoordenador.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getNombregrupoordenador()
|
||||||
|
{
|
||||||
|
return $this->nombregrupoordenador;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set idaula.
|
||||||
|
*
|
||||||
|
* @param int $idaula
|
||||||
|
*
|
||||||
|
* @return Gruposordenadores
|
||||||
|
*/
|
||||||
|
public function setIdaula($idaula)
|
||||||
|
{
|
||||||
|
$this->idaula = $idaula;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get idaula.
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getIdaula()
|
||||||
|
{
|
||||||
|
return $this->idaula;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set grupoid.
|
||||||
|
*
|
||||||
|
* @param int|null $grupoid
|
||||||
|
*
|
||||||
|
* @return Gruposordenadores
|
||||||
|
*/
|
||||||
|
public function setGrupoid($grupoid = null)
|
||||||
|
{
|
||||||
|
$this->grupoid = $grupoid;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get grupoid.
|
||||||
|
*
|
||||||
|
* @return int|null
|
||||||
|
*/
|
||||||
|
public function getGrupoid()
|
||||||
|
{
|
||||||
|
return $this->grupoid;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set comentarios.
|
||||||
|
*
|
||||||
|
* @param string|null $comentarios
|
||||||
|
*
|
||||||
|
* @return Gruposordenadores
|
||||||
|
*/
|
||||||
|
public function setComentarios($comentarios = null)
|
||||||
|
{
|
||||||
|
$this->comentarios = $comentarios;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get comentarios.
|
||||||
|
*
|
||||||
|
* @return string|null
|
||||||
|
*/
|
||||||
|
public function getComentarios()
|
||||||
|
{
|
||||||
|
return $this->comentarios;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get idgrupo.
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getIdgrupo()
|
||||||
|
{
|
||||||
|
return $this->idgrupo;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,663 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Entity\Migration;
|
||||||
|
|
||||||
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
|
||||||
|
#[ORM\Entity]
|
||||||
|
class Ordenadores
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var string|null
|
||||||
|
*/
|
||||||
|
private $nombreordenador;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string|null
|
||||||
|
*/
|
||||||
|
private $numserie;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $ip;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string|null
|
||||||
|
*/
|
||||||
|
private $mac;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var int|null
|
||||||
|
*/
|
||||||
|
private $idaula;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var int|null
|
||||||
|
*/
|
||||||
|
private $idperfilhard;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var int|null
|
||||||
|
*/
|
||||||
|
private $idrepositorio;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var int|null
|
||||||
|
*/
|
||||||
|
private $grupoid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var int|null
|
||||||
|
*/
|
||||||
|
private $idmenu;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var int|null
|
||||||
|
*/
|
||||||
|
private $cache;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $router;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $mascara;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
private $idproautoexec = '0';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $arranque = '00unknown';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string|null
|
||||||
|
*/
|
||||||
|
private $netiface = 'eth0';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $netdriver = 'generic';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $fotoord = 'fotoordenador.gif';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var bool|null
|
||||||
|
*/
|
||||||
|
private $validacion = '0';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string|null
|
||||||
|
*/
|
||||||
|
private $paginalogin;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string|null
|
||||||
|
*/
|
||||||
|
private $paginavalidacion;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string|null
|
||||||
|
*/
|
||||||
|
private $agentkey;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $oglivedir = 'ogLive';
|
||||||
|
|
||||||
|
#[ORM\Id]
|
||||||
|
#[ORM\GeneratedValue]
|
||||||
|
#[ORM\Column]
|
||||||
|
protected ?int $idordenador = null;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set nombreordenador.
|
||||||
|
*
|
||||||
|
* @param string|null $nombreordenador
|
||||||
|
*
|
||||||
|
* @return Ordenadores
|
||||||
|
*/
|
||||||
|
public function setNombreordenador($nombreordenador = null)
|
||||||
|
{
|
||||||
|
$this->nombreordenador = $nombreordenador;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get nombreordenador.
|
||||||
|
*
|
||||||
|
* @return string|null
|
||||||
|
*/
|
||||||
|
public function getNombreordenador()
|
||||||
|
{
|
||||||
|
return $this->nombreordenador;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set numserie.
|
||||||
|
*
|
||||||
|
* @param string|null $numserie
|
||||||
|
*
|
||||||
|
* @return Ordenadores
|
||||||
|
*/
|
||||||
|
public function setNumserie($numserie = null)
|
||||||
|
{
|
||||||
|
$this->numserie = $numserie;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get numserie.
|
||||||
|
*
|
||||||
|
* @return string|null
|
||||||
|
*/
|
||||||
|
public function getNumserie()
|
||||||
|
{
|
||||||
|
return $this->numserie;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set ip.
|
||||||
|
*
|
||||||
|
* @param string $ip
|
||||||
|
*
|
||||||
|
* @return Ordenadores
|
||||||
|
*/
|
||||||
|
public function setIp($ip)
|
||||||
|
{
|
||||||
|
$this->ip = $ip;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get ip.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getIp()
|
||||||
|
{
|
||||||
|
return $this->ip;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set mac.
|
||||||
|
*
|
||||||
|
* @param string|null $mac
|
||||||
|
*
|
||||||
|
* @return Ordenadores
|
||||||
|
*/
|
||||||
|
public function setMac($mac = null)
|
||||||
|
{
|
||||||
|
$this->mac = $mac;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get mac.
|
||||||
|
*
|
||||||
|
* @return string|null
|
||||||
|
*/
|
||||||
|
public function getMac()
|
||||||
|
{
|
||||||
|
return $this->mac;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set idaula.
|
||||||
|
*
|
||||||
|
* @param int|null $idaula
|
||||||
|
*
|
||||||
|
* @return Ordenadores
|
||||||
|
*/
|
||||||
|
public function setIdaula($idaula = null)
|
||||||
|
{
|
||||||
|
$this->idaula = $idaula;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get idaula.
|
||||||
|
*
|
||||||
|
* @return int|null
|
||||||
|
*/
|
||||||
|
public function getIdaula()
|
||||||
|
{
|
||||||
|
return $this->idaula;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set idperfilhard.
|
||||||
|
*
|
||||||
|
* @param int|null $idperfilhard
|
||||||
|
*
|
||||||
|
* @return Ordenadores
|
||||||
|
*/
|
||||||
|
public function setIdperfilhard($idperfilhard = null)
|
||||||
|
{
|
||||||
|
$this->idperfilhard = $idperfilhard;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get idperfilhard.
|
||||||
|
*
|
||||||
|
* @return int|null
|
||||||
|
*/
|
||||||
|
public function getIdperfilhard()
|
||||||
|
{
|
||||||
|
return $this->idperfilhard;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set idrepositorio.
|
||||||
|
*
|
||||||
|
* @param int|null $idrepositorio
|
||||||
|
*
|
||||||
|
* @return Ordenadores
|
||||||
|
*/
|
||||||
|
public function setIdrepositorio($idrepositorio = null)
|
||||||
|
{
|
||||||
|
$this->idrepositorio = $idrepositorio;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get idrepositorio.
|
||||||
|
*
|
||||||
|
* @return int|null
|
||||||
|
*/
|
||||||
|
public function getIdrepositorio()
|
||||||
|
{
|
||||||
|
return $this->idrepositorio;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set grupoid.
|
||||||
|
*
|
||||||
|
* @param int|null $grupoid
|
||||||
|
*
|
||||||
|
* @return Ordenadores
|
||||||
|
*/
|
||||||
|
public function setGrupoid($grupoid = null)
|
||||||
|
{
|
||||||
|
$this->grupoid = $grupoid;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get grupoid.
|
||||||
|
*
|
||||||
|
* @return int|null
|
||||||
|
*/
|
||||||
|
public function getGrupoid()
|
||||||
|
{
|
||||||
|
return $this->grupoid;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set idmenu.
|
||||||
|
*
|
||||||
|
* @param int|null $idmenu
|
||||||
|
*
|
||||||
|
* @return Ordenadores
|
||||||
|
*/
|
||||||
|
public function setIdmenu($idmenu = null)
|
||||||
|
{
|
||||||
|
$this->idmenu = $idmenu;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get idmenu.
|
||||||
|
*
|
||||||
|
* @return int|null
|
||||||
|
*/
|
||||||
|
public function getIdmenu()
|
||||||
|
{
|
||||||
|
return $this->idmenu;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set cache.
|
||||||
|
*
|
||||||
|
* @param int|null $cache
|
||||||
|
*
|
||||||
|
* @return Ordenadores
|
||||||
|
*/
|
||||||
|
public function setCache($cache = null)
|
||||||
|
{
|
||||||
|
$this->cache = $cache;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get cache.
|
||||||
|
*
|
||||||
|
* @return int|null
|
||||||
|
*/
|
||||||
|
public function getCache()
|
||||||
|
{
|
||||||
|
return $this->cache;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set router.
|
||||||
|
*
|
||||||
|
* @param string $router
|
||||||
|
*
|
||||||
|
* @return Ordenadores
|
||||||
|
*/
|
||||||
|
public function setRouter($router)
|
||||||
|
{
|
||||||
|
$this->router = $router;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get router.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getRouter()
|
||||||
|
{
|
||||||
|
return $this->router;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set mascara.
|
||||||
|
*
|
||||||
|
* @param string $mascara
|
||||||
|
*
|
||||||
|
* @return Ordenadores
|
||||||
|
*/
|
||||||
|
public function setMascara($mascara)
|
||||||
|
{
|
||||||
|
$this->mascara = $mascara;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get mascara.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getMascara()
|
||||||
|
{
|
||||||
|
return $this->mascara;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set idproautoexec.
|
||||||
|
*
|
||||||
|
* @param int $idproautoexec
|
||||||
|
*
|
||||||
|
* @return Ordenadores
|
||||||
|
*/
|
||||||
|
public function setIdproautoexec($idproautoexec)
|
||||||
|
{
|
||||||
|
$this->idproautoexec = $idproautoexec;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get idproautoexec.
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getIdproautoexec()
|
||||||
|
{
|
||||||
|
return $this->idproautoexec;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set arranque.
|
||||||
|
*
|
||||||
|
* @param string $arranque
|
||||||
|
*
|
||||||
|
* @return Ordenadores
|
||||||
|
*/
|
||||||
|
public function setArranque($arranque)
|
||||||
|
{
|
||||||
|
$this->arranque = $arranque;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get arranque.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getArranque()
|
||||||
|
{
|
||||||
|
return $this->arranque;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set netiface.
|
||||||
|
*
|
||||||
|
* @param string|null $netiface
|
||||||
|
*
|
||||||
|
* @return Ordenadores
|
||||||
|
*/
|
||||||
|
public function setNetiface($netiface = null)
|
||||||
|
{
|
||||||
|
$this->netiface = $netiface;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get netiface.
|
||||||
|
*
|
||||||
|
* @return string|null
|
||||||
|
*/
|
||||||
|
public function getNetiface()
|
||||||
|
{
|
||||||
|
return $this->netiface;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set netdriver.
|
||||||
|
*
|
||||||
|
* @param string $netdriver
|
||||||
|
*
|
||||||
|
* @return Ordenadores
|
||||||
|
*/
|
||||||
|
public function setNetdriver($netdriver)
|
||||||
|
{
|
||||||
|
$this->netdriver = $netdriver;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get netdriver.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getNetdriver()
|
||||||
|
{
|
||||||
|
return $this->netdriver;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set fotoord.
|
||||||
|
*
|
||||||
|
* @param string $fotoord
|
||||||
|
*
|
||||||
|
* @return Ordenadores
|
||||||
|
*/
|
||||||
|
public function setFotoord($fotoord)
|
||||||
|
{
|
||||||
|
$this->fotoord = $fotoord;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get fotoord.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getFotoord()
|
||||||
|
{
|
||||||
|
return $this->fotoord;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set validacion.
|
||||||
|
*
|
||||||
|
* @param bool|null $validacion
|
||||||
|
*
|
||||||
|
* @return Ordenadores
|
||||||
|
*/
|
||||||
|
public function setValidacion($validacion = null)
|
||||||
|
{
|
||||||
|
$this->validacion = $validacion;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get validacion.
|
||||||
|
*
|
||||||
|
* @return bool|null
|
||||||
|
*/
|
||||||
|
public function getValidacion()
|
||||||
|
{
|
||||||
|
return $this->validacion;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set paginalogin.
|
||||||
|
*
|
||||||
|
* @param string|null $paginalogin
|
||||||
|
*
|
||||||
|
* @return Ordenadores
|
||||||
|
*/
|
||||||
|
public function setPaginalogin($paginalogin = null)
|
||||||
|
{
|
||||||
|
$this->paginalogin = $paginalogin;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get paginalogin.
|
||||||
|
*
|
||||||
|
* @return string|null
|
||||||
|
*/
|
||||||
|
public function getPaginalogin()
|
||||||
|
{
|
||||||
|
return $this->paginalogin;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set paginavalidacion.
|
||||||
|
*
|
||||||
|
* @param string|null $paginavalidacion
|
||||||
|
*
|
||||||
|
* @return Ordenadores
|
||||||
|
*/
|
||||||
|
public function setPaginavalidacion($paginavalidacion = null)
|
||||||
|
{
|
||||||
|
$this->paginavalidacion = $paginavalidacion;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get paginavalidacion.
|
||||||
|
*
|
||||||
|
* @return string|null
|
||||||
|
*/
|
||||||
|
public function getPaginavalidacion()
|
||||||
|
{
|
||||||
|
return $this->paginavalidacion;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set agentkey.
|
||||||
|
*
|
||||||
|
* @param string|null $agentkey
|
||||||
|
*
|
||||||
|
* @return Ordenadores
|
||||||
|
*/
|
||||||
|
public function setAgentkey($agentkey = null)
|
||||||
|
{
|
||||||
|
$this->agentkey = $agentkey;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get agentkey.
|
||||||
|
*
|
||||||
|
* @return string|null
|
||||||
|
*/
|
||||||
|
public function getAgentkey()
|
||||||
|
{
|
||||||
|
return $this->agentkey;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set oglivedir.
|
||||||
|
*
|
||||||
|
* @param string $oglivedir
|
||||||
|
*
|
||||||
|
* @return Ordenadores
|
||||||
|
*/
|
||||||
|
public function setOglivedir($oglivedir)
|
||||||
|
{
|
||||||
|
$this->oglivedir = $oglivedir;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get oglivedir.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getOglivedir()
|
||||||
|
{
|
||||||
|
return $this->oglivedir;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get idordenador.
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getIdordenador()
|
||||||
|
{
|
||||||
|
return $this->idordenador;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Entity;
|
||||||
|
|
||||||
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
|
||||||
|
trait NameableTrait
|
||||||
|
{
|
||||||
|
#[ORM\Column(length: 255)]
|
||||||
|
private ?string $name = null;
|
||||||
|
|
||||||
|
public function getName(): ?string
|
||||||
|
{
|
||||||
|
return $this->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setName(string $name): static
|
||||||
|
{
|
||||||
|
$this->name = $name;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,224 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Entity;
|
||||||
|
|
||||||
|
use App\Repository\NetworkSettingsRepository;
|
||||||
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
|
use Doctrine\Common\Collections\Collection;
|
||||||
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
|
||||||
|
#[ORM\Entity(repositoryClass: NetworkSettingsRepository::class)]
|
||||||
|
class NetworkSettings extends AbstractEntity
|
||||||
|
{
|
||||||
|
#[ORM\Column(length: 255, nullable: true)]
|
||||||
|
private ?string $proxy = null;
|
||||||
|
|
||||||
|
#[ORM\Column(length: 255, nullable: true)]
|
||||||
|
private ?string $dns = null;
|
||||||
|
|
||||||
|
#[ORM\Column(length: 255, nullable: true)]
|
||||||
|
private ?string $netmask = null;
|
||||||
|
|
||||||
|
#[ORM\Column(length: 255, nullable: true)]
|
||||||
|
private ?string $router = null;
|
||||||
|
|
||||||
|
#[ORM\Column(length: 255, nullable: true)]
|
||||||
|
private ?string $ntp = null;
|
||||||
|
|
||||||
|
#[ORM\Column(nullable: true)]
|
||||||
|
private ?int $p2pTime = null;
|
||||||
|
|
||||||
|
#[ORM\Column(length: 255, nullable: true)]
|
||||||
|
private ?string $p2pMode = null;
|
||||||
|
|
||||||
|
#[ORM\Column(length: 255, nullable: true)]
|
||||||
|
private ?string $mcastIp = null;
|
||||||
|
|
||||||
|
#[ORM\Column]
|
||||||
|
private ?int $mcastSpeed = null;
|
||||||
|
|
||||||
|
#[ORM\Column(length: 255, nullable: true)]
|
||||||
|
private ?string $mcastMode = null;
|
||||||
|
|
||||||
|
#[ORM\Column(nullable: true)]
|
||||||
|
private ?int $mcastPort = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Collection<int, OrganizationalUnit>
|
||||||
|
*/
|
||||||
|
#[ORM\OneToMany(targetEntity: OrganizationalUnit::class, mappedBy: 'networkSettings')]
|
||||||
|
private Collection $organizationalUnits;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
$this->organizationalUnits = new ArrayCollection();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getId(): ?int
|
||||||
|
{
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getProxy(): ?string
|
||||||
|
{
|
||||||
|
return $this->proxy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setProxy(?string $proxy): static
|
||||||
|
{
|
||||||
|
$this->proxy = $proxy;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDns(): ?string
|
||||||
|
{
|
||||||
|
return $this->dns;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setDns(?string $dns): static
|
||||||
|
{
|
||||||
|
$this->dns = $dns;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getNetmask(): ?string
|
||||||
|
{
|
||||||
|
return $this->netmask;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setNetmask(?string $netmask): static
|
||||||
|
{
|
||||||
|
$this->netmask = $netmask;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getRouter(): ?string
|
||||||
|
{
|
||||||
|
return $this->router;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setRouter(?string $router): static
|
||||||
|
{
|
||||||
|
$this->router = $router;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getNtp(): ?string
|
||||||
|
{
|
||||||
|
return $this->ntp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setNtp(?string $ntp): static
|
||||||
|
{
|
||||||
|
$this->ntp = $ntp;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getP2pTime(): ?int
|
||||||
|
{
|
||||||
|
return $this->p2pTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setP2pTime(?int $p2pTime): static
|
||||||
|
{
|
||||||
|
$this->p2pTime = $p2pTime;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getP2pMode(): ?string
|
||||||
|
{
|
||||||
|
return $this->p2pMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setP2pMode(?string $p2pMode): static
|
||||||
|
{
|
||||||
|
$this->p2pMode = $p2pMode;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getMcastIp(): ?string
|
||||||
|
{
|
||||||
|
return $this->mcastIp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setMcastIp(?string $mcastIp): static
|
||||||
|
{
|
||||||
|
$this->mcastIp = $mcastIp;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getMcastSpeed(): ?int
|
||||||
|
{
|
||||||
|
return $this->mcastSpeed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setMcastSpeed(int $mcastSpeed): static
|
||||||
|
{
|
||||||
|
$this->mcastSpeed = $mcastSpeed;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getMcastMode(): ?string
|
||||||
|
{
|
||||||
|
return $this->mcastMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setMcastMode(?string $mcastMode): static
|
||||||
|
{
|
||||||
|
$this->mcastMode = $mcastMode;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getMcastPort(): ?int
|
||||||
|
{
|
||||||
|
return $this->mcastPort;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setMcastPort(?int $mcastPort): static
|
||||||
|
{
|
||||||
|
$this->mcastPort = $mcastPort;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Collection<int, OrganizationalUnit>
|
||||||
|
*/
|
||||||
|
public function getOrganizationalUnits(): Collection
|
||||||
|
{
|
||||||
|
return $this->organizationalUnits;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addOrganizationalUnit(OrganizationalUnit $organizationalUnit): static
|
||||||
|
{
|
||||||
|
if (!$this->organizationalUnits->contains($organizationalUnit)) {
|
||||||
|
$this->organizationalUnits->add($organizationalUnit);
|
||||||
|
$organizationalUnit->setNetworkSettings($this);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function removeOrganizationalUnit(OrganizationalUnit $organizationalUnit): static
|
||||||
|
{
|
||||||
|
if ($this->organizationalUnits->removeElement($organizationalUnit)) {
|
||||||
|
// set the owning side to null (unless already changed)
|
||||||
|
if ($organizationalUnit->getNetworkSettings() === $this) {
|
||||||
|
$organizationalUnit->setNetworkSettings(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,239 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Entity;
|
||||||
|
|
||||||
|
use Gedmo\Mapping\Annotation as Gedmo;
|
||||||
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
|
use Doctrine\Common\Collections\Collection;
|
||||||
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
use Gedmo\Tree\Entity\Repository\MaterializedPathRepository;
|
||||||
|
|
||||||
|
#[Gedmo\Tree(type: 'materializedPath')]
|
||||||
|
#[ORM\Entity(repositoryClass: MaterializedPathRepository::class)]
|
||||||
|
class OrganizationalUnit extends AbstractEntity
|
||||||
|
{
|
||||||
|
use NameableTrait;
|
||||||
|
|
||||||
|
#[ORM\Column(length: 255, nullable: true)]
|
||||||
|
private ?string $description = null;
|
||||||
|
|
||||||
|
#[ORM\Column(length: 255, nullable: true)]
|
||||||
|
private ?string $comments = null;
|
||||||
|
|
||||||
|
#[Gedmo\TreePath(separator: '/', appendId: false, startsWithSeparator: true, endsWithSeparator: false)]
|
||||||
|
#[ORM\Column(length: 255, nullable: true)]
|
||||||
|
private ?string $path = null;
|
||||||
|
|
||||||
|
#[Gedmo\TreeLevel]
|
||||||
|
#[ORM\Column(length: 255, nullable: true)]
|
||||||
|
private ?int $level;
|
||||||
|
|
||||||
|
#[Gedmo\TreePathSource]
|
||||||
|
#[Gedmo\Slug(fields: ['name'])]
|
||||||
|
#[ORM\Column(length: 255, nullable: true)]
|
||||||
|
private ?string $slug = null;
|
||||||
|
|
||||||
|
#[Gedmo\TreeParent]
|
||||||
|
#[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'organizationalUnits')]
|
||||||
|
#[ORM\JoinColumn( onDelete: 'SET NULL')]
|
||||||
|
private ?self $parent = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Collection<int, self>
|
||||||
|
*/
|
||||||
|
#[ORM\OneToMany(mappedBy: 'parent', targetEntity: self::class)]
|
||||||
|
private Collection $organizationalUnits;
|
||||||
|
|
||||||
|
#[ORM\ManyToOne(inversedBy: 'organizationalUnits')]
|
||||||
|
private ?NetworkSettings $networkSettings = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Collection<int, User>
|
||||||
|
*/
|
||||||
|
#[ORM\ManyToMany(targetEntity: User::class, mappedBy: 'allowedOrganizationalUnits')]
|
||||||
|
private Collection $users;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Collection<int, Client>
|
||||||
|
*/
|
||||||
|
#[ORM\OneToMany(mappedBy: 'organizationalUnit', targetEntity: Client::class)]
|
||||||
|
private Collection $clients;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
$this->organizationalUnits = new ArrayCollection();
|
||||||
|
$this->users = new ArrayCollection();
|
||||||
|
$this->clients = new ArrayCollection();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDescription(): ?string
|
||||||
|
{
|
||||||
|
return $this->description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setDescription(?string $description): static
|
||||||
|
{
|
||||||
|
$this->description = $description;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getComments(): ?string
|
||||||
|
{
|
||||||
|
return $this->comments;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setComments(?string $comments): static
|
||||||
|
{
|
||||||
|
$this->comments = $comments;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPath(): ?string
|
||||||
|
{
|
||||||
|
return $this->path;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setPath(?string $path): static
|
||||||
|
{
|
||||||
|
$this->path = $path;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getLevel(): ?int
|
||||||
|
{
|
||||||
|
return $this->level;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setLevel(?int $level): static
|
||||||
|
{
|
||||||
|
$this->level = $level;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getSlug(): ?string
|
||||||
|
{
|
||||||
|
return $this->slug;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setSlug(?string $slug): static
|
||||||
|
{
|
||||||
|
$this->slug = $slug;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getParent(): ?self
|
||||||
|
{
|
||||||
|
return $this->parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setParent(?self $parent): static
|
||||||
|
{
|
||||||
|
$this->parent = $parent;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Collection<int, self>
|
||||||
|
*/
|
||||||
|
public function getOrganizationalUnits(): Collection
|
||||||
|
{
|
||||||
|
return $this->organizationalUnits;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addOrganizationalUnit(self $organizationalUnit): static
|
||||||
|
{
|
||||||
|
if (!$this->organizationalUnits->contains($organizationalUnit)) {
|
||||||
|
$this->organizationalUnits->add($organizationalUnit);
|
||||||
|
$organizationalUnit->setParent($this);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function removeOrganizationalUnit(self $organizationalUnit): static
|
||||||
|
{
|
||||||
|
if ($this->organizationalUnits->removeElement($organizationalUnit)) {
|
||||||
|
// set the owning side to null (unless already changed)
|
||||||
|
if ($organizationalUnit->getParent() === $this) {
|
||||||
|
$organizationalUnit->setParent(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getNetworkSettings(): ?NetworkSettings
|
||||||
|
{
|
||||||
|
return $this->networkSettings;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setNetworkSettings(?NetworkSettings $networkSettings): static
|
||||||
|
{
|
||||||
|
$this->networkSettings = $networkSettings;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Collection<int, User>
|
||||||
|
*/
|
||||||
|
public function getUsers(): Collection
|
||||||
|
{
|
||||||
|
return $this->users;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addUser(User $user): static
|
||||||
|
{
|
||||||
|
if (!$this->users->contains($user)) {
|
||||||
|
$this->users->add($user);
|
||||||
|
$user->addAllowedOrganizationalUnit($this);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function removeUser(User $user): static
|
||||||
|
{
|
||||||
|
if ($this->users->removeElement($user)) {
|
||||||
|
$user->removeAllowedOrganizationalUnit($this);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Collection<int, Client>
|
||||||
|
*/
|
||||||
|
public function getClients(): Collection
|
||||||
|
{
|
||||||
|
return $this->clients;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addClient(Client $client): static
|
||||||
|
{
|
||||||
|
if (!$this->clients->contains($client)) {
|
||||||
|
$this->clients->add($client);
|
||||||
|
$client->setOrganizationalUnit($this);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function removeClient(Client $client): static
|
||||||
|
{
|
||||||
|
if ($this->clients->removeElement($client)) {
|
||||||
|
if ($client->getOrganizationalUnit() === $this) {
|
||||||
|
$client->setOrganizationalUnit(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Entity;
|
||||||
|
|
||||||
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
|
||||||
|
trait ToggleableTrait
|
||||||
|
{
|
||||||
|
#[ORM\Column(type: 'boolean')]
|
||||||
|
private bool $enabled = true;
|
||||||
|
|
||||||
|
public function isEnabled(): bool
|
||||||
|
{
|
||||||
|
return $this->enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setEnabled(bool $enabled): static
|
||||||
|
{
|
||||||
|
$this->enabled = $enabled;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,18 +3,22 @@
|
||||||
namespace App\Entity;
|
namespace App\Entity;
|
||||||
|
|
||||||
use App\Repository\UserRepository;
|
use App\Repository\UserRepository;
|
||||||
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
|
use Doctrine\Common\Collections\Collection;
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
||||||
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
|
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
|
||||||
use Symfony\Component\Security\Core\User\UserInterface;
|
use Symfony\Component\Security\Core\User\UserInterface;
|
||||||
|
|
||||||
#[ORM\Entity(repositoryClass: UserRepository::class)]
|
#[ORM\Entity(repositoryClass: UserRepository::class)]
|
||||||
#[ORM\UniqueConstraint(name: 'UNIQ_IDENTIFIER_USERNAME', fields: ['username'])]
|
#[ORM\UniqueConstraint(name: 'UNIQ_IDENTIFIER_USERNAME', fields: ['username'])]
|
||||||
class User implements UserInterface, PasswordAuthenticatedUserInterface
|
#[UniqueEntity(fields: ['username'], message: 'There is already an account with this username')]
|
||||||
|
class User extends AbstractEntity implements UserInterface, PasswordAuthenticatedUserInterface
|
||||||
{
|
{
|
||||||
#[ORM\Id]
|
use ToggleableTrait;
|
||||||
#[ORM\GeneratedValue]
|
|
||||||
#[ORM\Column]
|
const ROLE_SUPER_ADMIN = 'ROLE_SUPER_ADMIN';
|
||||||
private ?int $id = null;
|
const ROLE_USER = 'ROLE_USER';
|
||||||
|
|
||||||
#[ORM\Column(length: 180)]
|
#[ORM\Column(length: 180)]
|
||||||
private ?string $username = null;
|
private ?string $username = null;
|
||||||
|
@ -31,9 +35,23 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
|
||||||
#[ORM\Column]
|
#[ORM\Column]
|
||||||
private ?string $password = null;
|
private ?string $password = null;
|
||||||
|
|
||||||
public function getId(): ?int
|
/**
|
||||||
|
* @var Collection<int, UserGroup>
|
||||||
|
*/
|
||||||
|
#[ORM\ManyToMany(targetEntity: UserGroup::class, mappedBy: 'users')]
|
||||||
|
private Collection $userGroups;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Collection<int, OrganizationalUnit>
|
||||||
|
*/
|
||||||
|
#[ORM\ManyToMany(targetEntity: OrganizationalUnit::class, inversedBy: 'users')]
|
||||||
|
private Collection $allowedOrganizationalUnits;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
{
|
{
|
||||||
return $this->id;
|
parent::__construct();
|
||||||
|
$this->userGroups = new ArrayCollection();
|
||||||
|
$this->allowedOrganizationalUnits = new ArrayCollection();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getUsername(): ?string
|
public function getUsername(): ?string
|
||||||
|
@ -66,10 +84,18 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
|
||||||
public function getRoles(): array
|
public function getRoles(): array
|
||||||
{
|
{
|
||||||
$roles = $this->roles;
|
$roles = $this->roles;
|
||||||
// guarantee every user at least has ROLE_USER
|
|
||||||
$roles[] = 'ROLE_USER';
|
|
||||||
|
|
||||||
return array_unique($roles);
|
if (!array_search(self::ROLE_USER, $roles, true)){
|
||||||
|
$roles[] = self::ROLE_USER;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($this->getUserGroups() as $userGroup) {
|
||||||
|
if ($userGroup->isEnabled()){
|
||||||
|
$roles = array_merge($roles, $userGroup->getPermissions());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return array_merge(array_unique($roles));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -105,4 +131,77 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
|
||||||
// If you store any temporary, sensitive data on the user, clear it here
|
// If you store any temporary, sensitive data on the user, clear it here
|
||||||
// $this->plainPassword = null;
|
// $this->plainPassword = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Collection<int, UserGroup>
|
||||||
|
*/
|
||||||
|
public function getUserGroups(): Collection
|
||||||
|
{
|
||||||
|
return $this->userGroups;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setUserGroups(array $userGroup): static
|
||||||
|
{
|
||||||
|
$this->userGroups->clear();
|
||||||
|
|
||||||
|
foreach ($userGroup as $group){
|
||||||
|
$this->addUserGroup($group);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addUserGroup(UserGroup $userGroup): static
|
||||||
|
{
|
||||||
|
if (!$this->userGroups->contains($userGroup)) {
|
||||||
|
$this->userGroups->add($userGroup);
|
||||||
|
$userGroup->addUser($this);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function removeUserGroup(UserGroup $userGroup): static
|
||||||
|
{
|
||||||
|
if ($this->userGroups->removeElement($userGroup)) {
|
||||||
|
$userGroup->removeUser($this);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Collection<int, OrganizationalUnit>
|
||||||
|
*/
|
||||||
|
public function getAllowedOrganizationalUnits(): Collection
|
||||||
|
{
|
||||||
|
return $this->allowedOrganizationalUnits;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setAllowedOrganizationalUnits(array $allowedOrganizationalUnits): static
|
||||||
|
{
|
||||||
|
$this->allowedOrganizationalUnits->clear();
|
||||||
|
|
||||||
|
foreach ($allowedOrganizationalUnits as $allowedOrganizationalUnit){
|
||||||
|
$this->addAllowedOrganizationalUnit($allowedOrganizationalUnit);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addAllowedOrganizationalUnit(OrganizationalUnit $allowedOrganizationalUnit): static
|
||||||
|
{
|
||||||
|
if (!$this->allowedOrganizationalUnits->contains($allowedOrganizationalUnit)) {
|
||||||
|
$this->allowedOrganizationalUnits->add($allowedOrganizationalUnit);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function removeAllowedOrganizationalUnit(OrganizationalUnit $allowedOrganizationalUnit): static
|
||||||
|
{
|
||||||
|
$this->allowedOrganizationalUnits->removeElement($allowedOrganizationalUnit);
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,71 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Entity;
|
||||||
|
|
||||||
|
use App\Repository\UserGroupRepository;
|
||||||
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
|
use Doctrine\Common\Collections\Collection;
|
||||||
|
use Doctrine\DBAL\Types\Types;
|
||||||
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
||||||
|
|
||||||
|
#[ORM\Entity(repositoryClass: UserGroupRepository::class)]
|
||||||
|
#[ORM\UniqueConstraint(name: 'UNIQ_IDENTIFIER_NAME', fields: ['name'])]
|
||||||
|
#[UniqueEntity(fields: ['name'], message: 'There is already an role with this name')]
|
||||||
|
class UserGroup extends AbstractEntity
|
||||||
|
{
|
||||||
|
use NameableTrait;
|
||||||
|
use ToggleableTrait;
|
||||||
|
|
||||||
|
#[ORM\Column(type: Types::JSON)]
|
||||||
|
private array $permissions = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Collection<int, User>
|
||||||
|
*/
|
||||||
|
#[ORM\ManyToMany(targetEntity: User::class, inversedBy: 'userGroups')]
|
||||||
|
private Collection $users;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
|
||||||
|
$this->users = new ArrayCollection();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPermissions(): array
|
||||||
|
{
|
||||||
|
return $this->permissions;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setPermissions(array $permissions): static
|
||||||
|
{
|
||||||
|
$this->permissions = $permissions;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Collection<int, User>
|
||||||
|
*/
|
||||||
|
public function getUsers(): Collection
|
||||||
|
{
|
||||||
|
return $this->users;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addUser(User $user): static
|
||||||
|
{
|
||||||
|
if (!$this->users->contains($user)) {
|
||||||
|
$this->users->add($user);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function removeUser(User $user): static
|
||||||
|
{
|
||||||
|
$this->users->removeElement($user);
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,54 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Factory;
|
||||||
|
|
||||||
|
use App\Entity\OrganizationalUnit;
|
||||||
|
use Gedmo\Tree\Entity\Repository\MaterializedPathRepository;
|
||||||
|
use Zenstruck\Foundry\ModelFactory;
|
||||||
|
use Zenstruck\Foundry\Proxy;
|
||||||
|
use Zenstruck\Foundry\RepositoryProxy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @extends ModelFactory<OrganizationalUnit>
|
||||||
|
*/
|
||||||
|
final class OrganizationalUnitFactory extends ModelFactory
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @see https://symfony.com/bundles/ZenstruckFoundryBundle/current/index.html#factories-as-services
|
||||||
|
*
|
||||||
|
* @todo inject services if required
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see https://symfony.com/bundles/ZenstruckFoundryBundle/current/index.html#model-factories
|
||||||
|
*
|
||||||
|
* @todo add your default values here
|
||||||
|
*/
|
||||||
|
protected function getDefaults(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'createdAt' => self::faker()->dateTime(),
|
||||||
|
'name' => self::faker()->text(255),
|
||||||
|
'updatedAt' => self::faker()->dateTime(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see https://symfony.com/bundles/ZenstruckFoundryBundle/current/index.html#initialization
|
||||||
|
*/
|
||||||
|
protected function initialize(): self
|
||||||
|
{
|
||||||
|
return $this
|
||||||
|
// ->afterInstantiate(function(OrganizationalUnit $organizationalUnit): void {})
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static function getClass(): string
|
||||||
|
{
|
||||||
|
return OrganizationalUnit::class;
|
||||||
|
}
|
||||||
|
}
|
|
@ -16,11 +16,6 @@ final class UserFactory extends ModelFactory
|
||||||
{
|
{
|
||||||
CONST PLAIN_PASSWORD = '12345678';
|
CONST PLAIN_PASSWORD = '12345678';
|
||||||
|
|
||||||
/**
|
|
||||||
* @see https://symfony.com/bundles/ZenstruckFoundryBundle/current/index.html#factories-as-services
|
|
||||||
*
|
|
||||||
* @todo inject services if required
|
|
||||||
*/
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
|
|
|
@ -0,0 +1,45 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Factory;
|
||||||
|
|
||||||
|
use App\Entity\UserGroup;
|
||||||
|
use App\Repository\UserGroupRepository;
|
||||||
|
use Zenstruck\Foundry\ModelFactory;
|
||||||
|
use Zenstruck\Foundry\Proxy;
|
||||||
|
use Zenstruck\Foundry\RepositoryProxy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @extends ModelFactory<UserGroup>
|
||||||
|
*/
|
||||||
|
final class UserGroupFactory extends ModelFactory
|
||||||
|
{
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected function getDefaults(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'createdAt' => self::faker()->dateTime(),
|
||||||
|
'permissions' => [],
|
||||||
|
'updatedAt' => self::faker()->dateTime(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see https://symfony.com/bundles/ZenstruckFoundryBundle/current/index.html#initialization
|
||||||
|
*/
|
||||||
|
protected function initialize(): self
|
||||||
|
{
|
||||||
|
return $this
|
||||||
|
// ->afterInstantiate(function(UserGroup $userGroup): void {})
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static function getClass(): string
|
||||||
|
{
|
||||||
|
return UserGroup::class;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Model;
|
||||||
|
|
||||||
|
final class UserGroupPermissions
|
||||||
|
{
|
||||||
|
public const ROLE_SUPER_ADMIN = 'ROLE_SUPER_ADMIN';
|
||||||
|
public const ROLE_ORGANIZATIONAL_UNIT_ADMIN = 'ROLE_ORGANIZATIONAL_UNIT_ADMIN';
|
||||||
|
public const ROLE_ORGANIZATIONAL_UNIT_OPERATOR = 'ROLE_ORGANIZATIONAL_UNIT_OPERATOR';
|
||||||
|
public const ROLE_ORGANIZATIONAL_UNIT_MINIMAL = 'ROLE_ORGANIZATIONAL_UNIT_MINIMAL';
|
||||||
|
|
||||||
|
public const ROLE_USER = 'ROLE_USER';
|
||||||
|
|
||||||
|
private const ROLE_NAMES = [
|
||||||
|
self::ROLE_SUPER_ADMIN => 'Super Admin',
|
||||||
|
self::ROLE_ORGANIZATIONAL_UNIT_ADMIN => 'Admin de aulas',
|
||||||
|
self::ROLE_ORGANIZATIONAL_UNIT_OPERATOR => 'Operador de aulas',
|
||||||
|
self::ROLE_ORGANIZATIONAL_UNIT_MINIMAL => 'Usuario básico de aulas',
|
||||||
|
self::ROLE_USER => 'Usuario',
|
||||||
|
];
|
||||||
|
|
||||||
|
public static function getRoleNames(): array
|
||||||
|
{
|
||||||
|
return self::ROLE_NAMES;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getRoleName(string $role): ?string
|
||||||
|
{
|
||||||
|
return self::ROLE_NAMES[$role] ?? null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getRoles(): array
|
||||||
|
{
|
||||||
|
return array_keys(self::ROLE_NAMES);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Repository;
|
||||||
|
|
||||||
|
use App\Entity\AbstractEntity;
|
||||||
|
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||||
|
use Doctrine\Persistence\ManagerRegistry;
|
||||||
|
|
||||||
|
abstract class AbstractRepository extends ServiceEntityRepository
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
ManagerRegistry $registry,
|
||||||
|
string $entityClass)
|
||||||
|
{
|
||||||
|
parent::__construct($registry, $entityClass);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function save(AbstractEntity $entity, bool $flush = true, ?string $action = null): void
|
||||||
|
{
|
||||||
|
$this->getEntityManager()->persist($entity);
|
||||||
|
|
||||||
|
if ($flush) {
|
||||||
|
$this->getEntityManager()->flush();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function delete (AbstractEntity $entity, bool $flush = true): void
|
||||||
|
{
|
||||||
|
$this->getEntityManager()->remove($entity);
|
||||||
|
|
||||||
|
if ($flush) {
|
||||||
|
$this->getEntityManager()->flush();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,43 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Repository;
|
||||||
|
|
||||||
|
use App\Entity\Client;
|
||||||
|
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||||
|
use Doctrine\Persistence\ManagerRegistry;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @extends ServiceEntityRepository<Client>
|
||||||
|
*/
|
||||||
|
class ClientRepository extends ServiceEntityRepository
|
||||||
|
{
|
||||||
|
public function __construct(ManagerRegistry $registry)
|
||||||
|
{
|
||||||
|
parent::__construct($registry, Client::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * @return Client[] Returns an array of Client objects
|
||||||
|
// */
|
||||||
|
// public function findByExampleField($value): array
|
||||||
|
// {
|
||||||
|
// return $this->createQueryBuilder('c')
|
||||||
|
// ->andWhere('c.exampleField = :val')
|
||||||
|
// ->setParameter('val', $value)
|
||||||
|
// ->orderBy('c.id', 'ASC')
|
||||||
|
// ->setMaxResults(10)
|
||||||
|
// ->getQuery()
|
||||||
|
// ->getResult()
|
||||||
|
// ;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// public function findOneBySomeField($value): ?Client
|
||||||
|
// {
|
||||||
|
// return $this->createQueryBuilder('c')
|
||||||
|
// ->andWhere('c.exampleField = :val')
|
||||||
|
// ->setParameter('val', $value)
|
||||||
|
// ->getQuery()
|
||||||
|
// ->getOneOrNullResult()
|
||||||
|
// ;
|
||||||
|
// }
|
||||||
|
}
|
|
@ -0,0 +1,43 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Repository;
|
||||||
|
|
||||||
|
use App\Entity\NetworkSettings;
|
||||||
|
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||||
|
use Doctrine\Persistence\ManagerRegistry;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @extends ServiceEntityRepository<NetworkSettings>
|
||||||
|
*/
|
||||||
|
class NetworkSettingsRepository extends ServiceEntityRepository
|
||||||
|
{
|
||||||
|
public function __construct(ManagerRegistry $registry)
|
||||||
|
{
|
||||||
|
parent::__construct($registry, NetworkSettings::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * @return NetworkSettings[] Returns an array of NetworkSettings objects
|
||||||
|
// */
|
||||||
|
// public function findByExampleField($value): array
|
||||||
|
// {
|
||||||
|
// return $this->createQueryBuilder('n')
|
||||||
|
// ->andWhere('n.exampleField = :val')
|
||||||
|
// ->setParameter('val', $value)
|
||||||
|
// ->orderBy('n.id', 'ASC')
|
||||||
|
// ->setMaxResults(10)
|
||||||
|
// ->getQuery()
|
||||||
|
// ->getResult()
|
||||||
|
// ;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// public function findOneBySomeField($value): ?NetworkSettings
|
||||||
|
// {
|
||||||
|
// return $this->createQueryBuilder('n')
|
||||||
|
// ->andWhere('n.exampleField = :val')
|
||||||
|
// ->setParameter('val', $value)
|
||||||
|
// ->getQuery()
|
||||||
|
// ->getOneOrNullResult()
|
||||||
|
// ;
|
||||||
|
// }
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Repository;
|
||||||
|
|
||||||
|
use App\Entity\OrganizationalUnit;
|
||||||
|
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||||
|
use Doctrine\Persistence\ManagerRegistry;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @extends ServiceEntityRepository<OrganizationalUnit>
|
||||||
|
*/
|
||||||
|
class OrganizationalUnitRepository extends AbstractRepository
|
||||||
|
{
|
||||||
|
public function __construct(ManagerRegistry $registry)
|
||||||
|
{
|
||||||
|
parent::__construct($registry, OrganizationalUnit::class);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Repository;
|
||||||
|
|
||||||
|
use App\Entity\UserGroup;
|
||||||
|
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||||
|
use Doctrine\Persistence\ManagerRegistry;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @extends ServiceEntityRepository<UserGroup>
|
||||||
|
*/
|
||||||
|
class UserGroupRepository extends AbstractRepository
|
||||||
|
{
|
||||||
|
public function __construct(ManagerRegistry $registry)
|
||||||
|
{
|
||||||
|
parent::__construct($registry, UserGroup::class);
|
||||||
|
}
|
||||||
|
}
|
|
@ -12,7 +12,7 @@ use Symfony\Component\Security\Core\User\PasswordUpgraderInterface;
|
||||||
/**
|
/**
|
||||||
* @extends ServiceEntityRepository<User>
|
* @extends ServiceEntityRepository<User>
|
||||||
*/
|
*/
|
||||||
class UserRepository extends ServiceEntityRepository implements PasswordUpgraderInterface
|
class UserRepository extends AbstractRepository implements PasswordUpgraderInterface
|
||||||
{
|
{
|
||||||
public function __construct(ManagerRegistry $registry)
|
public function __construct(ManagerRegistry $registry)
|
||||||
{
|
{
|
||||||
|
@ -32,29 +32,4 @@ class UserRepository extends ServiceEntityRepository implements PasswordUpgrader
|
||||||
$this->getEntityManager()->persist($user);
|
$this->getEntityManager()->persist($user);
|
||||||
$this->getEntityManager()->flush();
|
$this->getEntityManager()->flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
// /**
|
|
||||||
// * @return User[] Returns an array of User objects
|
|
||||||
// */
|
|
||||||
// public function findByExampleField($value): array
|
|
||||||
// {
|
|
||||||
// return $this->createQueryBuilder('u')
|
|
||||||
// ->andWhere('u.exampleField = :val')
|
|
||||||
// ->setParameter('val', $value)
|
|
||||||
// ->orderBy('u.id', 'ASC')
|
|
||||||
// ->setMaxResults(10)
|
|
||||||
// ->getQuery()
|
|
||||||
// ->getResult()
|
|
||||||
// ;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// public function findOneBySomeField($value): ?User
|
|
||||||
// {
|
|
||||||
// return $this->createQueryBuilder('u')
|
|
||||||
// ->andWhere('u.exampleField = :val')
|
|
||||||
// ->setParameter('val', $value)
|
|
||||||
// ->getQuery()
|
|
||||||
// ->getOneOrNullResult()
|
|
||||||
// ;
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,68 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\State\Processor;
|
||||||
|
|
||||||
|
use ApiPlatform\Metadata\Delete;
|
||||||
|
use ApiPlatform\Metadata\Operation;
|
||||||
|
use ApiPlatform\Metadata\Patch;
|
||||||
|
use ApiPlatform\Metadata\Post;
|
||||||
|
use ApiPlatform\Metadata\Put;
|
||||||
|
use ApiPlatform\State\ProcessorInterface;
|
||||||
|
use ApiPlatform\Validator\ValidatorInterface;
|
||||||
|
use App\Dto\Input\OrganizationalUnitInput;
|
||||||
|
use App\Dto\Output\OrganizationalUnitOutput;
|
||||||
|
use App\Repository\OrganizationalUnitRepository;
|
||||||
|
|
||||||
|
class OrganizationalUnitProcessor implements ProcessorInterface
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
private readonly OrganizationalUnitRepository $organizationalUnitRepository,
|
||||||
|
private readonly ValidatorInterface $validator
|
||||||
|
)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws \Exception
|
||||||
|
*/
|
||||||
|
public function process(mixed $data, Operation $operation, array $uriVariables = [], array $context = []): OrganizationalUnitOutput|null
|
||||||
|
{
|
||||||
|
switch ($operation){
|
||||||
|
case $operation instanceof Post:
|
||||||
|
case $operation instanceof Put:
|
||||||
|
case $operation instanceof Patch:
|
||||||
|
return $this->processCreateOrUpdate($data, $operation, $uriVariables, $context);
|
||||||
|
case $operation instanceof Delete:
|
||||||
|
return $this->processDelete($data, $operation, $uriVariables, $context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws \Exception
|
||||||
|
*/
|
||||||
|
private function processCreateOrUpdate($data, Operation $operation, array $uriVariables = [], array $context = []): OrganizationalUnitOutput
|
||||||
|
{
|
||||||
|
if (!($data instanceof OrganizationalUnitOutput)) {
|
||||||
|
throw new \Exception(sprintf('data is not instance of %s', OrganizationalUnitInput::class));
|
||||||
|
}
|
||||||
|
|
||||||
|
$entity = null;
|
||||||
|
if (isset($uriVariables['uuid'])) {
|
||||||
|
$entity = $this->organizationalUnitRepository->findOneByUuid($uriVariables['uuid']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$organizationalUnit = $data->createOrUpdateEntity($entity);
|
||||||
|
$this->validator->validate($organizationalUnit);
|
||||||
|
$this->organizationalUnitRepository->save($organizationalUnit);
|
||||||
|
|
||||||
|
return new OrganizationalUnitOutput($organizationalUnit);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function processDelete($data, Operation $operation, array $uriVariables = [], array $context = []): null
|
||||||
|
{
|
||||||
|
$user = $this->organizationalUnitRepository->findOneByUuid($uriVariables['uuid']);
|
||||||
|
$this->organizationalUnitRepository->delete($user);
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,68 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\State\Processor;
|
||||||
|
|
||||||
|
use ApiPlatform\Metadata\Delete;
|
||||||
|
use ApiPlatform\Metadata\Operation;
|
||||||
|
use ApiPlatform\Metadata\Patch;
|
||||||
|
use ApiPlatform\Metadata\Post;
|
||||||
|
use ApiPlatform\Metadata\Put;
|
||||||
|
use ApiPlatform\State\ProcessorInterface;
|
||||||
|
use ApiPlatform\Validator\ValidatorInterface;
|
||||||
|
use App\Dto\Input\UserGroupInput;
|
||||||
|
use App\Dto\Output\UserGroupOutput;
|
||||||
|
use App\Repository\UserGroupRepository;
|
||||||
|
|
||||||
|
class UserGroupProcessor implements ProcessorInterface
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
private readonly UserGroupRepository $userGroupRepository,
|
||||||
|
private readonly ValidatorInterface $validator
|
||||||
|
)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws \Exception
|
||||||
|
*/
|
||||||
|
public function process(mixed $data, Operation $operation, array $uriVariables = [], array $context = []): UserGroupOutput|null
|
||||||
|
{
|
||||||
|
switch ($operation){
|
||||||
|
case $operation instanceof Post:
|
||||||
|
case $operation instanceof Put:
|
||||||
|
case $operation instanceof Patch:
|
||||||
|
return $this->processCreateOrUpdate($data, $operation, $uriVariables, $context);
|
||||||
|
case $operation instanceof Delete:
|
||||||
|
return $this->processDelete($data, $operation, $uriVariables, $context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws \Exception
|
||||||
|
*/
|
||||||
|
private function processCreateOrUpdate($data, Operation $operation, array $uriVariables = [], array $context = []): UserGroupOutput
|
||||||
|
{
|
||||||
|
if (!($data instanceof UserGroupInput)) {
|
||||||
|
throw new \Exception(sprintf('data is not instance of %s', UserGroupInput::class));
|
||||||
|
}
|
||||||
|
|
||||||
|
$entity = null;
|
||||||
|
if (isset($uriVariables['uuid'])) {
|
||||||
|
$entity = $this->userGroupRepository->findOneByUuid($uriVariables['uuid']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$userGroup = $data->createOrUpdateEntity($entity);
|
||||||
|
$this->validator->validate($userGroup);
|
||||||
|
$this->userGroupRepository->save($userGroup);
|
||||||
|
|
||||||
|
return new UserGroupOutput($userGroup);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function processDelete($data, Operation $operation, array $uriVariables = [], array $context = []): null
|
||||||
|
{
|
||||||
|
$user = $this->userGroupRepository->findOneByUuid($uriVariables['uuid']);
|
||||||
|
$this->userGroupRepository->delete($user);
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,75 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\State\Processor;
|
||||||
|
|
||||||
|
use ApiPlatform\Metadata\Delete;
|
||||||
|
use ApiPlatform\Metadata\Operation;
|
||||||
|
use ApiPlatform\Metadata\Patch;
|
||||||
|
use ApiPlatform\Metadata\Post;
|
||||||
|
use ApiPlatform\Metadata\Put;
|
||||||
|
use ApiPlatform\State\ProcessorInterface;
|
||||||
|
use ApiPlatform\Validator\ValidatorInterface;
|
||||||
|
use App\Dto\Input\UserInput;
|
||||||
|
use App\Dto\Output\UserOutput;
|
||||||
|
use App\Repository\UserRepository;
|
||||||
|
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
|
||||||
|
|
||||||
|
class UserProcessor implements ProcessorInterface
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
private readonly UserRepository $userRepository,
|
||||||
|
private readonly ValidatorInterface $validator,
|
||||||
|
private readonly UserPasswordHasherInterface $userPasswordHasher
|
||||||
|
)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws \Exception
|
||||||
|
*/
|
||||||
|
public function process(mixed $data, Operation $operation, array $uriVariables = [], array $context = []): UserOutput|null
|
||||||
|
{
|
||||||
|
switch ($operation){
|
||||||
|
case $operation instanceof Post:
|
||||||
|
case $operation instanceof Put:
|
||||||
|
case $operation instanceof Patch:
|
||||||
|
return $this->processCreateOrUpdate($data, $operation, $uriVariables, $context);
|
||||||
|
case $operation instanceof Delete:
|
||||||
|
return $this->processDelete($data, $operation, $uriVariables, $context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws \Exception
|
||||||
|
*/
|
||||||
|
private function processCreateOrUpdate($data, Operation $operation, array $uriVariables = [], array $context = []): UserOutput
|
||||||
|
{
|
||||||
|
if (!($data instanceof UserInput)) {
|
||||||
|
throw new \Exception(sprintf('data is not instance of %s', UserInput::class));
|
||||||
|
}
|
||||||
|
|
||||||
|
$user = null;
|
||||||
|
if (isset($uriVariables['uuid'])) {
|
||||||
|
$user = $this->userRepository->findOneByUuid($uriVariables['uuid']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$user = $data->createOrUpdateEntity($user);
|
||||||
|
|
||||||
|
if ($data->password !== null){
|
||||||
|
$user->setPassword($this->userPasswordHasher->hashPassword($user, $data->password));
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->validator->validate($user);
|
||||||
|
$this->userRepository->save($user);
|
||||||
|
|
||||||
|
return new UserOutput($user);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function processDelete($data, Operation $operation, array $uriVariables = [], array $context = []): null
|
||||||
|
{
|
||||||
|
$user = $this->userRepository->findOneByUuid($uriVariables['uuid']);
|
||||||
|
$this->userRepository->delete($user);
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,71 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\State\Provider;
|
||||||
|
|
||||||
|
use ApiPlatform\Metadata\Get;
|
||||||
|
use ApiPlatform\Metadata\GetCollection;
|
||||||
|
use ApiPlatform\Metadata\Operation;
|
||||||
|
use ApiPlatform\Metadata\Patch;
|
||||||
|
use ApiPlatform\Metadata\Put;
|
||||||
|
use ApiPlatform\State\Pagination\TraversablePaginator;
|
||||||
|
use ApiPlatform\State\ProviderInterface;
|
||||||
|
use App\Dto\Input\UserGroupInput;
|
||||||
|
use App\Dto\Output\OrganizationalUnitOutput;
|
||||||
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||||
|
|
||||||
|
class OrganizationalUnitProvider implements ProviderInterface
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
private readonly ProviderInterface $collectionProvider,
|
||||||
|
private readonly ProviderInterface $itemProvider
|
||||||
|
)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function provide(Operation $operation, array $uriVariables = [], array $context = []): object|array|null
|
||||||
|
{
|
||||||
|
switch ($operation){
|
||||||
|
case $operation instanceof GetCollection:
|
||||||
|
return $this->provideCollection($operation, $uriVariables, $context);
|
||||||
|
case $operation instanceof Patch:
|
||||||
|
case $operation instanceof Put:
|
||||||
|
return $this->provideInput($operation, $uriVariables, $context);
|
||||||
|
case $operation instanceof Get:
|
||||||
|
return $this->provideItem($operation, $uriVariables, $context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function provideCollection(Operation $operation, array $uriVariables = [], array $context = []): object
|
||||||
|
{
|
||||||
|
$paginator = $this->collectionProvider->provide($operation, $uriVariables, $context);
|
||||||
|
|
||||||
|
$items = new \ArrayObject();
|
||||||
|
foreach ($paginator->getIterator() as $item){
|
||||||
|
$items[] = new OrganizationalUnitOutput($item);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new TraversablePaginator($items, $paginator->getCurrentPage(), $paginator->getItemsPerPage(), $paginator->getTotalItems());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function provideItem(Operation $operation, array $uriVariables = [], array $context = []): object|array|null
|
||||||
|
{
|
||||||
|
$item = $this->itemProvider->provide($operation, $uriVariables, $context);
|
||||||
|
|
||||||
|
if (!$item) {
|
||||||
|
throw new NotFoundHttpException('Organizational unit not found');
|
||||||
|
}
|
||||||
|
|
||||||
|
return new OrganizationalUnitOutput($item);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function provideInput(Operation $operation, array $uriVariables = [], array $context = []): object|array|null
|
||||||
|
{
|
||||||
|
if (isset($uriVariables['uuid'])) {
|
||||||
|
$item = $this->itemProvider->provide($operation, $uriVariables, $context);
|
||||||
|
|
||||||
|
return $item !== null ? new UserGroupInput($item) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new UserGroupInput();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,71 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\State\Provider;
|
||||||
|
|
||||||
|
use ApiPlatform\Metadata\Get;
|
||||||
|
use ApiPlatform\Metadata\GetCollection;
|
||||||
|
use ApiPlatform\Metadata\Operation;
|
||||||
|
use ApiPlatform\Metadata\Patch;
|
||||||
|
use ApiPlatform\Metadata\Put;
|
||||||
|
use ApiPlatform\State\Pagination\TraversablePaginator;
|
||||||
|
use ApiPlatform\State\ProviderInterface;
|
||||||
|
use App\Dto\Input\UserGroupInput;
|
||||||
|
use App\Dto\Output\UserGroupOutput;
|
||||||
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||||
|
|
||||||
|
class UserGroupProvider implements ProviderInterface
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
private readonly ProviderInterface $collectionProvider,
|
||||||
|
private readonly ProviderInterface $itemProvider
|
||||||
|
)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function provide(Operation $operation, array $uriVariables = [], array $context = []): object|array|null
|
||||||
|
{
|
||||||
|
switch ($operation){
|
||||||
|
case $operation instanceof GetCollection:
|
||||||
|
return $this->provideCollection($operation, $uriVariables, $context);
|
||||||
|
case $operation instanceof Patch:
|
||||||
|
case $operation instanceof Put:
|
||||||
|
return $this->provideInput($operation, $uriVariables, $context);
|
||||||
|
case $operation instanceof Get:
|
||||||
|
return $this->provideItem($operation, $uriVariables, $context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function provideCollection(Operation $operation, array $uriVariables = [], array $context = []): object|array|null
|
||||||
|
{
|
||||||
|
$paginator = $this->collectionProvider->provide($operation, $uriVariables, $context);
|
||||||
|
|
||||||
|
$items = new \ArrayObject();
|
||||||
|
foreach ($paginator->getIterator() as $item){
|
||||||
|
$items[] = new UserGroupOutput($item);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new TraversablePaginator($items, $paginator->getCurrentPage(), $paginator->getItemsPerPage(), $paginator->getTotalItems());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function provideItem(Operation $operation, array $uriVariables = [], array $context = []): object|array|null
|
||||||
|
{
|
||||||
|
$item = $this->itemProvider->provide($operation, $uriVariables, $context);
|
||||||
|
|
||||||
|
if (!$item) {
|
||||||
|
throw new NotFoundHttpException('User Group not found');
|
||||||
|
}
|
||||||
|
|
||||||
|
return new UserGroupOutput($item);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function provideInput(Operation $operation, array $uriVariables = [], array $context = []): object|array|null
|
||||||
|
{
|
||||||
|
if (isset($uriVariables['uuid'])) {
|
||||||
|
$item = $this->itemProvider->provide($operation, $uriVariables, $context);
|
||||||
|
|
||||||
|
return $item !== null ? new UserGroupInput($item) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new UserGroupInput();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,71 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\State\Provider;
|
||||||
|
|
||||||
|
use ApiPlatform\Metadata\Get;
|
||||||
|
use ApiPlatform\Metadata\GetCollection;
|
||||||
|
use ApiPlatform\Metadata\Operation;
|
||||||
|
use ApiPlatform\Metadata\Patch;
|
||||||
|
use ApiPlatform\Metadata\Put;
|
||||||
|
use ApiPlatform\State\Pagination\TraversablePaginator;
|
||||||
|
use ApiPlatform\State\ProviderInterface;
|
||||||
|
use App\Dto\Input\UserInput;
|
||||||
|
use App\Dto\Output\UserOutput;
|
||||||
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||||
|
|
||||||
|
class UserProvider implements ProviderInterface
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
private readonly ProviderInterface $collectionProvider,
|
||||||
|
private readonly ProviderInterface $itemProvider
|
||||||
|
)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function provide(Operation $operation, array $uriVariables = [], array $context = []): object|array|null
|
||||||
|
{
|
||||||
|
switch ($operation){
|
||||||
|
case $operation instanceof GetCollection:
|
||||||
|
return $this->provideCollection($operation, $uriVariables, $context);
|
||||||
|
case $operation instanceof Patch:
|
||||||
|
case $operation instanceof Put:
|
||||||
|
return $this->provideInput($operation, $uriVariables, $context);
|
||||||
|
case $operation instanceof Get:
|
||||||
|
return $this->provideItem($operation, $uriVariables, $context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function provideCollection(Operation $operation, array $uriVariables = [], array $context = []): object|array|null
|
||||||
|
{
|
||||||
|
$paginator = $this->collectionProvider->provide($operation, $uriVariables, $context);
|
||||||
|
|
||||||
|
$items = new \ArrayObject();
|
||||||
|
foreach ($paginator->getIterator() as $item){
|
||||||
|
$items[] = new UserOutput($item);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new TraversablePaginator($items, $paginator->getCurrentPage(), $paginator->getItemsPerPage(), $paginator->getTotalItems());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function provideItem(Operation $operation, array $uriVariables = [], array $context = []): object|array|null
|
||||||
|
{
|
||||||
|
$item = $this->itemProvider->provide($operation, $uriVariables, $context);
|
||||||
|
|
||||||
|
if (!$item) {
|
||||||
|
throw new NotFoundHttpException('User not found');
|
||||||
|
}
|
||||||
|
|
||||||
|
return new UserOutput($item);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function provideInput(Operation $operation, array $uriVariables = [], array $context = []): object|array|null
|
||||||
|
{
|
||||||
|
if (isset($uriVariables['uuid'])) {
|
||||||
|
$item = $this->itemProvider->provide($operation, $uriVariables, $context);
|
||||||
|
|
||||||
|
return $item !== null ? new UserInput($item) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new UserInput();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Validator\Constraints;
|
||||||
|
|
||||||
|
use App\Model\UserGroupPermissions;
|
||||||
|
use Symfony\Component\Validator\Constraint;
|
||||||
|
|
||||||
|
#[\Attribute]
|
||||||
|
class UserGroupsValidPermission extends Constraint
|
||||||
|
{
|
||||||
|
private array $roles;
|
||||||
|
public string $message;
|
||||||
|
|
||||||
|
public function __construct(mixed $options = null, ?array $groups = null, mixed $payload = null)
|
||||||
|
{
|
||||||
|
parent::__construct($options, $groups, $payload);
|
||||||
|
|
||||||
|
$this->roles = UserGroupPermissions::getRoles();
|
||||||
|
$this->message = sprintf(
|
||||||
|
'The permission is not valid. Please use one of the following: %s',
|
||||||
|
implode(', ', $this->roles)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Validator\Constraints;
|
||||||
|
|
||||||
|
use App\Model\UserGroupPermissions;
|
||||||
|
use Symfony\Component\Validator\Constraint;
|
||||||
|
use Symfony\Component\Validator\ConstraintValidator;
|
||||||
|
|
||||||
|
class UserGroupsValidPermissionValidator extends ConstraintValidator
|
||||||
|
{
|
||||||
|
public function validate($value, Constraint $constraint): void
|
||||||
|
{
|
||||||
|
if (null === $value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($value as $role) {
|
||||||
|
if (!in_array($role, UserGroupPermissions::getRoles())) {
|
||||||
|
$this->context->buildViolation($constraint->message)->addViolation();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Binary file not shown.
After Width: | Height: | Size: 39 KiB |
Binary file not shown.
After Width: | Height: | Size: 119 KiB |
Binary file not shown.
After Width: | Height: | Size: 130 KiB |
65
symfony.lock
65
symfony.lock
|
@ -13,6 +13,18 @@
|
||||||
"src/ApiResource/.gitignore"
|
"src/ApiResource/.gitignore"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"dama/doctrine-test-bundle": {
|
||||||
|
"version": "8.1",
|
||||||
|
"recipe": {
|
||||||
|
"repo": "github.com/symfony/recipes-contrib",
|
||||||
|
"branch": "main",
|
||||||
|
"version": "7.2",
|
||||||
|
"ref": "896306d79d4ee143af9eadf9b09fd34a8c391b70"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"config/packages/dama_doctrine_test_bundle.yaml"
|
||||||
|
]
|
||||||
|
},
|
||||||
"doctrine/doctrine-bundle": {
|
"doctrine/doctrine-bundle": {
|
||||||
"version": "2.12",
|
"version": "2.12",
|
||||||
"recipe": {
|
"recipe": {
|
||||||
|
@ -90,6 +102,44 @@
|
||||||
"config/packages/nelmio_cors.yaml"
|
"config/packages/nelmio_cors.yaml"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"phpunit/phpunit": {
|
||||||
|
"version": "9.6",
|
||||||
|
"recipe": {
|
||||||
|
"repo": "github.com/symfony/recipes",
|
||||||
|
"branch": "main",
|
||||||
|
"version": "9.6",
|
||||||
|
"ref": "7364a21d87e658eb363c5020c072ecfdc12e2326"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
".env.test",
|
||||||
|
"phpunit.xml.dist",
|
||||||
|
"tests/bootstrap.php"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"ramsey/uuid-doctrine": {
|
||||||
|
"version": "2.0",
|
||||||
|
"recipe": {
|
||||||
|
"repo": "github.com/symfony/recipes-contrib",
|
||||||
|
"branch": "main",
|
||||||
|
"version": "1.3",
|
||||||
|
"ref": "471aed0fbf5620b8d7f92b7a5ebbbf6c0945c27a"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"config/packages/ramsey_uuid_doctrine.yaml"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"stof/doctrine-extensions-bundle": {
|
||||||
|
"version": "1.10",
|
||||||
|
"recipe": {
|
||||||
|
"repo": "github.com/symfony/recipes-contrib",
|
||||||
|
"branch": "main",
|
||||||
|
"version": "1.2",
|
||||||
|
"ref": "e805aba9eff5372e2d149a9ff56566769e22819d"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"config/packages/stof_doctrine_extensions.yaml"
|
||||||
|
]
|
||||||
|
},
|
||||||
"symfony/console": {
|
"symfony/console": {
|
||||||
"version": "6.4",
|
"version": "6.4",
|
||||||
"recipe": {
|
"recipe": {
|
||||||
|
@ -142,6 +192,21 @@
|
||||||
"ref": "fadbfe33303a76e25cb63401050439aa9b1a9c7f"
|
"ref": "fadbfe33303a76e25cb63401050439aa9b1a9c7f"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"symfony/phpunit-bridge": {
|
||||||
|
"version": "7.0",
|
||||||
|
"recipe": {
|
||||||
|
"repo": "github.com/symfony/recipes",
|
||||||
|
"branch": "main",
|
||||||
|
"version": "6.3",
|
||||||
|
"ref": "a411a0480041243d97382cac7984f7dce7813c08"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
".env.test",
|
||||||
|
"bin/phpunit",
|
||||||
|
"phpunit.xml.dist",
|
||||||
|
"tests/bootstrap.php"
|
||||||
|
]
|
||||||
|
},
|
||||||
"symfony/routing": {
|
"symfony/routing": {
|
||||||
"version": "6.4",
|
"version": "6.4",
|
||||||
"recipe": {
|
"recipe": {
|
||||||
|
|
|
@ -0,0 +1,73 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Functional;
|
||||||
|
|
||||||
|
use ApiPlatform\Symfony\Bundle\Test\ApiTestCase;
|
||||||
|
use ApiPlatform\Symfony\Bundle\Test\Client;
|
||||||
|
use App\Factory\UserFactory;
|
||||||
|
use Faker\Factory;
|
||||||
|
use Faker\Generator;
|
||||||
|
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
|
||||||
|
use Symfony\Contracts\HttpClient\Exception\DecodingExceptionInterface;
|
||||||
|
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
|
||||||
|
use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
|
||||||
|
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
|
||||||
|
use Zenstruck\Foundry\Test\Factories;
|
||||||
|
use Zenstruck\Foundry\Test\ResetDatabase;
|
||||||
|
|
||||||
|
abstract class AbstractTest extends ApiTestCase
|
||||||
|
{
|
||||||
|
use ResetDatabase, Factories;
|
||||||
|
|
||||||
|
protected static Client $client;
|
||||||
|
protected static Generator $faker;
|
||||||
|
private ?string $token = null;
|
||||||
|
|
||||||
|
public function setUp(): void
|
||||||
|
{
|
||||||
|
parent::setUp();
|
||||||
|
self::bootKernel();
|
||||||
|
|
||||||
|
self::$client = static::createClient();
|
||||||
|
self::$faker = Factory::create();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws TransportExceptionInterface
|
||||||
|
* @throws ServerExceptionInterface
|
||||||
|
* @throws RedirectionExceptionInterface
|
||||||
|
* @throws DecodingExceptionInterface
|
||||||
|
* @throws ClientExceptionInterface
|
||||||
|
*/
|
||||||
|
protected function getToken($body = []): string
|
||||||
|
{
|
||||||
|
if ($this->token) {
|
||||||
|
return $this->token;
|
||||||
|
}
|
||||||
|
|
||||||
|
$response = static::createClient()->request('POST', '/auth/login', ['json' => $body ?: [
|
||||||
|
'username' => 'ogadmin',
|
||||||
|
'password' => '12345678',
|
||||||
|
]]);
|
||||||
|
|
||||||
|
$this->assertResponseIsSuccessful();
|
||||||
|
$data = $response->toArray();
|
||||||
|
$this->token = $data['token'];
|
||||||
|
|
||||||
|
return $data['token'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws TransportExceptionInterface
|
||||||
|
* @throws ServerExceptionInterface
|
||||||
|
* @throws RedirectionExceptionInterface
|
||||||
|
* @throws DecodingExceptionInterface
|
||||||
|
* @throws ClientExceptionInterface
|
||||||
|
*/
|
||||||
|
protected function createClientWithCredentials($token = null): Client
|
||||||
|
{
|
||||||
|
$token = $token ?: $this->getToken();
|
||||||
|
|
||||||
|
return static::createClient([], ['headers' => ['authorization' => 'Bearer '.$token]]);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,126 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Functional;
|
||||||
|
|
||||||
|
use App\Entity\User;
|
||||||
|
use App\Entity\UserGroup;
|
||||||
|
use App\Factory\UserFactory;
|
||||||
|
use App\Factory\UserGroupFactory;
|
||||||
|
use App\Model\UserGroupPermissions;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
|
||||||
|
use Symfony\Contracts\HttpClient\Exception\DecodingExceptionInterface;
|
||||||
|
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
|
||||||
|
use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
|
||||||
|
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
|
||||||
|
|
||||||
|
class UserGroupTest extends AbstractTest
|
||||||
|
{
|
||||||
|
CONST USER_ADMIN = 'ogadmin';
|
||||||
|
|
||||||
|
CONST USER_GROUP_CREATE = 'test-user-group-create';
|
||||||
|
CONST USER_GROUP_UPDATE = 'test-user-group-update';
|
||||||
|
CONST USER_GROUP_DELETE = 'test-user-group-delete';
|
||||||
|
CONST ROLE_ORGANIZATIONAL_UNIT_ADMIN = 'ROLE_ORGANIZATIONAL_UNIT_ADMIN';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws RedirectionExceptionInterface
|
||||||
|
* @throws DecodingExceptionInterface
|
||||||
|
* @throws ClientExceptionInterface
|
||||||
|
* @throws TransportExceptionInterface
|
||||||
|
* @throws ServerExceptionInterface
|
||||||
|
*/
|
||||||
|
public function testGetCollectionUserGroup(): void
|
||||||
|
{
|
||||||
|
UserFactory::createOne(['username' => self::USER_ADMIN, 'roles'=> [UserGroupPermissions::ROLE_SUPER_ADMIN]]);
|
||||||
|
|
||||||
|
UserGroupFactory::createOne(['name' => 'Super Admin', 'permissions' => ['ROLE_SUPER_ADMIN'], 'enabled' => true]);
|
||||||
|
UserGroupFactory::createOne(['name' => 'Administrador de aulas', 'permissions' => ['ROLE_ORGANIZATIONAL_UNIT_ADMIN'], 'enabled' => true]);
|
||||||
|
UserGroupFactory::createOne(['name' => 'Operador de aulas', 'permissions' => ['ROLE_ORGANIZATIONAL_UNIT_OPERATOR'], 'enabled' => true]);
|
||||||
|
UserGroupFactory::createOne(['name' => 'Usuario', 'permissions' => ['ROLE_USER'], 'enabled' => true]);
|
||||||
|
|
||||||
|
$this->createClientWithCredentials()->request('GET', '/user-groups');
|
||||||
|
$this->assertResponseStatusCodeSame(Response::HTTP_OK);
|
||||||
|
$this->assertResponseHeaderSame('content-type', 'application/ld+json; charset=utf-8');
|
||||||
|
$this->assertJsonContains([
|
||||||
|
'@context' => '/contexts/UserGroup',
|
||||||
|
'@id' => '/user-groups',
|
||||||
|
'@type' => 'hydra:Collection',
|
||||||
|
'hydra:totalItems' => 4,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws RedirectionExceptionInterface
|
||||||
|
* @throws DecodingExceptionInterface
|
||||||
|
* @throws ClientExceptionInterface
|
||||||
|
* @throws TransportExceptionInterface
|
||||||
|
* @throws ServerExceptionInterface
|
||||||
|
*/
|
||||||
|
public function testCreateUserGroup(): void
|
||||||
|
{
|
||||||
|
UserFactory::createOne(['username' => self::USER_ADMIN, 'roles'=> [UserGroupPermissions::ROLE_SUPER_ADMIN]]);
|
||||||
|
$this->createClientWithCredentials()->request('POST', '/user-groups',['json' => [
|
||||||
|
'name' => self::USER_GROUP_CREATE,
|
||||||
|
'enabled' => true,
|
||||||
|
]]);
|
||||||
|
|
||||||
|
$this->assertResponseStatusCodeSame(201);
|
||||||
|
$this->assertResponseHeaderSame('content-type', 'application/ld+json; charset=utf-8');
|
||||||
|
$this->assertJsonContains([
|
||||||
|
'@context' => '/contexts/UserGroupOutput',
|
||||||
|
'@type' => 'UserGroup',
|
||||||
|
'name' => self::USER_GROUP_CREATE,
|
||||||
|
'enabled' => true,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws RedirectionExceptionInterface
|
||||||
|
* @throws DecodingExceptionInterface
|
||||||
|
* @throws ClientExceptionInterface
|
||||||
|
* @throws TransportExceptionInterface
|
||||||
|
* @throws ServerExceptionInterface
|
||||||
|
*/
|
||||||
|
public function testUpdateUserGroup(): void
|
||||||
|
{
|
||||||
|
UserFactory::createOne(['username' => self::USER_ADMIN, 'roles'=> [UserGroupPermissions::ROLE_SUPER_ADMIN]]);
|
||||||
|
|
||||||
|
UserGroupFactory::createOne(['name' => self::USER_GROUP_UPDATE]);
|
||||||
|
$iri = $this->findIriBy(UserGroup::class, ['name' => self::USER_GROUP_UPDATE]);
|
||||||
|
|
||||||
|
$this->createClientWithCredentials()->request('PATCH', $iri, ['json' => [
|
||||||
|
'name' => self::USER_GROUP_UPDATE,
|
||||||
|
'enabled' => false
|
||||||
|
]]);
|
||||||
|
|
||||||
|
$this->assertResponseIsSuccessful();
|
||||||
|
$this->assertJsonContains([
|
||||||
|
'@id' => $iri,
|
||||||
|
'name' => self::USER_GROUP_UPDATE,
|
||||||
|
'enabled' => false
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws TransportExceptionInterface
|
||||||
|
* @throws ServerExceptionInterface
|
||||||
|
* @throws RedirectionExceptionInterface
|
||||||
|
* @throws DecodingExceptionInterface
|
||||||
|
* @throws ClientExceptionInterface
|
||||||
|
*/
|
||||||
|
public function testDeleteUser(): void
|
||||||
|
{
|
||||||
|
UserFactory::createOne(['username' => self::USER_ADMIN, 'roles'=> [UserGroupPermissions::ROLE_SUPER_ADMIN]]);
|
||||||
|
UserGroupFactory::createOne(['name' => self::USER_GROUP_DELETE]);
|
||||||
|
|
||||||
|
$iri = $this->findIriBy(UserGroup::class, ['name' => self::USER_GROUP_DELETE]);
|
||||||
|
|
||||||
|
$this->createClientWithCredentials()->request('DELETE', $iri);
|
||||||
|
$this->assertResponseStatusCodeSame(204);
|
||||||
|
$this->assertNull(
|
||||||
|
static::getContainer()->get('doctrine')->getRepository(UserGroup::class)->findOneBy(['name' => self::USER_GROUP_DELETE])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,116 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Functional;
|
||||||
|
|
||||||
|
use App\Entity\User;
|
||||||
|
use App\Factory\UserFactory;
|
||||||
|
use App\Model\UserGroupPermissions;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
|
||||||
|
use Symfony\Contracts\HttpClient\Exception\DecodingExceptionInterface;
|
||||||
|
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
|
||||||
|
use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
|
||||||
|
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
|
||||||
|
|
||||||
|
class UserTest extends AbstractTest
|
||||||
|
{
|
||||||
|
CONST USER_ADMIN = 'ogadmin';
|
||||||
|
CONST USER_CREATE = 'test-user-create';
|
||||||
|
CONST USER_UPDATE = 'test-user-update';
|
||||||
|
CONST USER_DELETE = 'test-user-delete';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws RedirectionExceptionInterface
|
||||||
|
* @throws DecodingExceptionInterface
|
||||||
|
* @throws ClientExceptionInterface
|
||||||
|
* @throws TransportExceptionInterface
|
||||||
|
* @throws ServerExceptionInterface
|
||||||
|
*/
|
||||||
|
public function testGetCollectionUser(): void
|
||||||
|
{
|
||||||
|
UserFactory::createOne(['username' => self::USER_ADMIN, 'roles'=> [UserGroupPermissions::ROLE_SUPER_ADMIN]]);
|
||||||
|
UserFactory::createMany(10);
|
||||||
|
|
||||||
|
$this->createClientWithCredentials()->request('GET', '/users');
|
||||||
|
$this->assertResponseStatusCodeSame(Response::HTTP_OK);
|
||||||
|
$this->assertResponseHeaderSame('content-type', 'application/ld+json; charset=utf-8');
|
||||||
|
$this->assertJsonContains([
|
||||||
|
'@context' => '/contexts/User',
|
||||||
|
'@id' => '/users',
|
||||||
|
'@type' => 'hydra:Collection',
|
||||||
|
'hydra:totalItems' => 11,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws RedirectionExceptionInterface
|
||||||
|
* @throws DecodingExceptionInterface
|
||||||
|
* @throws ClientExceptionInterface
|
||||||
|
* @throws TransportExceptionInterface
|
||||||
|
* @throws ServerExceptionInterface
|
||||||
|
*/
|
||||||
|
public function testCreateUser(): void
|
||||||
|
{
|
||||||
|
UserFactory::createOne(['username' => self::USER_ADMIN, 'roles'=> [UserGroupPermissions::ROLE_SUPER_ADMIN]]);
|
||||||
|
$this->createClientWithCredentials()->request('POST', '/users',['json' => [
|
||||||
|
'username' => self::USER_CREATE,
|
||||||
|
'password' => '12345678',
|
||||||
|
'enabled' => true,
|
||||||
|
]]);
|
||||||
|
|
||||||
|
$this->assertResponseStatusCodeSame(201);
|
||||||
|
$this->assertResponseHeaderSame('content-type', 'application/ld+json; charset=utf-8');
|
||||||
|
$this->assertJsonContains([
|
||||||
|
'@context' => '/contexts/UserOutput',
|
||||||
|
'@type' => 'User',
|
||||||
|
'username' => self::USER_CREATE,
|
||||||
|
'enabled' => true,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws RedirectionExceptionInterface
|
||||||
|
* @throws DecodingExceptionInterface
|
||||||
|
* @throws ClientExceptionInterface
|
||||||
|
* @throws TransportExceptionInterface
|
||||||
|
* @throws ServerExceptionInterface
|
||||||
|
*/
|
||||||
|
public function testUpdateUser(): void
|
||||||
|
{
|
||||||
|
UserFactory::createOne(['username' => self::USER_ADMIN, 'roles'=> [UserGroupPermissions::ROLE_SUPER_ADMIN]]);
|
||||||
|
UserFactory::createOne(['username' => self::USER_UPDATE, 'roles'=> [UserGroupPermissions::ROLE_SUPER_ADMIN]]);
|
||||||
|
|
||||||
|
$iri = $this->findIriBy(User::class, ['username' => self::USER_UPDATE]);
|
||||||
|
|
||||||
|
$this->createClientWithCredentials()->request('PATCH', $iri, ['json' => [
|
||||||
|
'username' => self::USER_UPDATE,
|
||||||
|
]]);
|
||||||
|
|
||||||
|
$this->assertResponseIsSuccessful();
|
||||||
|
$this->assertJsonContains([
|
||||||
|
'@id' => $iri,
|
||||||
|
'username' => self::USER_UPDATE,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws TransportExceptionInterface
|
||||||
|
* @throws ServerExceptionInterface
|
||||||
|
* @throws RedirectionExceptionInterface
|
||||||
|
* @throws DecodingExceptionInterface
|
||||||
|
* @throws ClientExceptionInterface
|
||||||
|
*/
|
||||||
|
public function testDeleteUser(): void
|
||||||
|
{
|
||||||
|
UserFactory::createOne(['username' => self::USER_ADMIN, 'roles'=> [UserGroupPermissions::ROLE_SUPER_ADMIN]]);
|
||||||
|
UserFactory::createOne(['username' => self::USER_DELETE, 'roles'=> [UserGroupPermissions::ROLE_SUPER_ADMIN]]);
|
||||||
|
|
||||||
|
$iri = $this->findIriBy(User::class, ['username' => self::USER_DELETE]);
|
||||||
|
|
||||||
|
$this->createClientWithCredentials()->request('DELETE', $iri);
|
||||||
|
$this->assertResponseStatusCodeSame(204);
|
||||||
|
$this->assertNull(
|
||||||
|
static::getContainer()->get('doctrine')->getRepository(User::class)->findOneBy(['username' => self::USER_DELETE])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Symfony\Component\Dotenv\Dotenv;
|
||||||
|
|
||||||
|
require dirname(__DIR__).'/vendor/autoload.php';
|
||||||
|
|
||||||
|
if (method_exists(Dotenv::class, 'bootEnv')) {
|
||||||
|
(new Dotenv())->bootEnv(dirname(__DIR__).'/.env');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($_SERVER['APP_DEBUG']) {
|
||||||
|
umask(0000);
|
||||||
|
}
|
Loading…
Reference in New Issue