-
-
Notifications
You must be signed in to change notification settings - Fork 190
BUGFIX: Support ORM attributes #3508
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
Merged
+3,249
−469
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
421d644
TASK: Clean up persistence tests code
kdambekalns 05c29a8
TASK: Tiny code cleanup
kdambekalns c2b5f6a
BUGFIX: Use custom reader to access ORM configuration
kdambekalns 35009cb
BUGFIX: Handle proxy classnames correctly
kdambekalns fbda7ec
TASK: Update minimum doctrine/common 3.0.3 to 3.1.0
kdambekalns 5261eb8
TASK: Duplicate Test and Fixtures ... no php8 adjustments yet
mficzel 3329406
TASK: Adjust PHP8 persistence test-fixtures to php 8 syntax
mficzel 017f30f
TASK: Code cleanup
kdambekalns 6b049a0
BUGFIX: Respect type declaration when building class-schema
kdambekalns b37f327
TASK: Adjust (new) fixture to Flow 8.4
kdambekalns fc9fc07
TASK: Make compatible with lowest dependency
kdambekalns 3d2d163
TASK: Raise minimal doctrine/orm version from 2.12 to 2.17
kdambekalns a94cbf6
TASK: Convert nested orm annotations to attributes
mficzel 02fa4c0
TASK: Explain var tag precedence in ReflectionService
kdambekalns File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
155 changes: 40 additions & 115 deletions
155
Neos.Flow/Classes/Persistence/Doctrine/Mapping/Driver/FlowAnnotationDriver.php
Large diffs are not rendered by default.
Oops, something went wrong.
132 changes: 132 additions & 0 deletions
132
Neos.Flow/Classes/Persistence/Doctrine/Mapping/Driver/FlowAnotationReader.php
This file contains hidden or 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,132 @@ | ||
| <?php | ||
| declare(strict_types=1); | ||
|
|
||
| namespace Neos\Flow\Persistence\Doctrine\Mapping\Driver; | ||
|
|
||
| /* | ||
| * This file is part of the Neos.Flow package. | ||
| * | ||
| * (c) Contributors of the Neos Project - www.neos.io | ||
| * | ||
| * This package is Open Source Software. For the full copyright and license | ||
| * information, please view the LICENSE file which was distributed with this | ||
| * source code. | ||
| */ | ||
|
|
||
| use Doctrine\Common\Annotations\Reader; | ||
| use Neos\Flow\ObjectManagement\Proxy\Compiler; | ||
| use Neos\Flow\Reflection\ReflectionService; | ||
| use ReflectionClass; | ||
| use ReflectionMethod; | ||
| use ReflectionProperty; | ||
|
|
||
| class FlowAnotationReader implements Reader | ||
| { | ||
| private ReflectionService $reflectionService; | ||
|
|
||
| public function __construct(ReflectionService $reflectionService) | ||
| { | ||
| $this->reflectionService = $reflectionService; | ||
| } | ||
|
|
||
| /** | ||
| * Gets the annotations applied to a class. | ||
| * | ||
| * @param ReflectionClass $class The ReflectionClass of the class from which the class annotations should be read. | ||
| * @return array<object> An array of Annotations. | ||
| */ | ||
| public function getClassAnnotations(ReflectionClass $class) | ||
| { | ||
| $className = $this->getUnproxiedClassName($class->getName()); | ||
| $indexedAnnotations = []; | ||
| foreach ($this->reflectionService->getClassAnnotations($className) as $annotation) { | ||
| $indexedAnnotations[get_class($annotation)] = $annotation; | ||
| } | ||
| return $indexedAnnotations; | ||
| } | ||
|
|
||
| /** | ||
| * Gets a class annotation. | ||
| * | ||
| * @param ReflectionClass $class The ReflectionClass of the class from which the class annotations should be read. | ||
| * @param class-string<T> $annotationName The name of the annotation. | ||
| * @return T|null The Annotation or NULL, if the requested annotation does not exist. | ||
| * @template T | ||
| */ | ||
| public function getClassAnnotation(ReflectionClass $class, $annotationName) | ||
| { | ||
| $className = $this->getUnproxiedClassName($class->getName()); | ||
| return $this->reflectionService->getClassAnnotation($className, $annotationName); | ||
| } | ||
|
|
||
| /** | ||
| * Gets the annotations applied to a method. | ||
| * | ||
| * @param ReflectionMethod $method The ReflectionMethod of the method from which the annotations should be read. | ||
| * @return array<object> An array of Annotations. | ||
| */ | ||
| public function getMethodAnnotations(ReflectionMethod $method) | ||
| { | ||
| $className = $this->getUnproxiedClassName($method->class); | ||
| $indexedAnnotations = []; | ||
| foreach ($this->reflectionService->getMethodAnnotations($className, $method->getName()) as $annotation) { | ||
| $indexedAnnotations[get_class($annotation)] = $annotation; | ||
| } | ||
| return $indexedAnnotations; | ||
| } | ||
|
|
||
| /** | ||
| * Gets a method annotation. | ||
| * | ||
| * @param ReflectionMethod $method The ReflectionMethod to read the annotations from. | ||
| * @param class-string<T> $annotationName The name of the annotation. | ||
| * @return T|null The Annotation or NULL, if the requested annotation does not exist. | ||
| * @template T | ||
| */ | ||
| public function getMethodAnnotation(ReflectionMethod $method, $annotationName) | ||
| { | ||
| $className = $this->getUnproxiedClassName($method->class); | ||
| return $this->reflectionService->getMethodAnnotation($className, $method->getName(), $annotationName); | ||
| } | ||
|
|
||
| /** | ||
| * Gets the annotations applied to a property. | ||
| * | ||
| * @param ReflectionProperty $property The ReflectionProperty of the property from which the annotations should be read. | ||
| * @return array<object> An array of Annotations. | ||
| */ | ||
| public function getPropertyAnnotations(ReflectionProperty $property) | ||
| { | ||
| $className = $this->getUnproxiedClassName($property->class); | ||
| $indexedAnnotations = []; | ||
| foreach ($this->reflectionService->getPropertyAnnotations($className, $property->getName()) as $annotation) { | ||
| $indexedAnnotations[get_class($annotation)] = $annotation; | ||
| } | ||
| return $indexedAnnotations; | ||
| } | ||
|
|
||
| /** | ||
| * Gets a property annotation. | ||
| * | ||
| * @param ReflectionProperty $property The ReflectionProperty to read the annotations from. | ||
| * @param class-string<T> $annotationName The name of the annotation. | ||
| * @return T|null The Annotation or NULL, if the requested annotation does not exist. | ||
| * @template T | ||
| */ | ||
| public function getPropertyAnnotation(ReflectionProperty $property, $annotationName) | ||
| { | ||
| $className = $this->getUnproxiedClassName($property->class); | ||
| return $this->reflectionService->getPropertyAnnotation($className, $property->getName(), $annotationName); | ||
| } | ||
|
|
||
| /** | ||
| * Returns the classname after stripping a potentially present Compiler::ORIGINAL_CLASSNAME_SUFFIX. | ||
| * | ||
| * @param string $className | ||
| * @return string | ||
| */ | ||
| protected function getUnproxiedClassName($className) | ||
| { | ||
| return preg_replace('/' . Compiler::ORIGINAL_CLASSNAME_SUFFIX . '$/', '', $className); | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.