-
Notifications
You must be signed in to change notification settings - Fork 638
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[!!!][TASK] Aggregate validator information in class schema
This is the first part of many to streamline the resolving of validators. In this patch, the following changes: - The class schema aggregates all the information about validators that are added via @Validate annotations. As reflection is involved here, it makes sense to put this into the class schema generation and remove it from the ActionController. - Along with this change there have been changes to the ValidatorResolver class. Being references only in the ActionController, buildMethodArgumentsValidatorConjunctions has been deprecated and is no longer used by the core itself. - Also, the methods parseValidatorAnnotation and resolveValidatorObjectName have been made public as they are now used from outside the ValidatorResolver class. The main achievements of this patch are getting rid of runtime reflection by the ActionController and fetching the necessary information about validators from the class schema, which at this very moment, is also generated during runtime but is cached and that cache can be warmed up in the future. Therefore this change does also improve the runtime performance of Extbase a bit. This patch is considered breaking as it removes the support for adding validators to properties of method arguments via the following (quite unknown) semantic sugar. /* * @param Model $model * @Validate $model.property NotEmpty */ public function foo(Model $model){} This possibility is quite unknown and unused in the wild and as it eases the aggregation of validators it will be removed without any replacement. However, whenever a model is validated and a model validator exists for that model, it will be registered and called automatically. If not dealing with models but regular objects or arrays, the recommended way is to write a custom validator and do the validation manually in that class. Releases: master Resolves: #83475 Change-Id: I3c76e722fe084e8346bb27ea5ba8c7ef0f056eda Reviewed-on: https://review.typo3.org/55261 Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch> Tested-by: Christian Kuhn <lolli@schwarzbu.ch> Reviewed-by: Frank Naegler <frank.naegler@typo3.org> Tested-by: Frank Naegler <frank.naegler@typo3.org>
- Loading branch information
1 parent
b9026a9
commit 84879ed
Showing
16 changed files
with
639 additions
and
52 deletions.
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
.../Changelog/master/Breaking-83475-AggregateValidatorInformationInClassSchema.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
.. include:: ../../Includes.txt | ||
|
||
================================================================== | ||
Breaking: #83475 - Aggregate validator information in class schema | ||
================================================================== | ||
|
||
See :issue:`83475` | ||
|
||
Description | ||
=========== | ||
|
||
It is no longer possible to use the following semantic sugar to define validators for properties of action parameters: | ||
|
||
.. code-block:: php | ||
/* | ||
* @param Model $model | ||
* @validate $model.property NotEmpty | ||
*/ | ||
public function foo(Model $model){} | ||
Mind the dot and the reference to the property. This will no longer work. | ||
Of course, the regular validation of action parameters stays intact. | ||
|
||
.. code-block:: php | ||
/* | ||
* @param Model $model | ||
* @validate $model CustomValidator | ||
*/ | ||
public function foo(Model $model){} | ||
This will continue to work. | ||
|
||
|
||
Impact | ||
====== | ||
|
||
If you rely on that feature, you need to manually implement the validation in the future. | ||
|
||
|
||
Affected Installations | ||
====================== | ||
|
||
All installations that use that feature. | ||
|
||
|
||
Migration | ||
========= | ||
|
||
If you used that feature for adding validators to models, you can define the validators inside the model instead or inside a model validator, that is automatically registered and loaded if defined. | ||
|
||
When using that feature with regular objects, you need to write custom validators and call the desired property validators in there. | ||
|
||
.. index:: NotScanned |
41 changes: 41 additions & 0 deletions
41
...gelog/master/Deprecation-83475-AggregateValidatorInformationInClassSchema-1.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
.. include:: ../../Includes.txt | ||
|
||
===================================================================== | ||
Deprecation: #83475 - Aggregate validator information in class schema | ||
===================================================================== | ||
|
||
See :issue:`83475` | ||
|
||
Description | ||
=========== | ||
|
||
The method `\TYPO3\CMS\Extbase\Mvc\Controller\ActionController::getActionMethodParameters` is deprecated and will be removed in TYPO3 v10.0 | ||
|
||
|
||
Impact | ||
====== | ||
|
||
The method is not considered public api and it is unlikely that the methods is used in the wild. If you rely on that method, please migrate your code base. | ||
|
||
|
||
Affected Installations | ||
====================== | ||
|
||
All installations that use that method. | ||
|
||
|
||
Migration | ||
========= | ||
|
||
Use the ClassSchema class and get all necessary information from it. | ||
Example: | ||
|
||
.. code-block:: php | ||
$reflectionService = $objectManager->get(\TYPO3\CMS\Extbase\Reflection\ReflectionService::class); | ||
$methods = $reflectionService->getClassSchema($className)->getMethods(); | ||
$actions = array_filter($methods, function($method){ | ||
return $method['isAction']; | ||
}); | ||
.. index:: PHP-API, FullyScanned |
32 changes: 32 additions & 0 deletions
32
...gelog/master/Deprecation-83475-AggregateValidatorInformationInClassSchema-2.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
.. include:: ../../Includes.txt | ||
|
||
===================================================================== | ||
Deprecation: #83475 - Aggregate validator information in class schema | ||
===================================================================== | ||
|
||
See :issue:`83475` | ||
|
||
Description | ||
=========== | ||
|
||
The method `\TYPO3\CMS\Extbase\Validation\ValidatorResolver::buildMethodArgumentsValidatorConjunctions` is deprecated and will be removed in TYPO3 v10.0 | ||
|
||
|
||
Impact | ||
====== | ||
|
||
The method is not considered public api and it is unlikely that the methods is used in the wild. If you rely on that method, you will need to implement the logic yourself. | ||
|
||
|
||
Affected Installations | ||
====================== | ||
|
||
All installations that use that method. | ||
|
||
|
||
Migration | ||
========= | ||
|
||
There is no migration | ||
|
||
.. index:: PHP-API, FullyScanned |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.