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
b28e80dd
Commit
b28e80dd
authored
Nov 14, 2012
by
catch
Browse files
Issue
#1831240
by yched: Register Field API plugin managers in the DIC.
parent
b70ee4b4
Changes
4
Hide whitespace changes
Inline
Side-by-side
core/modules/field/field.info.inc
View file @
b28e80dd
...
...
@@ -222,10 +222,10 @@ function field_info_field_types($field_type = NULL) {
*/
function
field_info_widget_types
(
$widget_type
=
NULL
)
{
if
(
$widget_type
)
{
return
field_
get
_
plugin
_
manager
(
'
widget'
)
->
getDefinition
(
$widget_type
);
return
drupal_container
()
->
get
(
'
plugin
.
manager
.field.
widget'
)
->
getDefinition
(
$widget_type
);
}
else
{
return
field_
get
_
plugin
_
manager
(
'
widget'
)
->
getDefinitions
();
return
drupal_container
()
->
get
(
'
plugin
.
manager
.field.
widget'
)
->
getDefinitions
();
}
}
...
...
@@ -243,10 +243,10 @@ function field_info_widget_types($widget_type = NULL) {
*/
function
field_info_formatter_types
(
$formatter_type
=
NULL
)
{
if
(
$formatter_type
)
{
return
field_
get
_
plugin
_
manager
(
'
formatter'
)
->
getDefinition
(
$formatter_type
);
return
drupal_container
()
->
get
(
'
plugin
.
manager
.field.
formatter'
)
->
getDefinition
(
$formatter_type
);
}
else
{
return
field_
get
_
plugin
_
manager
(
'
formatter'
)
->
getDefinitions
();
return
drupal_container
()
->
get
(
'
plugin
.
manager
.field.
formatter'
)
->
getDefinitions
();
}
}
...
...
core/modules/field/field.module
View file @
b28e80dd
...
...
@@ -543,36 +543,6 @@ function field_associate_fields($module) {
}
}
/**
* Returns the PluginManager object for a given field plugin type.
*
* @param string $plugin_type
* The plugin type. One of:
* - field_type
* - widget
* - formatter
* - storage
*
* @return Drupal\Component\Plugin\PluginManagerInterface
* The PluginManager object.
*/
function
field_get_plugin_manager
(
$plugin_type
)
{
$plugin_types
=
&
drupal_static
(
__FUNCTION__
,
array
());
$classes
=
array
(
'widget'
=>
'Drupal\field\Plugin\Type\Widget\WidgetPluginManager'
,
'formatter'
=>
'Drupal\field\Plugin\Type\Formatter\FormatterPluginManager'
,
);
if
(
isset
(
$classes
[
$plugin_type
]))
{
if
(
!
isset
(
$plugin_types
[
$plugin_type
]))
{
$plugin_types
[
$plugin_type
]
=
new
$classes
[
$plugin_type
]();
}
return
$plugin_types
[
$plugin_type
];
}
}
/**
* Helper function to get the default value for a field on an entity.
*
...
...
core/modules/field/lib/Drupal/field/FieldBundle.php
0 → 100644
View file @
b28e80dd
<?php
/**
* @file
* Contains Drupal\field\FieldBundle.
*/
namespace
Drupal\field
;
use
Symfony\Component\DependencyInjection\ContainerBuilder
;
use
Symfony\Component\HttpKernel\Bundle\Bundle
;
/**
* Field dependency injection container.
*/
class
FieldBundle
extends
Bundle
{
/**
* Overrides Symfony\Component\HttpKernel\Bundle\Bundle::build().
*/
public
function
build
(
ContainerBuilder
$container
)
{
// Register the plugin managers for our plugin types with the dependency injection container.
$container
->
register
(
'plugin.manager.field.widget'
,
'Drupal\field\Plugin\Type\Widget\WidgetPluginManager'
);
$container
->
register
(
'plugin.manager.field.formatter'
,
'Drupal\field\Plugin\Type\Formatter\FormatterPluginManager'
);
}
}
core/modules/field/lib/Drupal/field/FieldInstance.php
View file @
b28e80dd
...
...
@@ -68,7 +68,7 @@ public function getWidget() {
'settings'
=>
$widget_properties
[
'settings'
],
'weight'
=>
$widget_properties
[
'weight'
],
);
$this
->
widget
=
field_
get
_
plugin
_
manager
(
'
widget'
)
->
getInstance
(
$options
);
$this
->
widget
=
drupal_container
()
->
get
(
'
plugin
.
manager
.field.
widget'
)
->
getInstance
(
$options
);
}
return
$this
->
widget
;
...
...
@@ -142,7 +142,7 @@ public function getFormatter($display_properties) {
'weight'
=>
$display_properties
[
'weight'
],
'view_mode'
=>
$view_mode
,
);
$formatter
=
field_
get
_
plugin
_
manager
(
'
formatter'
)
->
getInstance
(
$options
);
$formatter
=
drupal_container
()
->
get
(
'
plugin
.
manager
.field.
formatter'
)
->
getInstance
(
$options
);
}
else
{
$formatter
=
NULL
;
...
...
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