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
4fc16f8e
Commit
4fc16f8e
authored
Jul 20, 2013
by
alexpott
Browse files
Issue
#2035315
by dawehner: Add a dedicated @FieldWidget annotation.
parent
5d649f8b
Changes
23
Hide whitespace changes
Inline
Side-by-side
core/modules/datetime/lib/Drupal/datetime/Plugin/field/widget/DatetimeDatelistWidget.php
View file @
4fc16f8e
...
...
@@ -6,7 +6,7 @@
namespace
Drupal\datetime\Plugin\field\widget
;
use
Drupal\
Component
\Annotation\
Plugin
;
use
Drupal\
field
\Annotation\
FieldWidget
;
use
Drupal\Core\Annotation\Translation
;
use
Drupal\field\Plugin\Type\Widget\WidgetBase
;
use
Drupal\Component\Plugin\Discovery\DiscoveryInterface
;
...
...
@@ -20,9 +20,8 @@
/**
* Plugin implementation of the 'datetime_datelist' widget.
*
* @
Plugin
(
* @
FieldWidget
(
* id = "datetime_datelist",
* module = "datetime",
* label = @Translation("Select list"),
* field_types = {
* "datetime"
...
...
core/modules/datetime/lib/Drupal/datetime/Plugin/field/widget/DatetimeDefaultWidget.php
View file @
4fc16f8e
...
...
@@ -6,7 +6,7 @@
namespace
Drupal\datetime\Plugin\field\widget
;
use
Drupal\
Component
\Annotation\
Plugin
;
use
Drupal\
field
\Annotation\
FieldWidget
;
use
Drupal\Core\Annotation\Translation
;
use
Drupal\field\Plugin\Type\Widget\WidgetBase
;
use
Drupal\Component\Plugin\Discovery\DiscoveryInterface
;
...
...
@@ -19,9 +19,8 @@
/**
* Plugin implementation of the 'datetime_default' widget.
*
* @
Plugin
(
* @
FieldWidget
(
* id = "datetime_default",
* module = "datetime",
* label = @Translation("Date and time"),
* field_types = {
* "datetime"
...
...
core/modules/email/lib/Drupal/email/Plugin/field/widget/EmailDefaultWidget.php
View file @
4fc16f8e
...
...
@@ -7,16 +7,15 @@
namespace
Drupal\email\Plugin\field\widget
;
use
Drupal\
Component
\Annotation\
Plugin
;
use
Drupal\
field
\Annotation\
FieldWidget
;
use
Drupal\Core\Annotation\Translation
;
use
Drupal\field\Plugin\Type\Widget\WidgetBase
;
/**
* Plugin implementation of the 'email_default' widget.
*
* @
Plugin
(
* @
FieldWidget
(
* id = "email_default",
* module = "email",
* label = @Translation("E-mail"),
* field_types = {
* "email"
...
...
core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/field/widget/AutocompleteTagsWidget.php
View file @
4fc16f8e
...
...
@@ -7,16 +7,15 @@
namespace
Drupal\entity_reference\Plugin\field\widget
;
use
Drupal\
Component
\Annotation\
Plugin
;
use
Drupal\
field
\Annotation\
FieldWidget
;
use
Drupal\Core\Annotation\Translation
;
use
Drupal\entity_reference
\
Plugin\field\widget\AutocompleteWidgetBase
;
/**
* Plugin implementation of the 'entity_reference autocomplete-tags' widget.
*
* @
Plugin
(
* @
FieldWidget
(
* id = "entity_reference_autocomplete_tags",
* module = "entity_reference",
* label = @Translation("Autocomplete (Tags style)"),
* description = @Translation("An autocomplete text field."),
* field_types = {
...
...
core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/field/widget/AutocompleteWidget.php
View file @
4fc16f8e
...
...
@@ -7,7 +7,7 @@
namespace
Drupal\entity_reference\Plugin\field\widget
;
use
Drupal\
Component
\Annotation\
Plugin
;
use
Drupal\
field
\Annotation\
FieldWidget
;
use
Drupal\Core\Annotation\Translation
;
use
Drupal\entity_reference
\
Plugin\field\widget\AutocompleteWidgetBase
;
...
...
@@ -19,9 +19,8 @@
* the two widgets, and the Field API doesn't update default settings when
* the widget changes.
*
* @
Plugin
(
* @
FieldWidget
(
* id = "entity_reference_autocomplete",
* module = "entity_reference",
* label = @Translation("Autocomplete"),
* description = @Translation("An autocomplete text field."),
* field_types = {
...
...
core/modules/field/lib/Drupal/field/Annotation/FieldWidget.php
0 → 100644
View file @
4fc16f8e
<?php
/**
* @file
* Contains \Drupal\field\Annotation\FieldWidget.
*/
namespace
Drupal\field\Annotation
;
use
Drupal\Component\Annotation\Plugin
;
/**
* Defines a FieldWidget annotation object.
*
* Widgets handle how fields are displayed in edit forms.
*
* Additional annotation keys for formatters can be defined in
* hook_field_widget_info_alter().
*
* @Annotation
*
* @see \Drupal\field\Plugin\Type\Widget\WidgetPluginManager
* @see \Drupal\field\Plugin\Type\Widget\WidgetInterface
*/
class
FieldWidget
extends
Plugin
{
/**
* The plugin ID.
*
* @var string
*/
public
$id
;
/**
* The human-readable name of the widget type.
*
* @ingroup plugin_translatable
*
* @var \Drupal\Core\Annotation\Translation
*/
public
$label
;
/**
* A short description of the widget type.
*
* @ingroup plugin_translatable
*
* @var \Drupal\Core\Annotation\Translation
*/
public
$description
;
/**
* The name of the widget class.
*
* This is not provided manually, it will be added by the discovery mechanism.
*
* @var string
*/
public
$class
;
/**
* An array of field types the widget supports.
*
* @var array
*/
public
$field_types
=
array
();
/**
* An array whose keys are the names of the settings available to the widget
* type, and whose values are the default values for those settings.
*
* @var array
*/
public
$settings
=
array
();
/**
* Does the field widget handles multiple values at once.
*
* @var bool
*/
public
$multiple_values
=
FALSE
;
/**
* An integer to determine the weight of this widget relative to other widgets
* in the Field UI when selecting a widget for a given field instance.
*
* @var int optional
*/
public
$weight
=
NULL
;
}
core/modules/field/lib/Drupal/field/Plugin/Type/Widget/WidgetPluginManager.php
View file @
4fc16f8e
...
...
@@ -7,6 +7,7 @@
namespace
Drupal\field\Plugin\Type\Widget
;
use
Drupal\Component\Plugin\Factory\DefaultFactory
;
use
Drupal\Component\Plugin\PluginManagerBase
;
use
Drupal\Component\Plugin\Discovery\ProcessDecorator
;
use
Drupal\Core\Cache\CacheBackendInterface
;
...
...
@@ -29,16 +30,6 @@ class WidgetPluginManager extends DefaultPluginManager {
*/
protected
$widgetOptions
;
/**
* Overrides Drupal\Component\Plugin\PluginManagerBase:$defaults.
*/
protected
$defaults
=
array
(
'field_types'
=>
array
(),
'settings'
=>
array
(),
'multiple_values'
=>
FALSE
,
'default_value'
=>
TRUE
,
);
/**
* Constructs a WidgetPluginManager object.
*
...
...
@@ -53,7 +44,9 @@ class WidgetPluginManager extends DefaultPluginManager {
* The language manager.
*/
public
function
__construct
(
\
Traversable
$namespaces
,
CacheBackendInterface
$cache_backend
,
ModuleHandlerInterface
$module_handler
,
LanguageManager
$language_manager
)
{
parent
::
__construct
(
'field/widget'
,
$namespaces
);
$annotation_namespaces
=
array
(
'Drupal\field\Annotation'
=>
$namespaces
[
'Drupal\field'
]);
parent
::
__construct
(
'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'
);
...
...
@@ -110,6 +103,22 @@ public function getInstance(array $options) {
return
$this
->
createInstance
(
$plugin_id
,
$configuration
);
}
/**
* {@inheritdoc}
*/
public
function
createInstance
(
$plugin_id
,
array
$configuration
=
array
())
{
$plugin_definition
=
$this
->
discovery
->
getDefinition
(
$plugin_id
);
$plugin_class
=
DefaultFactory
::
getPluginClass
(
$plugin_id
,
$plugin_definition
);
// If the plugin provides a factory method, pass the container to it.
if
(
is_subclass_of
(
$plugin_class
,
'Drupal\Core\Plugin\ContainerFactoryPluginInterface'
))
{
return
$plugin_class
::
create
(
\
Drupal
::
getContainer
(),
$configuration
,
$plugin_id
,
$plugin_definition
);
}
return
new
$plugin_class
(
$plugin_id
,
$plugin_definition
,
$configuration
[
'field_definition'
],
$configuration
[
'settings'
]);
}
/**
* Merges default values for widget configuration.
*
...
...
core/modules/field/lib/Drupal/field/Plugin/field/widget/HiddenWidget.php
View file @
4fc16f8e
...
...
@@ -7,16 +7,15 @@
namespace
Drupal\field\Plugin\field\widget
;
use
Drupal\
Component
\Annotation\
Plugin
;
use
Drupal\
field
\Annotation\
FieldWidget
;
use
Drupal\Core\Annotation\Translation
;
use
Drupal\field\Plugin\Type\Widget\WidgetBase
;
/**
* Plugin implementation of the 'Hidden' widget.
*
* @
Plugin
(
* @
FieldWidget
(
* id = "hidden",
* module = "field",
* label = @Translation("- Hidden -"),
* multiple_values = TRUE,
* weight = 50
...
...
core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/field/widget/TestFieldWidget.php
View file @
4fc16f8e
...
...
@@ -7,7 +7,7 @@
namespace
Drupal\field_test\Plugin\field\widget
;
use
Drupal\
Component
\Annotation\
Plugin
;
use
Drupal\
field
\Annotation\
FieldWidget
;
use
Drupal\Core\Annotation\Translation
;
use
Drupal\field\Plugin\Type\Widget\WidgetBase
;
use
Symfony\Component\Validator\ConstraintViolationInterface
;
...
...
@@ -15,9 +15,8 @@
/**
* Plugin implementation of the 'test_field_widget' widget.
*
* @
Plugin
(
* @
FieldWidget
(
* id = "test_field_widget",
* module = "field_test",
* label = @Translation("Test widget"),
* field_types = {
* "test_field",
...
...
core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/field/widget/TestFieldWidgetMultiple.php
View file @
4fc16f8e
...
...
@@ -7,7 +7,8 @@
namespace
Drupal\field_test\Plugin\field\widget
;
use
Drupal\Component\Annotation\Plugin
;
use
Drupal\field\Annotation\FieldWidget
;
use
Drupal\Core\Annotation\Translation
;
use
Drupal\field\Plugin\Type\Widget\WidgetBase
;
use
Symfony\Component\Validator\ConstraintViolationInterface
;
...
...
@@ -19,9 +20,8 @@
*
* @see field_test_field_widget_info_alter()
*
* @
Plugin
(
* @
FieldWidget
(
* id = "test_field_widget_multiple",
* module = "field_test",
* label = @Translation("Test widget - multiple"),
* settings = {
* "test_widget_setting_multiple" = "dummy test string"
...
...
core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/field/widget/TestFieldWidgetNoDefault.php
View file @
4fc16f8e
...
...
@@ -7,16 +7,15 @@
namespace
Drupal\field_test\Plugin\field\widget
;
use
Drupal\
Component
\Annotation\
Plugin
;
use
Drupal\
field
\Annotation\
FieldWidget
;
use
Drupal\Core\Annotation\Translation
;
use
Drupal\field\Plugin\Type\Widget\WidgetBase
;
/**
* Plugin implementation of the 'test_field_widget_no_default' widget.
*
* @
Plugin
(
* @
FieldWidget
(
* id = "test_field_widget_no_default",
* module = "field_test",
* label = @Translation("Test widget - no default"),
* field_types = {
* "test_field"
...
...
core/modules/file/lib/Drupal/file/Plugin/field/widget/FileWidget.php
View file @
4fc16f8e
...
...
@@ -7,7 +7,7 @@
namespace
Drupal\file\Plugin\field\widget
;
use
Drupal\
Component
\Annotation\
Plugin
;
use
Drupal\
field
\Annotation\
FieldWidget
;
use
Drupal\Core\Annotation\Translation
;
use
Drupal\field\Plugin\Type\Widget\WidgetBase
;
use
Drupal\Core\Entity\EntityInterface
;
...
...
@@ -15,9 +15,8 @@
/**
* Plugin implementation of the 'file_generic' widget.
*
* @
Plugin
(
* @
FieldWidget
(
* id = "file_generic",
* module = "file",
* label = @Translation("File"),
* field_types = {
* "file"
...
...
core/modules/image/lib/Drupal/image/Plugin/field/widget/ImageWidget.php
View file @
4fc16f8e
...
...
@@ -7,7 +7,7 @@
namespace
Drupal\image\Plugin\field\widget
;
use
Drupal\
Component
\Annotation\
Plugin
;
use
Drupal\
field
\Annotation\
FieldWidget
;
use
Drupal\Core\Annotation\Translation
;
use
Drupal\field\Plugin\Type\Widget\WidgetBase
;
use
Drupal\file\Plugin\field\widget\FileWidget
;
...
...
@@ -16,9 +16,8 @@
/**
* Plugin implementation of the 'image_image' widget.
*
* @
Plugin
(
* @
FieldWidget
(
* id = "image_image",
* module = "image",
* label = @Translation("Image"),
* field_types = {
* "image"
...
...
core/modules/link/lib/Drupal/link/Plugin/field/widget/LinkWidget.php
View file @
4fc16f8e
...
...
@@ -7,16 +7,15 @@
namespace
Drupal\link\Plugin\field\widget
;
use
Drupal\
Component
\Annotation\
Plugin
;
use
Drupal\
field
\Annotation\
FieldWidget
;
use
Drupal\Core\Annotation\Translation
;
use
Drupal\field\Plugin\Type\Widget\WidgetBase
;
/**
* Plugin implementation of the 'link' widget.
*
* @
Plugin
(
* @
FieldWidget
(
* id = "link_default",
* module = "link",
* label = @Translation("Link"),
* field_types = {
* "link"
...
...
core/modules/number/lib/Drupal/number/Plugin/field/widget/NumberWidget.php
View file @
4fc16f8e
...
...
@@ -7,7 +7,7 @@
namespace
Drupal\number\Plugin\field\widget
;
use
Drupal\
Component
\Annotation\
Plugin
;
use
Drupal\
field
\Annotation\
FieldWidget
;
use
Drupal\Core\Annotation\Translation
;
use
Drupal\field\Plugin\Type\Widget\WidgetBase
;
use
Symfony\Component\Validator\ConstraintViolationInterface
;
...
...
@@ -15,9 +15,8 @@
/**
* Plugin implementation of the 'number' widget.
*
* @
Plugin
(
* @
FieldWidget
(
* id = "number",
* module = "number",
* label = @Translation("Text field"),
* field_types = {
* "number_integer",
...
...
core/modules/options/lib/Drupal/options/Plugin/field/widget/ButtonsWidget.php
View file @
4fc16f8e
...
...
@@ -7,15 +7,14 @@
namespace
Drupal\options\Plugin\field\widget
;
use
Drupal\
Component
\Annotation\
Plugin
;
use
Drupal\
field
\Annotation\
FieldWidget
;
use
Drupal\Core\Annotation\Translation
;
/**
* Plugin implementation of the 'options_buttons' widget.
*
* @
Plugin
(
* @
FieldWidget
(
* id = "options_buttons",
* module = "options",
* label = @Translation("Check boxes/radio buttons"),
* field_types = {
* "list_integer",
...
...
core/modules/options/lib/Drupal/options/Plugin/field/widget/OnOffWidget.php
View file @
4fc16f8e
...
...
@@ -7,15 +7,14 @@
namespace
Drupal\options\Plugin\field\widget
;
use
Drupal\
Component
\Annotation\
Plugin
;
use
Drupal\
field
\Annotation\
FieldWidget
;
use
Drupal\Core\Annotation\Translation
;
/**
* Plugin implementation of the 'options_onoff' widget.
*
* @
Plugin
(
* @
FieldWidget
(
* id = "options_onoff",
* module = "options",
* label = @Translation("Single on/off checkbox"),
* field_types = {
* "list_boolean"
...
...
core/modules/options/lib/Drupal/options/Plugin/field/widget/SelectWidget.php
View file @
4fc16f8e
...
...
@@ -7,15 +7,14 @@
namespace
Drupal\options\Plugin\field\widget
;
use
Drupal\
Component
\Annotation\
Plugin
;
use
Drupal\
field
\Annotation\
FieldWidget
;
use
Drupal\Core\Annotation\Translation
;
/**
* Plugin implementation of the 'options_select' widget.
*
* @
Plugin
(
* @
FieldWidget
(
* id = "options_select",
* module = "options",
* label = @Translation("Select list"),
* field_types = {
* "list_integer",
...
...
core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/field/widget/TaxonomyAutocompleteWidget.php
View file @
4fc16f8e
...
...
@@ -7,16 +7,15 @@
namespace
Drupal\taxonomy\Plugin\field\widget
;
use
Drupal\
Component
\Annotation\
Plugin
;
use
Drupal\
field
\Annotation\
FieldWidget
;
use
Drupal\Core\Annotation\Translation
;
use
Drupal\field\Plugin\Type\Widget\WidgetBase
;
/**
* Plugin implementation of the 'taxonomy_autocomplete' widget.
*
* @
Plugin
(
* @
FieldWidget
(
* id = "taxonomy_autocomplete",
* module = "taxonomy",
* label = @Translation("Autocomplete term widget (tagging)"),
* field_types = {
* "taxonomy_term_reference"
...
...
core/modules/telephone/lib/Drupal/telephone/Plugin/field/widget/TelephoneDefaultWidget.php
View file @
4fc16f8e
...
...
@@ -7,16 +7,15 @@
namespace
Drupal\telephone\Plugin\field\widget
;
use
Drupal\
Component
\Annotation\
Plugin
;
use
Drupal\
field
\Annotation\
FieldWidget
;
use
Drupal\Core\Annotation\Translation
;
use
Drupal\field\Plugin\Type\Widget\WidgetBase
;
/**
* Plugin implementation of the 'telephone_default' widget.
*
* @
Plugin
(
* @
FieldWidget
(
* id = "telephone_default",
* module = "telephone",
* label = @Translation("Telephone number"),
* field_types = {
* "telephone"
...
...
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