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

Annotation Class Inheritance #235

Open
maennchen opened this issue May 19, 2016 · 0 comments
Open

Annotation Class Inheritance #235

maennchen opened this issue May 19, 2016 · 0 comments

Comments

@maennchen
Copy link
Contributor

maennchen commented May 19, 2016

It seems that the class inheritance is ignored for annotations.

I need to do that to get the inheritance. Am I doing something wrong?

(It works with the patch below. I'd be happy to contribute a proper PR.)

From 0111785f8fc91e66195916072f1fcff05cbfa95d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jonatan=20M=C3=A4nnchen?= <jonatan.maennchen@ibrows.ch>
Date: Thu, 19 May 2016 11:47:25 +0000
Subject: [PATCH] Annotation Class Inheritance

---
 src/Hateoas/Configuration/Metadata/Driver/AnnotationDriver.php | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/Hateoas/Configuration/Metadata/Driver/AnnotationDriver.php b/src/Hateoas/Configuration/Metadata/Driver/AnnotationDriver.php
index 6364c55..41cc53d 100644
--- a/src/Hateoas/Configuration/Metadata/Driver/AnnotationDriver.php
+++ b/src/Hateoas/Configuration/Metadata/Driver/AnnotationDriver.php
@@ -37,6 +37,12 @@ class AnnotationDriver implements DriverInterface
     {
         $annotations = $this->reader->getClassAnnotations($class);

+        $parent = $class->getParentClass();
+        while($parent instanceof  \ReflectionClass) {
+            $annotations = array_merge($annotations, $this->reader->getClassAnnotations($parent));
+            $parent = $parent->getParentClass();
+        }
+
         if (0 === count($annotations)) {
             return null;
         }
--
2.2.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant