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
d88a2be4
Commit
d88a2be4
authored
Jul 25, 2013
by
alexpott
Browse files
Issue
#2043379
by tim.plunkett: Allow plugins to be discovered in any directory.
parent
45014004
Changes
32
Hide whitespace changes
Inline
Side-by-side
core/lib/Drupal/Core/Action/ActionManager.php
View file @
d88a2be4
...
...
@@ -28,7 +28,7 @@ class ActionManager extends PluginManagerBase {
* keyed by the corresponding namespace to look for plugin implementations.
*/
public
function
__construct
(
\
Traversable
$namespaces
)
{
$this
->
discovery
=
new
AnnotatedClassDiscovery
(
'Action'
,
$namespaces
,
array
(),
'Drupal\Core\Annotation\Action'
);
$this
->
discovery
=
new
AnnotatedClassDiscovery
(
'
Plugin/
Action'
,
$namespaces
,
array
(),
'Drupal\Core\Annotation\Action'
);
$this
->
discovery
=
new
AlterDecorator
(
$this
->
discovery
,
'action_info'
);
$this
->
factory
=
new
ContainerFactory
(
$this
);
...
...
core/lib/Drupal/Core/Archiver/ArchiverManager.php
View file @
d88a2be4
...
...
@@ -31,7 +31,7 @@ class ArchiverManager extends DefaultPluginManager {
* The module handler to invoke the alter hook with.
*/
public
function
__construct
(
\
Traversable
$namespaces
,
CacheBackendInterface
$cache_backend
,
LanguageManager
$language_manager
,
ModuleHandlerInterface
$module_handler
)
{
parent
::
__construct
(
'Archiver'
,
$namespaces
);
parent
::
__construct
(
'
Plugin/
Archiver'
,
$namespaces
);
$this
->
alterInfo
(
$module_handler
,
'archiver_info'
);
$this
->
setCacheBackend
(
$cache_backend
,
$language_manager
,
'archiver_info'
);
}
...
...
core/lib/Drupal/Core/Condition/ConditionManager.php
View file @
d88a2be4
...
...
@@ -39,7 +39,7 @@ public function __construct(\Traversable $namespaces, CacheBackendInterface $cac
$annotation_namespaces
=
array
(
'Drupal\Core\Condition\Annotation'
=>
DRUPAL_ROOT
.
'/core/lib'
,
);
parent
::
__construct
(
'Condition'
,
$namespaces
,
$annotation_namespaces
,
'Drupal\Core\Condition\Annotation\Condition'
);
parent
::
__construct
(
'
Plugin/
Condition'
,
$namespaces
,
$annotation_namespaces
,
'Drupal\Core\Condition\Annotation\Condition'
);
}
/**
...
...
core/lib/Drupal/Core/Entity/EntityManager.php
View file @
d88a2be4
...
...
@@ -112,7 +112,7 @@ public function __construct(\Traversable $namespaces, ContainerInterface $contai
$this
->
cache
=
$cache
;
$this
->
languageManager
=
$language_manager
;
$this
->
discovery
=
new
AnnotatedClassDiscovery
(
'Core/Entity'
,
$namespaces
,
$annotation_namespaces
,
'Drupal\Core\Entity\Annotation\EntityType'
);
$this
->
discovery
=
new
AnnotatedClassDiscovery
(
'
Plugin/
Core/Entity'
,
$namespaces
,
$annotation_namespaces
,
'Drupal\Core\Entity\Annotation\EntityType'
);
$this
->
discovery
=
new
InfoHookDecorator
(
$this
->
discovery
,
'entity_info'
);
$this
->
discovery
=
new
AlterDecorator
(
$this
->
discovery
,
'entity_info'
);
$this
->
discovery
=
new
CacheDecorator
(
$this
->
discovery
,
'entity_info:'
.
$this
->
languageManager
->
getLanguage
(
Language
::
TYPE_INTERFACE
)
->
id
,
'cache'
,
CacheBackendInterface
::
CACHE_PERMANENT
,
array
(
'entity_info'
=>
TRUE
));
...
...
core/lib/Drupal/Core/Entity/Field/FieldTypePluginManager.php
View file @
d88a2be4
...
...
@@ -45,7 +45,7 @@ public function __construct(\Traversable $namespaces, CacheBackendInterface $cac
$annotation_namespaces
=
array
(
'Drupal\Core\Entity\Annotation'
=>
DRUPAL_ROOT
.
'/core/lib'
,
);
parent
::
__construct
(
'field/field_type'
,
$namespaces
,
$annotation_namespaces
,
'Drupal\Core\Entity\Annotation\FieldType'
);
parent
::
__construct
(
'
Plugin/
field/field_type'
,
$namespaces
,
$annotation_namespaces
,
'Drupal\Core\Entity\Annotation\FieldType'
);
$this
->
alterInfo
(
$module_handler
,
'field_info'
);
$this
->
setCacheBackend
(
$cache_backend
,
$language_manager
,
'field_types'
);
...
...
core/lib/Drupal/Core/Menu/LocalActionManager.php
View file @
d88a2be4
...
...
@@ -59,7 +59,7 @@ class LocalActionManager extends DefaultPluginManager {
* The module handler.
*/
public
function
__construct
(
\
Traversable
$namespaces
,
ControllerResolverInterface
$controller_resolver
,
Request
$request
,
ModuleHandlerInterface
$module_handler
)
{
parent
::
__construct
(
'Menu
\
LocalAction'
,
$namespaces
,
array
(),
'Drupal\Core\Annotation\Menu\LocalAction'
);
parent
::
__construct
(
'
Plugin/
Menu
/
LocalAction'
,
$namespaces
,
array
(),
'Drupal\Core\Annotation\Menu\LocalAction'
);
$this
->
controllerResolver
=
$controller_resolver
;
$this
->
request
=
$request
;
...
...
core/lib/Drupal/Core/Menu/LocalTaskManager.php
View file @
d88a2be4
...
...
@@ -66,7 +66,7 @@ class LocalTaskManager extends DefaultPluginManager {
* The module handler.u
*/
public
function
__construct
(
\
Traversable
$namespaces
,
ControllerResolverInterface
$controller_resolver
,
Request
$request
,
RouteProviderInterface
$route_provider
,
ModuleHandlerInterface
$module_handler
)
{
parent
::
__construct
(
'Menu
\
LocalTask'
,
$namespaces
,
array
(),
'Drupal\Core\Annotation\Menu\LocalTask'
);
parent
::
__construct
(
'
Plugin/
Menu
/
LocalTask'
,
$namespaces
,
array
(),
'Drupal\Core\Annotation\Menu\LocalTask'
);
$this
->
controllerResolver
=
$controller_resolver
;
$this
->
request
=
$request
;
$this
->
routeProvider
=
$route_provider
;
...
...
core/lib/Drupal/Core/Plugin/DefaultPluginManager.php
View file @
d88a2be4
...
...
@@ -60,9 +60,10 @@ class DefaultPluginManager extends PluginManagerBase implements PluginManagerInt
protected
$alterHook
;
/**
* The plugin's subdirectory, for example views/filter.
* The subdirectory within a namespace to look for plugins, or FALSE if the
* plugins are in the top level of the namespace.
*
* @var string
* @var string
|bool
*/
protected
$subdir
;
...
...
@@ -83,11 +84,11 @@ class DefaultPluginManager extends PluginManagerBase implements PluginManagerInt
/**
* Creates the discovery object.
*
* @param string $subdir
* The plugin's subdirectory, for example views/filter.
* @param string
|bool
$subdir
* The plugin's subdirectory, for example
Plugin/
views/filter.
* @param \Traversable $namespaces
* An object that implements \Traversable which contains the root paths
* keyed by the corresponding namespace to look for plugin implementations
* keyed by the corresponding namespace to look for plugin implementations
.
* @param array $annotation_namespaces
* (optional) The namespaces of classes that can be used as annotations.
* Defaults to an empty array.
...
...
core/lib/Drupal/Core/Plugin/Discovery/AnnotatedClassDiscovery.php
View file @
d88a2be4
...
...
@@ -15,18 +15,14 @@
class
AnnotatedClassDiscovery
extends
ComponentAnnotatedClassDiscovery
{
/**
* The
module name that defines the
plugin
type
.
* The
subdirectory within a namespace to look for
plugin
s
.
*
* @var string
*/
protected
$owner
;
/**
* The plugin type, for example filter.
* If the plugins are in the top level of the namespace and not within a
* subdirectory, set this to an empty string.
*
* @var string
*/
protected
$
type
;
protected
$
subdir
=
''
;
/**
* An object containing the namespaces to look for plugin implementations.
...
...
@@ -39,11 +35,12 @@ class AnnotatedClassDiscovery extends ComponentAnnotatedClassDiscovery {
* Constructs an AnnotatedClassDiscovery object.
*
* @param string $subdir
* The plugin's subdirectory, for example views/filter.
* Either the plugin's subdirectory, for example 'Plugin/views/filter', or
* empty string if plugins are located at the top level of the namespace.
* @param \Traversable $root_namespaces
* An object that implements \Traversable which contains the root paths
* keyed by the corresponding namespace to look for plugin implementations
,
*
\Plugin\$subdir
will be appended to each namespace.
* keyed by the corresponding namespace to look for plugin implementations
.
*
If $subdir is not an empty string, it
will be appended to each namespace.
* @param array $annotation_namespaces
* (optional) The namespaces of classes that can be used as annotations.
* Defaults to an empty array.
...
...
@@ -52,7 +49,9 @@ class AnnotatedClassDiscovery extends ComponentAnnotatedClassDiscovery {
* Defaults to 'Drupal\Component\Annotation\Plugin'.
*/
function
__construct
(
$subdir
,
\
Traversable
$root_namespaces
,
$annotation_namespaces
=
array
(),
$plugin_definition_annotation_name
=
'Drupal\Component\Annotation\Plugin'
)
{
$this
->
subdir
=
str_replace
(
'/'
,
'\\'
,
$subdir
);
if
(
$subdir
)
{
$this
->
subdir
=
str_replace
(
'/'
,
'\\'
,
$subdir
);
}
$this
->
rootNamespacesIterator
=
$root_namespaces
;
$annotation_namespaces
+=
array
(
'Drupal\Component\Annotation'
=>
DRUPAL_ROOT
.
'/core/lib'
,
...
...
@@ -101,7 +100,10 @@ protected function getProviderFromNamespace($namespace) {
protected
function
getPluginNamespaces
()
{
$plugin_namespaces
=
array
();
foreach
(
$this
->
rootNamespacesIterator
as
$namespace
=>
$dir
)
{
$plugin_namespaces
[
"
$namespace
\\
Plugin
\\
{
$this
->
subdir
}
"
]
=
array
(
$dir
);
if
(
$this
->
subdir
)
{
$namespace
.
=
"
\\
{
$this
->
subdir
}
"
;
}
$plugin_namespaces
[
$namespace
]
=
array
(
$dir
);
}
return
$plugin_namespaces
;
...
...
core/lib/Drupal/Core/TypedData/TypedDataManager.php
View file @
d88a2be4
...
...
@@ -52,7 +52,7 @@ public function __construct(\Traversable $namespaces, CacheBackendInterface $cac
$annotation_namespaces
=
array
(
'Drupal\Core\TypedData\Annotation'
=>
DRUPAL_ROOT
.
'/core/lib'
,
);
parent
::
__construct
(
'DataType'
,
$namespaces
,
$annotation_namespaces
,
'Drupal\Core\TypedData\Annotation\DataType'
);
parent
::
__construct
(
'
Plugin/
DataType'
,
$namespaces
,
$annotation_namespaces
,
'Drupal\Core\TypedData\Annotation\DataType'
);
}
/**
...
...
core/lib/Drupal/Core/Validation/ConstraintManager.php
View file @
d88a2be4
...
...
@@ -47,7 +47,7 @@ class ConstraintManager extends DefaultPluginManager {
* The module handler to invoke the alter hook with.
*/
public
function
__construct
(
\
Traversable
$namespaces
,
CacheBackendInterface
$cache_backend
,
LanguageManager
$language_manager
,
ModuleHandlerInterface
$module_handler
)
{
parent
::
__construct
(
'Validation/Constraint'
,
$namespaces
);
parent
::
__construct
(
'
Plugin/
Validation/Constraint'
,
$namespaces
);
$this
->
discovery
=
new
StaticDiscoveryDecorator
(
$this
->
discovery
,
array
(
$this
,
'registerDefinitions'
));
$this
->
alterInfo
(
$module_handler
,
'validation_constraint'
);
$this
->
setCacheBackend
(
$cache_backend
,
$language_manager
,
'validation_constraint'
);
...
...
core/modules/aggregator/lib/Drupal/aggregator/Plugin/AggregatorPluginManager.php
View file @
d88a2be4
...
...
@@ -38,7 +38,7 @@ public function __construct($type, \Traversable $namespaces) {
'Drupal\aggregator\Annotation'
=>
DRUPAL_ROOT
.
'/core/modules/aggregator/lib'
,
);
$this
->
discovery
=
new
AnnotatedClassDiscovery
(
"aggregator/
$type
"
,
$namespaces
,
$annotation_namespaces
,
$type_annotations
[
$type
]);
$this
->
discovery
=
new
AnnotatedClassDiscovery
(
"
Plugin/
aggregator/
$type
"
,
$namespaces
,
$annotation_namespaces
,
$type_annotations
[
$type
]);
$this
->
discovery
=
new
CacheDecorator
(
$this
->
discovery
,
"aggregator_
$type
:"
.
language
(
Language
::
TYPE_INTERFACE
)
->
id
);
$this
->
factory
=
new
DefaultFactory
(
$this
->
discovery
);
}
...
...
core/modules/block/lib/Drupal/block/Plugin/Type/BlockManager.php
View file @
d88a2be4
...
...
@@ -33,7 +33,7 @@ class BlockManager extends DefaultPluginManager {
* The module handler to invoke the alter hook with.
*/
public
function
__construct
(
\
Traversable
$namespaces
,
CacheBackendInterface
$cache_backend
,
LanguageManager
$language_manager
,
ModuleHandlerInterface
$module_handler
)
{
parent
::
__construct
(
'Block'
,
$namespaces
);
parent
::
__construct
(
'
Plugin/
Block'
,
$namespaces
);
$this
->
alterInfo
(
$module_handler
,
'block'
);
$this
->
setCacheBackend
(
$cache_backend
,
$language_manager
,
'block_plugins'
);
}
...
...
core/modules/ckeditor/lib/Drupal/ckeditor/CKEditorPluginManager.php
View file @
d88a2be4
...
...
@@ -34,7 +34,7 @@ class CKEditorPluginManager extends DefaultPluginManager {
*/
public
function
__construct
(
\
Traversable
$namespaces
,
CacheBackendInterface
$cache_backend
,
LanguageManager
$language_manager
,
ModuleHandlerInterface
$module_handler
)
{
$annotation_namespaces
=
array
(
'Drupal\ckeditor\Annotation'
=>
$namespaces
[
'Drupal\ckeditor'
]);
parent
::
__construct
(
'CKEditorPlugin'
,
$namespaces
,
$annotation_namespaces
,
'Drupal\ckeditor\Annotation\CKEditorPlugin'
);
parent
::
__construct
(
'
Plugin/
CKEditorPlugin'
,
$namespaces
,
$annotation_namespaces
,
'Drupal\ckeditor\Annotation\CKEditorPlugin'
);
$this
->
alterInfo
(
$module_handler
,
'ckeditor_plugin_info'
);
$this
->
setCacheBackend
(
$cache_backend
,
$language_manager
,
'ckeditor_plugin'
);
}
...
...
core/modules/edit/lib/Drupal/edit/Plugin/InPlaceEditorManager.php
View file @
d88a2be4
...
...
@@ -30,7 +30,7 @@ class InPlaceEditorManager extends PluginManagerBase {
*/
public
function
__construct
(
\
Traversable
$namespaces
)
{
$annotation_namespaces
=
array
(
'Drupal\edit\Annotation'
=>
$namespaces
[
'Drupal\edit'
]);
$this
->
discovery
=
new
AnnotatedClassDiscovery
(
'InPlaceEditor'
,
$namespaces
,
$annotation_namespaces
,
'Drupal\edit\Annotation\InPlaceEditor'
);
$this
->
discovery
=
new
AnnotatedClassDiscovery
(
'
Plugin/
InPlaceEditor'
,
$namespaces
,
$annotation_namespaces
,
'Drupal\edit\Annotation\InPlaceEditor'
);
$this
->
discovery
=
new
AlterDecorator
(
$this
->
discovery
,
'edit_editor'
);
$this
->
discovery
=
new
CacheDecorator
(
$this
->
discovery
,
'edit:editor'
);
$this
->
factory
=
new
DefaultFactory
(
$this
->
discovery
);
...
...
core/modules/editor/lib/Drupal/editor/Plugin/EditorManager.php
View file @
d88a2be4
...
...
@@ -32,7 +32,7 @@ class EditorManager extends DefaultPluginManager {
*/
public
function
__construct
(
\
Traversable
$namespaces
,
CacheBackendInterface
$cache_backend
,
LanguageManager
$language_manager
,
ModuleHandlerInterface
$module_handler
)
{
$annotation_namespaces
=
array
(
'Drupal\editor\Annotation'
=>
$namespaces
[
'Drupal\editor'
]);
parent
::
__construct
(
'Editor'
,
$namespaces
,
$annotation_namespaces
,
'Drupal\editor\Annotation\Editor'
);
parent
::
__construct
(
'
Plugin/
Editor'
,
$namespaces
,
$annotation_namespaces
,
'Drupal\editor\Annotation\Editor'
);
$this
->
alterInfo
(
$module_handler
,
'editor_info'
);
$this
->
setCacheBackend
(
$cache_backend
,
$language_manager
,
'editor'
);
}
...
...
core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/Type/SelectionPluginManager.php
View file @
d88a2be4
...
...
@@ -25,11 +25,8 @@ class SelectionPluginManager extends DefaultPluginManager {
* {@inheritdoc}
*/
public
function
__construct
(
\
Traversable
$namespaces
,
CacheBackendInterface
$cache_backend
,
LanguageManager
$language_manager
,
ModuleHandlerInterface
$module_handler
)
{
$this
->
subdir
=
'entity_reference/selection'
;
$annotation_namespaces
=
array
(
'Drupal\entity_reference\Annotation'
=>
$namespaces
[
'Drupal\entity_reference'
]
);
$this
->
discovery
=
new
AnnotatedClassDiscovery
(
$this
->
subdir
,
$namespaces
,
$annotation_namespaces
,
'Drupal\entity_reference\Annotation\EntityReferenceSelection'
);
$annotation_namespaces
=
array
(
'Drupal\entity_reference\Annotation'
=>
$namespaces
[
'Drupal\entity_reference'
]);
$this
->
discovery
=
new
AnnotatedClassDiscovery
(
'Plugin/entity_reference/selection'
,
$namespaces
,
$annotation_namespaces
,
'Drupal\entity_reference\Annotation\EntityReferenceSelection'
);
// We're not using the parent constructor because we use a different factory
// method and don't need the derivative discovery decorator.
...
...
core/modules/field/lib/Drupal/field/Plugin/Type/Formatter/FormatterPluginManager.php
View file @
d88a2be4
...
...
@@ -46,7 +46,7 @@ class FormatterPluginManager extends DefaultPluginManager {
public
function
__construct
(
\
Traversable
$namespaces
,
CacheBackendInterface
$cache_backend
,
ModuleHandlerInterface
$module_handler
,
LanguageManager
$language_manager
)
{
$annotation_namespaces
=
array
(
'Drupal\field\Annotation'
=>
$namespaces
[
'Drupal\field'
]);
parent
::
__construct
(
'field/formatter'
,
$namespaces
,
$annotation_namespaces
,
'Drupal\field\Annotation\FieldFormatter'
);
parent
::
__construct
(
'
Plugin/
field/formatter'
,
$namespaces
,
$annotation_namespaces
,
'Drupal\field\Annotation\FieldFormatter'
);
$this
->
setCacheBackend
(
$cache_backend
,
$language_manager
,
'field_formatter_types'
);
$this
->
alterInfo
(
$module_handler
,
'field_formatter_info'
);
...
...
core/modules/field/lib/Drupal/field/Plugin/Type/Widget/WidgetPluginManager.php
View file @
d88a2be4
...
...
@@ -46,7 +46,7 @@ class WidgetPluginManager extends DefaultPluginManager {
public
function
__construct
(
\
Traversable
$namespaces
,
CacheBackendInterface
$cache_backend
,
ModuleHandlerInterface
$module_handler
,
LanguageManager
$language_manager
)
{
$annotation_namespaces
=
array
(
'Drupal\field\Annotation'
=>
$namespaces
[
'Drupal\field'
]);
parent
::
__construct
(
'field/widget'
,
$namespaces
,
$annotation_namespaces
,
'Drupal\field\Annotation\FieldWidget'
);
parent
::
__construct
(
'
Plugin/
field/widget'
,
$namespaces
,
$annotation_namespaces
,
'Drupal\field\Annotation\FieldWidget'
);
$this
->
setCacheBackend
(
$cache_backend
,
$language_manager
,
'field_widget_types'
);
$this
->
alterInfo
(
$module_handler
,
'field_widget_info'
);
...
...
core/modules/filter/lib/Drupal/filter/FilterPluginManager.php
View file @
d88a2be4
...
...
@@ -31,7 +31,7 @@ class FilterPluginManager extends PluginManagerBase {
*/
public
function
__construct
(
\
Traversable
$namespaces
)
{
$annotation_namespaces
=
array
(
'Drupal\filter\Annotation'
=>
$namespaces
[
'Drupal\filter'
]);
$this
->
discovery
=
new
AnnotatedClassDiscovery
(
'Filter'
,
$namespaces
,
$annotation_namespaces
,
'Drupal\filter\Annotation\Filter'
);
$this
->
discovery
=
new
AnnotatedClassDiscovery
(
'
Plugin/
Filter'
,
$namespaces
,
$annotation_namespaces
,
'Drupal\filter\Annotation\Filter'
);
$this
->
discovery
=
new
AlterDecorator
(
$this
->
discovery
,
'filter_info'
);
$cache_key
=
'filter_plugins:'
.
language
(
Language
::
TYPE_INTERFACE
)
->
id
;
$cache_tags
=
array
(
'filter_formats'
=>
TRUE
);
...
...
Prev
1
2
Next
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