Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/ADF-660/ParamConverter #3148

Draft
wants to merge 22 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
0a20a06
feat: ParamConverter
shpran Sep 29, 2021
3cbfd86
refactor: remove unnecessary code
shpran Sep 29, 2021
06a9814
refactor: replace with import
shpran Sep 29, 2021
9bb2662
refactor: prettify code
shpran Sep 29, 2021
c05733d
refactor: add missed DockBlocks, remove unnecessary code
shpran Sep 29, 2021
30c3797
refactor: use interfaces, create converted object via reflection
shpran Sep 29, 2021
a3b69fc
refactor: add DockBlocks, remove unnecessary use-statements
shpran Sep 29, 2021
96839ca
refactor: apply dependency inversion principle, prettify code
shpran Sep 29, 2021
65e48a8
refactor: apply php-cs-fixer on manifest
shpran Sep 29, 2021
0961acb
refactor: remove commented lines
shpran Sep 29, 2021
9046d66
refactor: group use statements and separate with a line
shpran Sep 29, 2021
acf7b8e
refactor: register event, ignore 'requiresRight' annotation
shpran Sep 30, 2021
09f10f2
feat: implement serializer, use serializer to deserialize param conve…
shpran Oct 13, 2021
78dc40e
Merge branch 'develop' of https://github.com/oat-sa/tao-core into fea…
shpran Oct 13, 2021
d4138c0
refactor: add missed dockblocks
shpran Oct 13, 2021
73bfb1e
Merge branch 'develop' of https://github.com/oat-sa/tao-core into fea…
shpran Nov 9, 2021
b1d01ee
tests: add classes and test action for perfomance testing
shpran Nov 15, 2021
eeb886d
refactor: remove author and change year
shpran Nov 20, 2021
1f13082
Merge branch 'develop' of https://github.com/oat-sa/tao-core into fea…
shpran Dec 3, 2021
43c14bb
refactor: use method instead of passing ParamConverters through the …
shpran Dec 3, 2021
e8909b3
Merge branch 'develop' of https://github.com/oat-sa/tao-core into fea…
shpran Feb 1, 2022
2f40a90
Merge branch 'develop' of https://github.com/oat-sa/tao-core into fea…
shpran Mar 21, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions actions/class.TestAction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php

/**
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; under version 2
* of the License (non-upgradable).
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Copyright (c) 2021 (original work) Open Assessment Technologies SA;
*/

declare(strict_types=1);

use oat\tao\model\TestParamConverter\Query;
use oat\tao\model\http\HttpJsonResponseTrait;
use oat\tao\model\ParamConverter\Configuration\ParamConverter;

