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
302
Merge Requests
302
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
b28e80dd
Commit
b28e80dd
authored
Nov 14, 2012
by
catch
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#1831240
by yched: Register Field API plugin managers in the DIC.
parent
b70ee4b4
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
36 deletions
+33
-36
core/modules/field/field.info.inc
core/modules/field/field.info.inc
+4
-4
core/modules/field/field.module
core/modules/field/field.module
+0
-30
core/modules/field/lib/Drupal/field/FieldBundle.php
core/modules/field/lib/Drupal/field/FieldBundle.php
+27
-0
core/modules/field/lib/Drupal/field/FieldInstance.php
core/modules/field/lib/Drupal/field/FieldInstance.php
+2
-2
No files found.
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