Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
D
drupal
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Custom Issue Tracker
Custom Issue Tracker
Labels
Merge Requests
306
Merge Requests
306
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
project
drupal
Commits
e11af747
Commit
e11af747
authored
Nov 13, 2012
by
webchick
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#1827424
by EclipseGc, tim.plunkett, Fabianx, dawehner: Fixed Parse annotations recursively.
parent
6f32687e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
2 deletions
+54
-2
core/lib/Drupal/Core/Annotation/Plugin.php
core/lib/Drupal/Core/Annotation/Plugin.php
+20
-2
core/modules/system/lib/Drupal/system/Tests/Plugin/Discovery/AnnotatedClassDiscoveryTest.php
...em/Tests/Plugin/Discovery/AnnotatedClassDiscoveryTest.php
+9
-0
core/modules/system/tests/modules/plugin_test/lib/Drupal/plugin_test/Plugin/plugin_test/fruit/Banana.php
...ib/Drupal/plugin_test/Plugin/plugin_test/fruit/Banana.php
+25
-0
No files found.
core/lib/Drupal/Core/Annotation/Plugin.php
View file @
e11af747
...
...
@@ -36,14 +36,32 @@ class Plugin implements AnnotationInterface {
* classed annotations that were used.
*/
public
function
__construct
(
$values
)
{
$this
->
definition
=
$this
->
parse
(
$values
);
}
/**
* Parses an annotation into its definition.
*
* @param array $values
* The annotation array.
*
* @return array
* The parsed annotation as a definition.
*/
protected
function
parse
(
array
$values
)
{
$definitions
=
array
();
foreach
(
$values
as
$key
=>
$value
)
{
if
(
$value
instanceof
AnnotationInterface
)
{
$this
->
definition
[
$key
]
=
$value
->
get
();
$definitions
[
$key
]
=
$value
->
get
();
}
elseif
(
is_array
(
$value
))
{
$definitions
[
$key
]
=
$this
->
parse
(
$value
);
}
else
{
$
this
->
definition
[
$key
]
=
$value
;
$
definitions
[
$key
]
=
$value
;
}
}
return
$definitions
;
}
/**
...
...
core/modules/system/lib/Drupal/system/Tests/Plugin/Discovery/AnnotatedClassDiscoveryTest.php
View file @
e11af747
...
...
@@ -31,6 +31,15 @@ public function setUp() {
'color'
=>
'green'
,
'class'
=>
'Drupal\plugin_test\Plugin\plugin_test\fruit\Apple'
,
),
'banana'
=>
array
(
'id'
=>
'banana'
,
'label'
=>
'Banana'
,
'color'
=>
'yellow'
,
'uses'
=>
array
(
'bread'
=>
t
(
'Banana bread'
),
),
'class'
=>
'Drupal\plugin_test\Plugin\plugin_test\fruit\Banana'
,
),
'cherry'
=>
array
(
'id'
=>
'cherry'
,
'label'
=>
'Cherry'
,
...
...
core/modules/system/tests/modules/plugin_test/lib/Drupal/plugin_test/Plugin/plugin_test/fruit/Banana.php
0 → 100644
View file @
e11af747
<?php
/**
* @file
* Contains \Drupal\plugin_test\Plugin\plugin_test\fruit\Banana.
*/
namespace
Drupal\plugin_test\Plugin\plugin_test\fruit
;
use
Drupal\Core\Annotation\Plugin
;
use
Drupal\Core\Annotation\Translation
;
/**
* @Plugin(
* id = "banana",
* label = "Banana",
* color = "yellow",
* uses = {
* "bread" = @Translation("Banana bread")
* }
* )
*/
class
Banana
{
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment