Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
e11af747
Commit
e11af747
authored
Nov 13, 2012
by
webchick
Browse files
Issue
#1827424
by EclipseGc, tim.plunkett, Fabianx, dawehner: Fixed Parse annotations recursively.
parent
6f32687e
Changes
3
Hide whitespace changes
Inline
Side-by-side
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
;
$definition
s
[
$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