class tao_actions_TestAction extends tao_actions_CommonModule
{
use HttpJsonResponseTrait;

public function withoutParamConverter(): void
{
$uri = $this->getGetParameter('uri');
$listOfUris = $this->getGetParameter('listOfUris');
$subQuery = $this->getGetParameter('subQuery');

$subQueryUri = $subQuery['uri'] ?? '';
$subQueryValue = $subQuery['value'] ?? 0;

$this->setSuccessJsonResponse(__METHOD__);
}

/**
* @ParamConverter("query", converter="oat.tao.param_converter.query")
*/
public function withParamConverter(Query $query): void
{
$uri = $query->getUri();
$listOfUris = $query->getListOfUris();

$subQueryUri = $query->getSubQuery()->getUri();
$subQueryValue = $query->getSubQuery()->getValue();

$this->setSuccessJsonResponse(__METHOD__);
}
}
6 changes: 5 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,11 @@
"flow/jsonpath": "~0.5",
"jtl-software/opsgenie-client": "2.0.2",
"league/openapi-psr7-validator": "0.9",
"relay/relay": "~2.0"
"relay/relay": "~2.0",
"symfony/serializer": "~5.2.0",
"symfony/http-foundation": "^5.3",
"symfony/psr-http-message-bridge": "^2.1",
"symfony/property-access": "~5.0.0"
},
"autoload": {
"psr-4": {
Expand Down
87 changes: 46 additions & 41 deletions manifest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,54 +24,56 @@

declare(strict_types=1);

use oat\tao\model\user\TaoRoles;
use oat\tao\controller\api\Users;
use oat\tao\helpers\form\ServiceProvider\FormServiceProvider;
use oat\tao\install\services\SetupSettingsStorage;
use oat\tao\model\accessControl\func\AccessRule;
use oat\tao\model\routing\ApiRoute;
use oat\tao\model\routing\LegacyRoute;
use oat\tao\model\user\TaoRoles;
use oat\tao\scripts\install\AddArchiveService;
use oat\tao\scripts\update\Updater;
use oat\tao\scripts\install\AddLogFs;
use oat\tao\model\routing\LegacyRoute;
use oat\tao\scripts\install\RegisterEvents;
use oat\tao\scripts\install\SetServiceState;
use oat\tao\scripts\install\SetUpQueueTasks;
use oat\tao\scripts\install\AddTmpFsHandlers;
use oat\tao\scripts\install\AddArchiveService;
use oat\tao\scripts\install\CreateRdsListStore;
use oat\tao\scripts\install\CreateWebhookEventLogTable;
use oat\tao\scripts\install\InstallNotificationTable;
use oat\tao\scripts\install\RegisterRtlLocales;
use oat\tao\model\accessControl\func\AccessRule;
use oat\tao\scripts\install\RegisterUserService;
use oat\tao\scripts\install\SetContainerService;
use oat\tao\scripts\install\SetDefaultCSPHeader;
use oat\tao\install\services\SetupSettingsStorage;
use oat\tao\scripts\install\RegisterActionService;
use oat\tao\scripts\install\SetClientLoggerConfig;
use oat\tao\scripts\install\SetServiceFileStorage;
use oat\tao\scripts\install\RegisterResourceEvents;
use oat\tao\scripts\install\RegisterSearchServices;
use oat\tao\scripts\install\SetImageAligmentConfig;
use oat\tao\scripts\install\SetLocaleNumbersConfig;
use oat\tao\scripts\install\RegisterValidationRules;
use oat\tao\scripts\install\SetupMaintenanceService;
use oat\tao\scripts\install\InstallNotificationTable;
use oat\tao\scripts\install\RegisterTaskQueueServices;
use oat\tao\model\Serializer\SerializerServiceProvider;
use oat\tao\scripts\install\CreateWebhookEventLogTable;
use oat\tao\scripts\install\RegisterSignatureGenerator;
use oat\tao\scripts\install\RegisterActionAccessControl;
use oat\tao\scripts\install\RegisterSessionCookieService;
use oat\tao\scripts\install\RegisterClassMetadataServices;
use oat\tao\scripts\install\RegisterResourceWatcherService;
use oat\tao\scripts\install\RegisterTaoUpdateEventListener;
use oat\tao\scripts\install\RegisterResourceRelationService;
use oat\tao\scripts\install\RegisterValueCollectionServices;
use oat\tao\helpers\form\ServiceProvider\FormServiceProvider;
use oat\tao\model\Lists\ServiceProvider\ListsServiceProvider;
use oat\tao\scripts\install\RegisterClassPropertiesChangedEvent;
use oat\tao\scripts\install\RegisterClassPropertiesChangedEventListener;
use oat\tao\scripts\install\RegisterClassPropertyRemovedEvent;
use oat\tao\model\ParamConverter\ParamConverterServiceProvider;
use oat\tao\scripts\install\RegisterUserLockoutsEventListeners;
use oat\tao\scripts\install\RegisterClassPropertiesChangedEvent;
use oat\tao\scripts\install\RegisterClassPropertyRemovedListener;
use oat\tao\scripts\install\RegisterDataAccessControlChangedEvent;
use oat\tao\scripts\install\RegisterDataAccessControlChangedListener;
use oat\tao\scripts\install\RegisterEvents;
use oat\tao\scripts\install\RegisterResourceEvents;
use oat\tao\scripts\install\RegisterResourceRelationService;
use oat\tao\scripts\install\RegisterResourceWatcherService;
use oat\tao\scripts\install\RegisterRtlLocales;
use oat\tao\scripts\install\RegisterSearchServices;
use oat\tao\scripts\install\RegisterSessionCookieService;
use oat\tao\scripts\install\RegisterSignatureGenerator;
use oat\tao\scripts\install\RegisterTaoUpdateEventListener;
use oat\tao\scripts\install\RegisterTaskQueueServices;
use oat\tao\scripts\install\RegisterUserLockoutsEventListeners;
use oat\tao\scripts\install\RegisterUserService;
use oat\tao\scripts\install\RegisterValidationRules;
use oat\tao\scripts\install\RegisterValueCollectionServices;
use oat\tao\scripts\install\SetClientLoggerConfig;
use oat\tao\scripts\install\SetContainerService;
use oat\tao\scripts\install\SetDefaultCSPHeader;
use oat\tao\scripts\install\SetImageAligmentConfig;
use oat\tao\scripts\install\SetLocaleNumbersConfig;
use oat\tao\scripts\install\SetServiceFileStorage;
use oat\tao\scripts\install\SetServiceState;
use oat\tao\scripts\install\SetupMaintenanceService;
use oat\tao\scripts\install\SetUpQueueTasks;
use oat\tao\scripts\tools\AddRtlLocale;
use oat\tao\scripts\update\Updater;
use oat\tao\scripts\install\RegisterClassPropertiesChangedEventListener;
use oat\tao\model\HttpFoundation\ServiceProvider\HttpFoundationServiceProvider;

$extpath = __DIR__ . DIRECTORY_SEPARATOR;

Expand All @@ -83,7 +85,7 @@
'author' => 'Open Assessment Technologies, CRP Henri Tudor',
'models' => [
'http://www.tao.lu/Ontologies/TAO.rdf',
'http://www.tao.lu/middleware/wfEngine.rdf'
'http://www.tao.lu/middleware/wfEngine.rdf',
],
'install' => [
'rdf' => [
Expand All @@ -97,7 +99,7 @@
__DIR__ . '/models/ontology/widgetdefinitions.rdf',
__DIR__ . '/models/ontology/requiredaction.rdf',
__DIR__ . '/models/ontology/auth/basicauth.rdf',
__DIR__ . '/models/ontology/userlocks.rdf'
__DIR__ . '/models/ontology/userlocks.rdf',
],
'checks' => [
['type' => 'CheckPHPRuntime', 'value' => ['id' => 'tao_php_runtime', 'min' => '5.4']],
Expand All @@ -117,8 +119,8 @@
['type' => 'CheckPHPINIValue', 'value' => ['id' => 'tao_ini_suhosin_request_max_varname_length', 'name' => 'suhosin.request.max_varname_length', 'value' => '128', 'dependsOn' => ['tao_extension_suhosin']]],
['type' => 'CheckFileSystemComponent', 'value' => ['id' => 'fs_generis_common_conf', 'location' => 'config', 'rights' => 'rw', 'recursive' => true]],
['type' => 'CheckFileSystemComponent', 'value' => ['id' => 'fs_tao_client_locales', 'location' => 'tao/views/locales', 'rights' => 'rw']],
['type' => 'CheckCustom', 'value' => ['id' => 'tao_custom_not_nginx', 'name' => 'not_nginx', 'extension' => 'tao', "optional" => true, 'dependsOn' => ['tao_extension_curl']]],
['type' => 'CheckCustom', 'value' => ['id' => 'tao_custom_allowoverride', 'name' => 'allow_override', 'extension' => 'tao', "optional" => true, 'dependsOn' => ['tao_custom_not_nginx']]],
['type' => 'CheckCustom', 'value' => ['id' => 'tao_custom_not_nginx', 'name' => 'not_nginx', 'extension' => 'tao', 'optional' => true, 'dependsOn' => ['tao_extension_curl']]],
['type' => 'CheckCustom', 'value' => ['id' => 'tao_custom_allowoverride', 'name' => 'allow_override', 'extension' => 'tao', 'optional' => true, 'dependsOn' => ['tao_custom_not_nginx']]],
['type' => 'CheckCustom', 'value' => ['id' => 'tao_custom_mod_rewrite', 'name' => 'mod_rewrite', 'extension' => 'tao', 'dependsOn' => ['tao_custom_allowoverride']]],
['type' => 'CheckCustom', 'value' => ['id' => 'tao_custom_database_drivers', 'name' => 'database_drivers', 'extension' => 'tao']],
],
Expand Down Expand Up @@ -165,13 +167,13 @@
RegisterActionAccessControl::class,
RegisterRtlLocales::class,
RegisterSearchServices::class,
SetImageAligmentConfig::class
SetImageAligmentConfig::class,
],
],
'update' => Updater::class,
'optimizableClasses' => [
'http://www.tao.lu/Ontologies/TAO.rdf#Languages',
'http://www.tao.lu/Ontologies/TAO.rdf#LanguageUsages'
'http://www.tao.lu/Ontologies/TAO.rdf#LanguageUsages',
],
'managementRole' => TaoRoles::TAO_MANAGER,
'acl' => [
Expand Down Expand Up @@ -272,6 +274,9 @@
],
'containerServiceProviders' => [
ListsServiceProvider::class,
SerializerServiceProvider::class,
HttpFoundationServiceProvider::class,
ParamConverterServiceProvider::class,
FormServiceProvider::class,
],
];
56 changes: 56 additions & 0 deletions migrations/Version202109300806032234_tao.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php

/**
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; under version 2
* of the License (non-upgradable).
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Copyright (c) 2021 (original work) Open Assessment Technologies SA;
*/

declare(strict_types=1);

namespace oat\tao\migrations;

use Doctrine\DBAL\Schema\Schema;
use oat\oatbox\event\EventManager;
use oat\tao\scripts\tools\migrations\AbstractMigration;
use oat\tao\model\ParamConverter\Event\ParamConverterEvent;
use oat\tao\model\ParamConverter\EventListener\ParamConverterListener;

final class Version202109300806032234_tao extends AbstractMigration
{
public function getDescription(): string
{
return 'Attach ParamConverterEvent to EventManager.';
}

public function up(Schema $schema): void
{
$eventManager = $this->getEventManager();
$eventManager->attach(ParamConverterEvent::class, [ParamConverterListener::class, 'handleEvent']);
$this->getServiceLocator()->register(EventManager::SERVICE_ID, $eventManager);
}

public function down(Schema $schema): void
{
$eventManager = $this->getEventManager();
$eventManager->detach(ParamConverterEvent::class, [ParamConverterListener::class, 'handleEvent']);
$this->getServiceLocator()->register(EventManager::SERVICE_ID, $eventManager);
}

private function getEventManager(): EventManager
{
return $this->getServiceLocator()->getContainer()->get(EventManager::SERVICE_ID);
}
}
46 changes: 46 additions & 0 deletions models/classes/HttpFoundation/Factory/HttpFoundationFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

