Skip to content

Load routes from subclasses

Compare
Choose a tag to compare
@mpdude mpdude released this 29 Sep 11:10
· 31 commits to master since this release
721e81d

This release fixes that @ObjectRoute annotations from class hierarchies would not be correctly merged.

For example, consider:

<?php

/** @ObjectRoute(type="view", "name" => "foo_route") */
class Foo{}

/** @ObjectRoute(type="view", "name" => "bar_route") */
class Bar extends Foo{}

This will now correctly use the bar_route when using object_path('view', obj) with obj being an instance of Bar.

In fact, the code to merge the relevant metadata from class hierarchies was already in place, it only forgot to merge the routes property in a subclass (see #1).

This might be a breaking change for users who use @ObjectRoute annotations on subclasses, but in fact ended up with the first (highest) class in the inheritance tree that uses the annotation. Since until now the annotation on the subclass never worked as one would expect (in fact, it had no effect), this should not be relevant "in the wild".