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
301
Merge Requests
301
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
48025f92
Commit
48025f92
authored
Mar 11, 2014
by
alexpott
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#2168159
by dawehner: Plugin Derivatives don't work with Objects returned from Annotations.
parent
c53879f0
Changes
32
Hide whitespace changes
Inline
Side-by-side
Showing
32 changed files
with
129 additions
and
54 deletions
+129
-54
core/lib/Drupal/Component/Plugin/Derivative/DerivativeBase.php
...lib/Drupal/Component/Plugin/Derivative/DerivativeBase.php
+2
-2
core/lib/Drupal/Component/Plugin/Derivative/DerivativeInterface.php
...rupal/Component/Plugin/Derivative/DerivativeInterface.php
+6
-5
core/lib/Drupal/Component/Plugin/Discovery/DerivativeDiscoveryDecorator.php
...mponent/Plugin/Discovery/DerivativeDiscoveryDecorator.php
+8
-9
core/lib/Drupal/Core/Entity/Plugin/DataType/Deriver/EntityDeriver.php
...pal/Core/Entity/Plugin/DataType/Deriver/EntityDeriver.php
+2
-2
core/lib/Drupal/Core/Field/Plugin/DataType/Deriver/FieldItemDeriver.php
...l/Core/Field/Plugin/DataType/Deriver/FieldItemDeriver.php
+2
-2
core/lib/Drupal/Core/Plugin/Discovery/ContainerDerivativeDiscoveryDecorator.php
...lugin/Discovery/ContainerDerivativeDiscoveryDecorator.php
+1
-1
core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Derivative/CustomBlock.php
...lib/Drupal/custom_block/Plugin/Derivative/CustomBlock.php
+1
-1
core/modules/block/lib/Drupal/block/Plugin/Derivative/ThemeLocalTask.php
...ock/lib/Drupal/block/Plugin/Derivative/ThemeLocalTask.php
+1
-1
core/modules/config_translation/lib/Drupal/config_translation/Plugin/Derivative/ConfigTranslationContextualLinks.php
...on/Plugin/Derivative/ConfigTranslationContextualLinks.php
+1
-1
core/modules/config_translation/lib/Drupal/config_translation/Plugin/Derivative/ConfigTranslationLocalTasks.php
...slation/Plugin/Derivative/ConfigTranslationLocalTasks.php
+1
-1
core/modules/content_translation/lib/Drupal/content_translation/Plugin/Derivative/ContentTranslationContextualLinks.php
...n/Plugin/Derivative/ContentTranslationContextualLinks.php
+1
-1
core/modules/content_translation/lib/Drupal/content_translation/Plugin/Derivative/ContentTranslationLocalTasks.php
...lation/Plugin/Derivative/ContentTranslationLocalTasks.php
+1
-1
core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/Derivative/SelectionBase.php
...upal/entity_reference/Plugin/Derivative/SelectionBase.php
+1
-1
core/modules/field_ui/lib/Drupal/field_ui/Plugin/Derivative/FieldUiLocalTask.php
...ib/Drupal/field_ui/Plugin/Derivative/FieldUiLocalTask.php
+1
-1
core/modules/language/lib/Drupal/language/Plugin/Derivative/LanguageBlock.php
...e/lib/Drupal/language/Plugin/Derivative/LanguageBlock.php
+1
-1
core/modules/rest/lib/Drupal/rest/Plugin/Derivative/EntityDerivative.php
...st/lib/Drupal/rest/Plugin/Derivative/EntityDerivative.php
+2
-2
core/modules/search/lib/Drupal/search/Plugin/Derivative/SearchLocalTask.php
...h/lib/Drupal/search/Plugin/Derivative/SearchLocalTask.php
+1
-1
core/modules/system/lib/Drupal/system/Plugin/Derivative/SystemMenuBlock.php
...m/lib/Drupal/system/Plugin/Derivative/SystemMenuBlock.php
+1
-1
core/modules/system/lib/Drupal/system/Plugin/Derivative/ThemeLocalTask.php
...em/lib/Drupal/system/Plugin/Derivative/ThemeLocalTask.php
+1
-1
core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Plugin/Derivative/EntityTestLocalTasks.php
...al/entity_test/Plugin/Derivative/EntityTestLocalTasks.php
+1
-1
core/modules/system/tests/modules/menu_test/lib/Drupal/menu_test/Plugin/Derivative/LocalTaskTest.php
.../lib/Drupal/menu_test/Plugin/Derivative/LocalTaskTest.php
+1
-1
core/modules/system/tests/modules/plugin_test/lib/Drupal/plugin_test/Plugin/plugin_test/mock_block/MockLayoutBlockDeriver.php
.../Plugin/plugin_test/mock_block/MockLayoutBlockDeriver.php
+2
-2
core/modules/system/tests/modules/plugin_test/lib/Drupal/plugin_test/Plugin/plugin_test/mock_block/MockMenuBlockDeriver.php
...st/Plugin/plugin_test/mock_block/MockMenuBlockDeriver.php
+2
-2
core/modules/views/lib/Drupal/views/Plugin/Derivative/DefaultWizardDeriver.php
...b/Drupal/views/Plugin/Derivative/DefaultWizardDeriver.php
+1
-1
core/modules/views/lib/Drupal/views/Plugin/Derivative/ViewsBlock.php
...s/views/lib/Drupal/views/Plugin/Derivative/ViewsBlock.php
+2
-2
core/modules/views/lib/Drupal/views/Plugin/Derivative/ViewsEntityArgumentValidator.php
.../views/Plugin/Derivative/ViewsEntityArgumentValidator.php
+1
-1
core/modules/views/lib/Drupal/views/Plugin/Derivative/ViewsEntityRow.php
...ews/lib/Drupal/views/Plugin/Derivative/ViewsEntityRow.php
+2
-2
core/modules/views/lib/Drupal/views/Plugin/Derivative/ViewsExposedFilterBlock.php
...rupal/views/Plugin/Derivative/ViewsExposedFilterBlock.php
+2
-2
core/modules/views/lib/Drupal/views/Plugin/Derivative/ViewsLocalTask.php
...ews/lib/Drupal/views/Plugin/Derivative/ViewsLocalTask.php
+1
-1
core/tests/Drupal/Tests/Core/Plugin/Discovery/DerivativeDiscoveryDecoratorTest.php
...ore/Plugin/Discovery/DerivativeDiscoveryDecoratorTest.php
+36
-2
core/tests/Drupal/Tests/Core/Plugin/Discovery/TestDerivativeDiscovery.php
...l/Tests/Core/Plugin/Discovery/TestDerivativeDiscovery.php
+2
-2
core/tests/Drupal/Tests/Core/Plugin/Discovery/TestDerivativeDiscoveryWithObject.php
...re/Plugin/Discovery/TestDerivativeDiscoveryWithObject.php
+41
-0
No files found.
core/lib/Drupal/Component/Plugin/Derivative/DerivativeBase.php
View file @
48025f92
...
...
@@ -27,7 +27,7 @@ abstract class DerivativeBase implements DerivativeInterface {
/**
* {@inheritdoc}
*/
public
function
getDerivativeDefinition
(
$derivative_id
,
array
$base_plugin_definition
)
{
public
function
getDerivativeDefinition
(
$derivative_id
,
$base_plugin_definition
)
{
if
(
!
empty
(
$this
->
derivatives
)
&&
!
empty
(
$this
->
derivatives
[
$derivative_id
]))
{
return
$this
->
derivatives
[
$derivative_id
];
}
...
...
@@ -38,7 +38,7 @@ public function getDerivativeDefinition($derivative_id, array $base_plugin_defin
/**
* {@inheritdoc}
*/
public
function
getDerivativeDefinitions
(
array
$base_plugin_definition
)
{
public
function
getDerivativeDefinitions
(
$base_plugin_definition
)
{
return
$this
->
derivatives
;
}
}
core/lib/Drupal/Component/Plugin/Derivative/DerivativeInterface.php
View file @
48025f92
...
...
@@ -18,16 +18,17 @@ interface DerivativeInterface {
* @param string $derivative_id
* The derivative id. The id must uniquely identify the derivative within a
* given base plugin, but derivative ids can be reused across base plugins.
* @param array $base_plugin_definition
* The definition array of the base plugin from which the derivative plugin
* is derived.
* @param mixed $base_plugin_definition
* The definition of the base plugin from which the derivative plugin
* is derived. It is maybe an entire object or just some array, depending
* on the discovery mechanism.
*
* @return array
* The full definition array of the derivative plugin, typically a merge of
* $base_plugin_definition with extra derivative-specific information. NULL
* if the derivative doesn't exist.
*/
public
function
getDerivativeDefinition
(
$derivative_id
,
array
$base_plugin_definition
);
public
function
getDerivativeDefinition
(
$derivative_id
,
$base_plugin_definition
);
/**
* Returns the definition of all derivatives of a base plugin.
...
...
@@ -39,6 +40,6 @@ public function getDerivativeDefinition($derivative_id, array $base_plugin_defin
*
* @see getDerivativeDefinition()
*/
public
function
getDerivativeDefinitions
(
array
$base_plugin_definition
);
public
function
getDerivativeDefinitions
(
$base_plugin_definition
);
}
core/lib/Drupal/Component/Plugin/Discovery/DerivativeDiscoveryDecorator.php
View file @
48025f92
...
...
@@ -155,17 +155,17 @@ protected function encodePluginId($base_plugin_id, $derivative_id) {
*
* @param string $base_plugin_id
* The base plugin id of the plugin.
* @param
array
$base_definition
* @param
mixed
$base_definition
* The base plugin definition to build derivatives.
*
* @return \Drupal\Component\Plugin\Derivative\DerivativeInterface|null
+
* A DerivativeInterface or NULL if none exists for the plugin.
+
*
+
* @throws \Drupal\Component\Plugin\Exception\InvalidDerivativeClassException
+
* Thrown if the 'derivative' class specified in the plugin definition does
+
* not implement \Drupal\Component\Plugin\Derivative\DerivativeInterface.
* A DerivativeInterface or NULL if none exists for the plugin.
*
* @throws \Drupal\Component\Plugin\Exception\InvalidDerivativeClassException
* Thrown if the 'derivative' class specified in the plugin definition does
* not implement \Drupal\Component\Plugin\Derivative\DerivativeInterface.
*/
protected
function
getDerivativeFetcher
(
$base_plugin_id
,
array
$base_definition
)
{
protected
function
getDerivativeFetcher
(
$base_plugin_id
,
$base_definition
)
{
if
(
!
isset
(
$this
->
derivativeFetchers
[
$base_plugin_id
]))
{
$this
->
derivativeFetchers
[
$base_plugin_id
]
=
FALSE
;
$class
=
$this
->
getDerivativeClass
(
$base_definition
);
...
...
@@ -191,8 +191,7 @@ protected function getDerivativeFetcher($base_plugin_id, array $base_definition)
*/
protected
function
getDerivativeClass
(
$base_definition
)
{
$class
=
NULL
;
if
(
isset
(
$base_definition
[
'derivative'
]))
{
$class
=
$base_definition
[
'derivative'
];
if
((
is_array
(
$base_definition
)
||
(
$base_definition
=
(
array
)
$base_definition
))
&&
(
isset
(
$base_definition
[
'derivative'
])
&&
$class
=
$base_definition
[
'derivative'
]))
{
if
(
!
is_subclass_of
(
$class
,
'\Drupal\Component\Plugin\Derivative\DerivativeInterface'
))
{
throw
new
InvalidDerivativeClassException
(
sprintf
(
'Plugin (%s) derivative class "%s" has to implement interface \Drupal\Component\Plugin\Derivative\DerivativeInterface'
,
$base_definition
[
'id'
],
$class
));
}
...
...
core/lib/Drupal/Core/Entity/Plugin/DataType/Deriver/EntityDeriver.php
View file @
48025f92
...
...
@@ -63,7 +63,7 @@ public static function create(ContainerInterface $container, $base_plugin_id) {
/**
* {@inheritdoc}
*/
public
function
getDerivativeDefinition
(
$derivative_id
,
array
$base_plugin_definition
)
{
public
function
getDerivativeDefinition
(
$derivative_id
,
$base_plugin_definition
)
{
if
(
!
empty
(
$this
->
derivatives
)
&&
!
empty
(
$this
->
derivatives
[
$derivative_id
]))
{
return
$this
->
derivatives
[
$derivative_id
];
}
...
...
@@ -76,7 +76,7 @@ public function getDerivativeDefinition($derivative_id, array $base_plugin_defin
/**
* {@inheritdoc}
*/
public
function
getDerivativeDefinitions
(
array
$base_plugin_definition
)
{
public
function
getDerivativeDefinitions
(
$base_plugin_definition
)
{
// Also keep the 'entity' defined as is.
$this
->
derivatives
[
''
]
=
$base_plugin_definition
;
// Add definitions for each entity type and bundle.
...
...
core/lib/Drupal/Core/Field/Plugin/DataType/Deriver/FieldItemDeriver.php
View file @
48025f92
...
...
@@ -63,7 +63,7 @@ public static function create(ContainerInterface $container, $base_plugin_id) {
/**
* {@inheritdoc}
*/
public
function
getDerivativeDefinition
(
$derivative_id
,
array
$base_plugin_definition
)
{
public
function
getDerivativeDefinition
(
$derivative_id
,
$base_plugin_definition
)
{
if
(
!
isset
(
$this
->
derivatives
))
{
$this
->
getDerivativeDefinitions
(
$base_plugin_definition
);
}
...
...
@@ -75,7 +75,7 @@ public function getDerivativeDefinition($derivative_id, array $base_plugin_defin
/**
* {@inheritdoc}
*/
public
function
getDerivativeDefinitions
(
array
$base_plugin_definition
)
{
public
function
getDerivativeDefinitions
(
$base_plugin_definition
)
{
foreach
(
$this
->
fieldTypePluginManager
->
getDefinitions
()
as
$plugin_id
=>
$definition
)
{
$definition
[
'definition_class'
]
=
'\Drupal\Core\Field\TypedData\FieldItemDataDefinition'
;
$definition
[
'list_definition_class'
]
=
'\Drupal\Core\Field\FieldDefinition'
;
...
...
core/lib/Drupal/Core/Plugin/Discovery/ContainerDerivativeDiscoveryDecorator.php
View file @
48025f92
...
...
@@ -14,7 +14,7 @@ class ContainerDerivativeDiscoveryDecorator extends DerivativeDiscoveryDecorator
/**
* {@inheritdoc}
*/
protected
function
getDerivativeFetcher
(
$base_plugin_id
,
array
$base_definition
)
{
protected
function
getDerivativeFetcher
(
$base_plugin_id
,
$base_definition
)
{
if
(
!
isset
(
$this
->
derivativeFetchers
[
$base_plugin_id
]))
{
$this
->
derivativeFetchers
[
$base_plugin_id
]
=
FALSE
;
$class
=
$this
->
getDerivativeClass
(
$base_definition
);
...
...
core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Derivative/CustomBlock.php
View file @
48025f92
...
...
@@ -17,7 +17,7 @@ class CustomBlock extends DerivativeBase {
/**
* {@inheritdoc}
*/
public
function
getDerivativeDefinitions
(
array
$base_plugin_definition
)
{
public
function
getDerivativeDefinitions
(
$base_plugin_definition
)
{
$custom_blocks
=
entity_load_multiple
(
'custom_block'
);
foreach
(
$custom_blocks
as
$custom_block
)
{
$this
->
derivatives
[
$custom_block
->
uuid
()]
=
$base_plugin_definition
;
...
...
core/modules/block/lib/Drupal/block/Plugin/Derivative/ThemeLocalTask.php
View file @
48025f92
...
...
@@ -58,7 +58,7 @@ public static function create(ContainerInterface $container, $base_plugin_id) {
/**
* {@inheritdoc}
*/
public
function
getDerivativeDefinitions
(
array
$base_plugin_definition
)
{
public
function
getDerivativeDefinitions
(
$base_plugin_definition
)
{
$default_theme
=
$this
->
config
->
get
(
'default'
);
foreach
(
$this
->
themeHandler
->
listInfo
()
as
$theme_name
=>
$theme
)
{
...
...
core/modules/config_translation/lib/Drupal/config_translation/Plugin/Derivative/ConfigTranslationContextualLinks.php
View file @
48025f92
...
...
@@ -47,7 +47,7 @@ public static function create(ContainerInterface $container, $base_plugin_id) {
/**
* {@inheritdoc}
*/
public
function
getDerivativeDefinitions
(
array
$base_plugin_definition
)
{
public
function
getDerivativeDefinitions
(
$base_plugin_definition
)
{
// Create contextual links for all mappers.
$mappers
=
$this
->
mapperManager
->
getMappers
();
foreach
(
$mappers
as
$plugin_id
=>
$mapper
)
{
...
...
core/modules/config_translation/lib/Drupal/config_translation/Plugin/Derivative/ConfigTranslationLocalTasks.php
View file @
48025f92
...
...
@@ -57,7 +57,7 @@ public static function create(ContainerInterface $container, $base_plugin_id) {
/**
* {@inheritdoc}
*/
public
function
getDerivativeDefinitions
(
array
$base_plugin_definition
)
{
public
function
getDerivativeDefinitions
(
$base_plugin_definition
)
{
$mappers
=
$this
->
mapperManager
->
getMappers
();
foreach
(
$mappers
as
$plugin_id
=>
$mapper
)
{
/** @var \Drupal\config_translation\ConfigMapperInterface $mapper */
...
...
core/modules/content_translation/lib/Drupal/content_translation/Plugin/Derivative/ContentTranslationContextualLinks.php
View file @
48025f92
...
...
@@ -49,7 +49,7 @@ public static function create(ContainerInterface $container, $base_plugin_id) {
/**
* {@inheritdoc}
*/
public
function
getDerivativeDefinitions
(
array
$base_plugin_definition
)
{
public
function
getDerivativeDefinitions
(
$base_plugin_definition
)
{
// Create contextual links for translatable entity types.
foreach
(
$this
->
contentTranslationManager
->
getSupportedEntityTypes
()
as
$entity_type_id
=>
$entity_type
)
{
$this
->
derivatives
[
$entity_type_id
][
'title'
]
=
t
(
'Translate'
);
...
...
core/modules/content_translation/lib/Drupal/content_translation/Plugin/Derivative/ContentTranslationLocalTasks.php
View file @
48025f92
...
...
@@ -57,7 +57,7 @@ public static function create(ContainerInterface $container, $base_plugin_id) {
/**
* {@inheritdoc}
*/
public
function
getDerivativeDefinitions
(
array
$base_plugin_definition
)
{
public
function
getDerivativeDefinitions
(
$base_plugin_definition
)
{
// Create tabs for all possible entity types.
foreach
(
$this
->
contentTranslationManager
->
getSupportedEntityTypes
()
as
$entity_type_id
=>
$entity_type
)
{
// Find the route name for the translation overview.
...
...
core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/Derivative/SelectionBase.php
View file @
48025f92
...
...
@@ -16,7 +16,7 @@ class SelectionBase extends DerivativeBase {
/**
* {@inheritdoc}
*/
public
function
getDerivativeDefinitions
(
array
$base_plugin_definition
)
{
public
function
getDerivativeDefinitions
(
$base_plugin_definition
)
{
$supported_entities
=
array
(
'comment'
,
'file'
,
...
...
core/modules/field_ui/lib/Drupal/field_ui/Plugin/Derivative/FieldUiLocalTask.php
View file @
48025f92
...
...
@@ -70,7 +70,7 @@ public static function create(ContainerInterface $container, $base_plugin_id) {
/**
* {@inheritdoc}
*/
public
function
getDerivativeDefinitions
(
array
$base_plugin_definition
)
{
public
function
getDerivativeDefinitions
(
$base_plugin_definition
)
{
$this
->
derivatives
=
array
();
foreach
(
$this
->
entityManager
->
getDefinitions
()
as
$entity_type_id
=>
$entity_type
)
{
...
...
core/modules/language/lib/Drupal/language/Plugin/Derivative/LanguageBlock.php
View file @
48025f92
...
...
@@ -18,7 +18,7 @@ class LanguageBlock extends DerivativeBase {
/**
* {@inheritdoc}
*/
public
function
getDerivativeDefinitions
(
array
$base_plugin_definition
)
{
public
function
getDerivativeDefinitions
(
$base_plugin_definition
)
{
$language_manager
=
\
Drupal
::
languageManager
();
if
(
$language_manager
instanceof
ConfigurableLanguageManagerInterface
)
{
...
...
core/modules/rest/lib/Drupal/rest/Plugin/Derivative/EntityDerivative.php
View file @
48025f92
...
...
@@ -52,7 +52,7 @@ public static function create(ContainerInterface $container, $base_plugin_id) {
/**
* Implements DerivativeInterface::getDerivativeDefinition().
*/
public
function
getDerivativeDefinition
(
$derivative_id
,
array
$base_plugin_definition
)
{
public
function
getDerivativeDefinition
(
$derivative_id
,
$base_plugin_definition
)
{
if
(
!
isset
(
$this
->
derivatives
))
{
$this
->
getDerivativeDefinitions
(
$base_plugin_definition
);
}
...
...
@@ -64,7 +64,7 @@ public function getDerivativeDefinition($derivative_id, array $base_plugin_defin
/**
* Implements DerivativeInterface::getDerivativeDefinitions().
*/
public
function
getDerivativeDefinitions
(
array
$base_plugin_definition
)
{
public
function
getDerivativeDefinitions
(
$base_plugin_definition
)
{
if
(
!
isset
(
$this
->
derivatives
))
{
// Add in the default plugin configuration and the resource type.
foreach
(
$this
->
entityManager
->
getDefinitions
()
as
$entity_type_id
=>
$entity_type
)
{
...
...
core/modules/search/lib/Drupal/search/Plugin/Derivative/SearchLocalTask.php
View file @
48025f92
...
...
@@ -46,7 +46,7 @@ public static function create(ContainerInterface $container, $base_plugin_id) {
/**
* {@inheritdoc}
*/
public
function
getDerivativeDefinitions
(
array
$base_plugin_definition
)
{
public
function
getDerivativeDefinitions
(
$base_plugin_definition
)
{
$this
->
derivatives
=
array
();
if
(
$default
=
$this
->
searchPageRepository
->
getDefaultSearchPage
())
{
...
...
core/modules/system/lib/Drupal/system/Plugin/Derivative/SystemMenuBlock.php
View file @
48025f92
...
...
@@ -48,7 +48,7 @@ public static function create(ContainerInterface $container, $base_plugin_id) {
/**
* {@inheritdoc}
*/
public
function
getDerivativeDefinitions
(
array
$base_plugin_definition
)
{
public
function
getDerivativeDefinitions
(
$base_plugin_definition
)
{
foreach
(
$this
->
menuStorage
->
loadMultiple
()
as
$menu
=>
$entity
)
{
$this
->
derivatives
[
$menu
]
=
$base_plugin_definition
;
$this
->
derivatives
[
$menu
][
'admin_label'
]
=
$entity
->
label
();
...
...
core/modules/system/lib/Drupal/system/Plugin/Derivative/ThemeLocalTask.php
View file @
48025f92
...
...
@@ -17,7 +17,7 @@ class ThemeLocalTask extends DerivativeBase {
/**
* {@inheritdoc}
*/
public
function
getDerivativeDefinitions
(
array
$base_plugin_definition
)
{
public
function
getDerivativeDefinitions
(
$base_plugin_definition
)
{
foreach
(
list_themes
()
as
$theme_name
=>
$theme
)
{
if
(
$theme
->
status
)
{
$this
->
derivatives
[
$theme_name
]
=
$base_plugin_definition
;
...
...
core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Plugin/Derivative/EntityTestLocalTasks.php
View file @
48025f92
...
...
@@ -17,7 +17,7 @@ class EntityTestLocalTasks extends DerivativeBase {
/**
* {@inheritdoc}
*/
public
function
getDerivativeDefinitions
(
array
$base_plugin_definition
)
{
public
function
getDerivativeDefinitions
(
$base_plugin_definition
)
{
$this
->
derivatives
=
array
();
$types
=
entity_test_entity_types
();
...
...
core/modules/system/tests/modules/menu_test/lib/Drupal/menu_test/Plugin/Derivative/LocalTaskTest.php
View file @
48025f92
...
...
@@ -13,7 +13,7 @@ class LocalTaskTest extends DerivativeBase {
/**
* {@inheritdoc}
*/
public
function
getDerivativeDefinitions
(
array
$base_plugin_definition
)
{
public
function
getDerivativeDefinitions
(
$base_plugin_definition
)
{
$weight
=
$base_plugin_definition
[
'weight'
];
foreach
(
array
(
'derive1'
=>
'Derive 1'
,
'derive2'
=>
'Derive 2'
)
as
$key
=>
$title
)
{
$this
->
derivatives
[
$key
]
=
$base_plugin_definition
;
...
...
core/modules/system/tests/modules/plugin_test/lib/Drupal/plugin_test/Plugin/plugin_test/mock_block/MockLayoutBlockDeriver.php
View file @
48025f92
...
...
@@ -19,7 +19,7 @@ class MockLayoutBlockDeriver implements DerivativeInterface {
/**
* Implements Drupal\Component\Plugin\Derivative\DerivativeInterface::getDerivativeDefinition().
*/
public
function
getDerivativeDefinition
(
$derivative_id
,
array
$base_plugin_definition
)
{
public
function
getDerivativeDefinition
(
$derivative_id
,
$base_plugin_definition
)
{
$derivatives
=
$this
->
getDerivativeDefinitions
(
$base_plugin_definition
);
if
(
isset
(
$derivatives
[
$derivative_id
]))
{
return
$derivatives
[
$derivative_id
];
...
...
@@ -29,7 +29,7 @@ public function getDerivativeDefinition($derivative_id, array $base_plugin_defin
/**
* Implements Drupal\Component\Plugin\Derivative\DerivativeInterface::getDerivativeDefinitions().
*/
public
function
getDerivativeDefinitions
(
array
$base_plugin_definition
)
{
public
function
getDerivativeDefinitions
(
$base_plugin_definition
)
{
// This isn't strictly necessary, but it helps reduce clutter in
// DerivativePluginTest::testDerivativeDecorator()'s $expected variable.
// Since derivative definitions don't need further deriving, we remove this
...
...
core/modules/system/tests/modules/plugin_test/lib/Drupal/plugin_test/Plugin/plugin_test/mock_block/MockMenuBlockDeriver.php
View file @
48025f92
...
...
@@ -19,7 +19,7 @@ class MockMenuBlockDeriver implements DerivativeInterface {
/**
* Implements Drupal\Component\Plugin\Derivative\DerivativeInterface::getDerivativeDefinition().
*/
public
function
getDerivativeDefinition
(
$derivative_id
,
array
$base_plugin_definition
)
{
public
function
getDerivativeDefinition
(
$derivative_id
,
$base_plugin_definition
)
{
$derivatives
=
$this
->
getDerivativeDefinitions
(
$base_plugin_definition
);
if
(
isset
(
$derivatives
[
$derivative_id
]))
{
return
$derivatives
[
$derivative_id
];
...
...
@@ -29,7 +29,7 @@ public function getDerivativeDefinition($derivative_id, array $base_plugin_defin
/**
* Implements Drupal\Component\Plugin\Derivative\DerivativeInterface::getDerivativeDefinitions().
*/
public
function
getDerivativeDefinitions
(
array
$base_plugin_definition
)
{
public
function
getDerivativeDefinitions
(
$base_plugin_definition
)
{
// This isn't strictly necessary, but it helps reduce clutter in
// DerivativePluginTest::testDerivativeDecorator()'s $expected variable.
// Since derivative definitions don't need further deriving, we remove this
...
...
core/modules/views/lib/Drupal/views/Plugin/Derivative/DefaultWizardDeriver.php
View file @
48025f92
...
...
@@ -19,7 +19,7 @@ class DefaultWizardDeriver extends DerivativeBase {
/**
* {@inheritdoc}
*/
public
function
getDerivativeDefinitions
(
array
$base_plugin_definition
)
{
public
function
getDerivativeDefinitions
(
$base_plugin_definition
)
{
$views_data
=
Views
::
viewsData
();
$base_tables
=
array_keys
(
$views_data
->
fetchBaseTables
());
$this
->
derivatives
=
array
();
...
...
core/modules/views/lib/Drupal/views/Plugin/Derivative/ViewsBlock.php
View file @
48025f92
...
...
@@ -65,7 +65,7 @@ public function __construct($base_plugin_id, EntityStorageControllerInterface $v
/**
* Implements \Drupal\Component\Plugin\Derivative\DerivativeInterface::getDerivativeDefinition().
*/
public
function
getDerivativeDefinition
(
$derivative_id
,
array
$base_plugin_definition
)
{
public
function
getDerivativeDefinition
(
$derivative_id
,
$base_plugin_definition
)
{
if
(
!
empty
(
$this
->
derivatives
)
&&
!
empty
(
$this
->
derivatives
[
$derivative_id
]))
{
return
$this
->
derivatives
[
$derivative_id
];
}
...
...
@@ -76,7 +76,7 @@ public function getDerivativeDefinition($derivative_id, array $base_plugin_defin
/**
* Implements \Drupal\Component\Plugin\Derivative\DerivativeInterface::getDerivativeDefinitions().
*/
public
function
getDerivativeDefinitions
(
array
$base_plugin_definition
)
{
public
function
getDerivativeDefinitions
(
$base_plugin_definition
)
{
// Check all Views for block displays.
foreach
(
$this
->
viewStorageController
->
loadMultiple
()
as
$view
)
{
// Do not return results for disabled views.
...
...
core/modules/views/lib/Drupal/views/Plugin/Derivative/ViewsEntityArgumentValidator.php
View file @
48025f92
...
...
@@ -79,7 +79,7 @@ public static function create(ContainerInterface $container, $base_plugin_id) {
/**
* {@inheritdoc}
*/
public
function
getDerivativeDefinitions
(
array
$base_plugin_definition
)
{
public
function
getDerivativeDefinitions
(
$base_plugin_definition
)
{
$entity_types
=
$this
->
entityManager
->
getDefinitions
();
$this
->
derivatives
=
array
();
foreach
(
$entity_types
as
$entity_type_id
=>
$entity_type
)
{
...
...
core/modules/views/lib/Drupal/views/Plugin/Derivative/ViewsEntityRow.php
View file @
48025f92
...
...
@@ -79,7 +79,7 @@ public static function create(ContainerInterface $container, $base_plugin_id) {
/**
* {@inheritdoc}
*/
public
function
getDerivativeDefinition
(
$derivative_id
,
array
$base_plugin_definition
)
{
public
function
getDerivativeDefinition
(
$derivative_id
,
$base_plugin_definition
)
{
if
(
!
empty
(
$this
->
derivatives
)
&&
!
empty
(
$this
->
derivatives
[
$derivative_id
]))
{
return
$this
->
derivatives
[
$derivative_id
];
}
...
...
@@ -90,7 +90,7 @@ public function getDerivativeDefinition($derivative_id, array $base_plugin_defin
/**
* {@inheritdoc}
*/
public
function
getDerivativeDefinitions
(
array
$base_plugin_definition
)
{
public
function
getDerivativeDefinitions
(
$base_plugin_definition
)
{
foreach
(
$this
->
entityManager
->
getDefinitions
()
as
$entity_type_id
=>
$entity_type
)
{
// Just add support for entity types which have a views integration.
if
((
$base_table
=
$entity_type
->
getBaseTable
())
&&
$this
->
viewsData
->
get
(
$base_table
)
&&
$this
->
entityManager
->
hasController
(
$entity_type_id
,
'view_builder'
))
{
...
...
core/modules/views/lib/Drupal/views/Plugin/Derivative/ViewsExposedFilterBlock.php
View file @
48025f92
...
...
@@ -65,7 +65,7 @@ public static function create(ContainerInterface $container, $base_plugin_id) {
/**
* Implements \Drupal\Component\Plugin\Derivative\DerivativeInterface::getDerivativeDefinition().
*/
public
function
getDerivativeDefinition
(
$derivative_id
,
array
$base_plugin_definition
)
{
public
function
getDerivativeDefinition
(
$derivative_id
,
$base_plugin_definition
)
{
if
(
!
empty
(
$this
->
derivatives
)
&&
!
empty
(
$this
->
derivatives
[
$derivative_id
]))
{
return
$this
->
derivatives
[
$derivative_id
];
}
...
...
@@ -76,7 +76,7 @@ public function getDerivativeDefinition($derivative_id, array $base_plugin_defin
/**
* Implements \Drupal\Component\Plugin\Derivative\DerivativeInterface::getDerivativeDefinitions().
*/
public
function
getDerivativeDefinitions
(
array
$base_plugin_definition
)
{
public
function
getDerivativeDefinitions
(
$base_plugin_definition
)
{
// Check all Views for displays with an exposed filter block.
foreach
(
$this
->
viewStorageController
->
loadMultiple
()
as
$view
)
{
// Do not return results for disabled views.
...
...
core/modules/views/lib/Drupal/views/Plugin/Derivative/ViewsLocalTask.php
View file @
48025f92
...
...
@@ -59,7 +59,7 @@ public static function create(ContainerInterface $container, $base_plugin_id) {
/**
* {@inheritdoc}
*/
public
function
getDerivativeDefinitions
(
array
$base_plugin_definition
)
{
public
function
getDerivativeDefinitions
(
$base_plugin_definition
)
{
$this
->
derivatives
=
array
();
$view_route_names
=
$this
->
state
->
get
(
'views.view_route_names'
);
...
...
core/tests/Drupal/Tests/Core/Plugin/Discovery/DerivativeDiscoveryDecoratorTest.php
View file @
48025f92
...
...
@@ -49,6 +49,40 @@ public function testGetDerivativeFetcher() {
// Ensure that both test derivatives got added.
$this
->
assertEquals
(
2
,
count
(
$definitions
));
$this
->
assertEquals
(
'non_container_aware_discovery'
,
$definitions
[
'non_container_aware_discovery:test_discovery_0'
][
'id'
]);
$this
->
assertEquals
(
'\Drupal\Tests\Core\Plugin\Discovery\TestDerivativeDiscovery'
,
$definitions
[
'non_container_aware_discovery:test_discovery_0'
][
'derivative'
]);
$this
->
assertEquals
(
'non_container_aware_discovery'
,
$definitions
[
'non_container_aware_discovery:test_discovery_1'
][
'id'
]);
$this
->
assertEquals
(
'\Drupal\Tests\Core\Plugin\Discovery\TestDerivativeDiscovery'
,
$definitions
[
'non_container_aware_discovery:test_discovery_1'
][
'derivative'
]);
}
/**
* Tests the getDerivativeFetcher method with objects instead of arrays.
*/
public
function
testGetDerivativeFetcherWithAnnotationObjects
()
{
$definitions
=
array
();
$definitions
[
'non_container_aware_discovery'
]
=
(
object
)
array
(
'id'
=>
'non_container_aware_discovery'
,
'derivative'
=>
'\Drupal\Tests\Core\Plugin\Discovery\TestDerivativeDiscoveryWithObject'
,
);
$discovery_main
=
$this
->
getMock
(
'Drupal\Component\Plugin\Discovery\DiscoveryInterface'
);
$discovery_main
->
expects
(
$this
->
any
())
->
method
(
'getDefinitions'
)
->
will
(
$this
->
returnValue
(
$definitions
));
$discovery
=
new
DerivativeDiscoveryDecorator
(
$discovery_main
);
$definitions
=
$discovery
->
getDefinitions
();
// Ensure that both test derivatives got added.
$this
->
assertEquals
(
2
,
count
(
$definitions
));
$this
->
assertInstanceOf
(
'\stdClass'
,
$definitions
[
'non_container_aware_discovery:test_discovery_0'
]);
$this
->
assertEquals
(
'non_container_aware_discovery'
,
$definitions
[
'non_container_aware_discovery:test_discovery_0'
]
->
id
);
$this
->
assertEquals
(
'\Drupal\Tests\Core\Plugin\Discovery\TestDerivativeDiscoveryWithObject'
,
$definitions
[
'non_container_aware_discovery:test_discovery_0'
]
->
derivative
);
$this
->
assertInstanceOf
(
'\stdClass'
,
$definitions
[
'non_container_aware_discovery:test_discovery_1'
]);
$this
->
assertEquals
(
'non_container_aware_discovery'
,
$definitions
[
'non_container_aware_discovery:test_discovery_1'
]
->
id
);
$this
->
assertEquals
(
'\Drupal\Tests\Core\Plugin\Discovery\TestDerivativeDiscoveryWithObject'
,
$definitions
[
'non_container_aware_discovery:test_discovery_1'
]
->
derivative
);
}
/**
...
...
@@ -56,7 +90,7 @@ public function testGetDerivativeFetcher() {
*
* @see \Drupal\Component\Plugin\Discovery\DerivativeDiscoveryDecorator::getDerivativeFetcher().\
*
* @expectedException Drupal\Component\Plugin\Exception\InvalidDerivativeClassException
* @expectedException
\
Drupal\Component\Plugin\Exception\InvalidDerivativeClassException
*/
public
function
testInvalidDerivativeFetcher
()
{
$definitions
=
array
();
...
...
@@ -71,6 +105,6 @@ public function testInvalidDerivativeFetcher() {
->
will
(
$this
->
returnValue
(
$definitions
));
$discovery
=
new
DerivativeDiscoveryDecorator
(
$discovery_main
);
$d
efinitions
=
$d
iscovery
->
getDefinitions
();
$discovery
->
getDefinitions
();
}
}
core/tests/Drupal/Tests/Core/Plugin/Discovery/TestDerivativeDiscovery.php
View file @
48025f92
...
...
@@ -17,7 +17,7 @@ class TestDerivativeDiscovery implements DerivativeInterface {
/**
* {@inheritdoc}
*/
public
function
getDerivativeDefinition
(
$derivative_id
,
array
$base_plugin_definition
)
{
public
function
getDerivativeDefinition
(
$derivative_id
,
$base_plugin_definition
)
{
$definitions
=
$this
->
getDerivativeDefinitions
(
$base_plugin_definition
);
return
$definitions
[
$derivative_id
];
}
...
...
@@ -25,7 +25,7 @@ public function getDerivativeDefinition($derivative_id, array $base_plugin_defin
/**
* {@inheritdoc}
*/
public
function
getDerivativeDefinitions
(
array
$base_plugin_definition
)
{
public
function
getDerivativeDefinitions
(
$base_plugin_definition
)
{
$plugins
=
array
();
for
(
$i
=
0
;
$i
<
2
;
$i
++
)
{
$plugins
[
'test_discovery_'
.
$i
]
=
$base_plugin_definition
;
...
...
core/tests/Drupal/Tests/Core/Plugin/Discovery/TestDerivativeDiscoveryWithObject.php
0 → 100644
View file @
48025f92
<?php
/**
* @file
* Contains \Drupal\Tests\Core\Plugin\Discovery\TestDerivativeDiscoveryWithObject.
*/
namespace
Drupal\Tests\Core\Plugin\Discovery
;
use
Drupal\Component\Plugin\Derivative\DerivativeInterface
;
/**
* Defines test derivative discovery using an object..
*/
class
TestDerivativeDiscoveryWithObject
implements
DerivativeInterface
{
/**
* {@inheritdoc}
* @param string $derivative_id
* @param array $base_plugin_definition
* @return array
*/
public
function
getDerivativeDefinition
(
$derivative_id
,
$base_plugin_definition
)
{
$definitions
=
$this
->
getDerivativeDefinitions
(
$base_plugin_definition
);
return
$definitions
[
$derivative_id
];
}
/**
* {@inheritdoc}
* @param array $base_plugin_definition
* @return array
*/
public
function
getDerivativeDefinitions
(
$base_plugin_definition
)
{
$plugins
=
array
();
for
(
$i
=
0
;
$i
<
2
;
$i
++
)
{
$plugins
[
'test_discovery_'
.
$i
]
=
$base_plugin_definition
;
}
return
$plugins
;
}
}
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