/**
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; under version 2
* of the License (non-upgradable).
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Copyright (c) 2021 (original work) Open Assessment Technologies SA;
*/

declare(strict_types=1);

namespace oat\tao\model\HttpFoundation\Factory;

use Psr\Http\Message\ServerRequestInterface;
use oat\tao\model\HttpFoundation\Request\Request;
use oat\tao\model\HttpFoundation\Request\RequestInterface;
use Symfony\Bridge\PsrHttpMessage\Factory\HttpFoundationFactory as SymfonyHttpFoundationFactory;

class HttpFoundationFactory implements HttpFoundationFactoryInterface
{
/** @var SymfonyHttpFoundationFactory */
private $httpFoundationFactory;

public function __construct()
{
$this->httpFoundationFactory = new SymfonyHttpFoundationFactory();
}

public function createRequest(ServerRequestInterface $psrRequest, bool $streamed = false): RequestInterface
{
$request = $this->httpFoundationFactory->createRequest($psrRequest, $streamed);

return new Request($request);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

/**
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; under version 2
* of the License (non-upgradable).
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Copyright (c) 2021 (original work) Open Assessment Technologies SA;
*/

declare(strict_types=1);

namespace oat\tao\model\HttpFoundation\Factory;

use Psr\Http\Message\ServerRequestInterface;
use oat\tao\model\HttpFoundation\Request\RequestInterface;

interface HttpFoundationFactoryInterface
{
public function createRequest(ServerRequestInterface $psrRequest, bool $streamed = false): RequestInterface;
}
Loading