Problem/Motivation
In the following annotation, the @Translation annotation is used both on the top level for 'label', but also nested in 'view_modes' -> 'full' -> 'label'.
Currently this does not work, preventing any nested values from being transltations.
use Drupal\Core\Annotation\Plugin;
use Drupal\Core\Annotation\Translation;
/**
* Defines the user entity class.
*
* @Plugin(
* id = "user",
* label = @Translation("User"),
* module = "user",
* view_modes = {
* "full" = {
* "label" = @Translation("User account"),
* "custom_settings" = FALSE
* }
* }
* )
*/
class User extends Entity {
//...
}
Proposed resolution
Parse the annotations recursively, by splitting the actual parsing code out of Drupal\Core\Annotation\Plugin::__construct() and into a dedicated method.
Remaining tasks
n/a
User interface changes
n/a
API changes
Adds a new protected method Drupal\Core\Annotation\Plugin::parse().
| Comment | File | Size | Author |
|---|---|---|---|
| #14 | plugins-1827424-14-FAIL.patch | 1.74 KB | tim.plunkett |
| #14 | plugins-1827424-14-PASS.patch | 2.87 KB | tim.plunkett |
| #9 | drupal-1827424-9.patch | 1.13 KB | tim.plunkett |
| #8 | drupal-1827424-8.patch | 1.13 KB | dawehner |
| #7 | plugins-1827424-7.patch | 1.13 KB | fabianx |
Comments
Comment #1
tim.plunkettComment #2
sunLooks good, makes sense.
Comment #3
eclipsegc commentedI was coming to RTBC this as well. Blocks needs it and it is in fact straight out of my patch for blocks, so ++ from me.
Comment #4
tim.plunkettOh yes, for the committers, @EclipseGc should get credit on this commit.
Comment #5
eclipsegc commentednot then intention of that comment, but thanks :-)
Comment #6
fabianx commented+1 for RTBC of this, nice patch.
Comment #7
fabianx commentedCosmetical touch:Added declaration of $definitions before loop.
Does not change RTBC status.
Comment #8
dawehnerI'm sorry, please don't put me in the commit message.
Comment #9
tim.plunkettLet's not put either of you in there ;)
Ahem.
Comment #11
tim.plunkett#9: drupal-1827424-9.patch queued for re-testing.
Comment #12
berdirWas RTBC before, just had some minor style corrections, which look correct.
Comment #13
webchickWe should get test coverage for this.
Comment #14
tim.plunkettHere we are.
Comment #15
tstoecklerNoone can argue with more fruit in Drupal :-)
Assuming this comes back red/green, this is RTBC.
Comment #16
tim.plunkettThis blocks #1535868: Convert all blocks into plugins (that patch includes this one), so bumping the priority.
Comment #17
webchickCommitted and pushed to 8.x. Thanks!