Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
D
drupal
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Insights
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Drupal.org issue queue
Drupal.org issue queue
Security & Compliance
Security & Compliance
Dependency List
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
project
drupal
Commits
a820153f
Commit
a820153f
authored
Apr 13, 2013
by
alexpott
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#1735118
by swentel, yched, xjm, larowlan, alexpott, tim.plunkett: Convert Field API to CMI.
parent
5a6647be
Changes
78
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
78 changed files
with
2799 additions
and
1376 deletions
+2799
-1376
core/modules/datetime/lib/Drupal/datetime/Plugin/field/widget/DatetimeDatelistWidget.php
...l/datetime/Plugin/field/widget/DatetimeDatelistWidget.php
+1
-1
core/modules/datetime/lib/Drupal/datetime/Plugin/field/widget/DatetimeDefaultWidget.php
...al/datetime/Plugin/field/widget/DatetimeDefaultWidget.php
+1
-1
core/modules/datetime/lib/Drupal/datetime/Tests/DateTimeFieldTest.php
.../datetime/lib/Drupal/datetime/Tests/DateTimeFieldTest.php
+5
-6
core/modules/edit/lib/Drupal/edit/EditorBase.php
core/modules/edit/lib/Drupal/edit/EditorBase.php
+1
-1
core/modules/edit/lib/Drupal/edit/EditorInterface.php
core/modules/edit/lib/Drupal/edit/EditorInterface.php
+1
-1
core/modules/edit/lib/Drupal/edit/EditorSelector.php
core/modules/edit/lib/Drupal/edit/EditorSelector.php
+1
-1
core/modules/edit/lib/Drupal/edit/EditorSelectorInterface.php
.../modules/edit/lib/Drupal/edit/EditorSelectorInterface.php
+1
-1
core/modules/edit/lib/Drupal/edit/MetadataGenerator.php
core/modules/edit/lib/Drupal/edit/MetadataGenerator.php
+1
-1
core/modules/edit/lib/Drupal/edit/MetadataGeneratorInterface.php
...dules/edit/lib/Drupal/edit/MetadataGeneratorInterface.php
+1
-1
core/modules/edit/lib/Drupal/edit/Plugin/edit/editor/DirectEditor.php
.../edit/lib/Drupal/edit/Plugin/edit/editor/DirectEditor.php
+1
-1
core/modules/edit/lib/Drupal/edit/Plugin/edit/editor/FormEditor.php
...es/edit/lib/Drupal/edit/Plugin/edit/editor/FormEditor.php
+1
-1
core/modules/edit/lib/Drupal/edit/Tests/EditTestBase.php
core/modules/edit/lib/Drupal/edit/Tests/EditTestBase.php
+2
-3
core/modules/edit/tests/modules/lib/Drupal/edit_test/Plugin/edit/editor/WysiwygEditor.php
...lib/Drupal/edit_test/Plugin/edit/editor/WysiwygEditor.php
+1
-1
core/modules/editor/lib/Drupal/editor/Plugin/edit/editor/Editor.php
...es/editor/lib/Drupal/editor/Plugin/edit/editor/Editor.php
+1
-1
core/modules/entity/lib/Drupal/entity/Tests/EntityDisplayTest.php
...ules/entity/lib/Drupal/entity/Tests/EntityDisplayTest.php
+0
-6
core/modules/field/field.api.php
core/modules/field/field.api.php
+14
-11
core/modules/field/field.attach.inc
core/modules/field/field.attach.inc
+14
-9
core/modules/field/field.crud.inc
core/modules/field/field.crud.inc
+216
-539
core/modules/field/field.info.inc
core/modules/field/field.info.inc
+1
-1
core/modules/field/field.info.yml
core/modules/field/field.info.yml
+0
-2
core/modules/field/field.install
core/modules/field/field.install
+161
-164
core/modules/field/field.module
core/modules/field/field.module
+71
-176
core/modules/field/field.views.inc
core/modules/field/field.views.inc
+3
-3
core/modules/field/lib/Drupal/field/FieldInfo.php
core/modules/field/lib/Drupal/field/FieldInfo.php
+58
-51
core/modules/field/lib/Drupal/field/FieldInstance.php
core/modules/field/lib/Drupal/field/FieldInstance.php
+0
-135
core/modules/field/lib/Drupal/field/FieldInstanceStorageController.php
...field/lib/Drupal/field/FieldInstanceStorageController.php
+36
-0
core/modules/field/lib/Drupal/field/Plugin/Core/Entity/Field.php
...dules/field/lib/Drupal/field/Plugin/Core/Entity/Field.php
+600
-0
core/modules/field/lib/Drupal/field/Plugin/Core/Entity/FieldInstance.php
...eld/lib/Drupal/field/Plugin/Core/Entity/FieldInstance.php
+528
-0
core/modules/field/lib/Drupal/field/Plugin/Type/Formatter/FormatterBase.php
.../lib/Drupal/field/Plugin/Type/Formatter/FormatterBase.php
+1
-1
core/modules/field/lib/Drupal/field/Plugin/Type/Formatter/FormatterInterface.php
...Drupal/field/Plugin/Type/Formatter/FormatterInterface.php
+1
-1
core/modules/field/lib/Drupal/field/Plugin/Type/Formatter/FormatterPluginManager.php
...al/field/Plugin/Type/Formatter/FormatterPluginManager.php
+1
-1
core/modules/field/lib/Drupal/field/Plugin/Type/Widget/WidgetBase.php
.../field/lib/Drupal/field/Plugin/Type/Widget/WidgetBase.php
+2
-2
core/modules/field/lib/Drupal/field/Plugin/Type/Widget/WidgetInterface.php
...d/lib/Drupal/field/Plugin/Type/Widget/WidgetInterface.php
+1
-1
core/modules/field/lib/Drupal/field/Plugin/views/field/Field.php
...dules/field/lib/Drupal/field/Plugin/views/field/Field.php
+2
-3
core/modules/field/lib/Drupal/field/Tests/BulkDeleteTest.php
core/modules/field/lib/Drupal/field/Tests/BulkDeleteTest.php
+13
-11
core/modules/field/lib/Drupal/field/Tests/CrudTest.php
core/modules/field/lib/Drupal/field/Tests/CrudTest.php
+33
-48
core/modules/field/lib/Drupal/field/Tests/FieldAttachStorageTest.php
...s/field/lib/Drupal/field/Tests/FieldAttachStorageTest.php
+4
-4
core/modules/field/lib/Drupal/field/Tests/FieldImportChangeTest.php
...es/field/lib/Drupal/field/Tests/FieldImportChangeTest.php
+64
-0
core/modules/field/lib/Drupal/field/Tests/FieldImportCreateTest.php
...es/field/lib/Drupal/field/Tests/FieldImportCreateTest.php
+81
-0
core/modules/field/lib/Drupal/field/Tests/FieldImportDeleteTest.php
...es/field/lib/Drupal/field/Tests/FieldImportDeleteTest.php
+93
-0
core/modules/field/lib/Drupal/field/Tests/FieldInfoTest.php
core/modules/field/lib/Drupal/field/Tests/FieldInfoTest.php
+14
-25
core/modules/field/lib/Drupal/field/Tests/FieldInstanceCrudTest.php
...es/field/lib/Drupal/field/Tests/FieldInstanceCrudTest.php
+19
-17
core/modules/field/lib/Drupal/field/Tests/FieldUnitTestBase.php
...odules/field/lib/Drupal/field/Tests/FieldUnitTestBase.php
+2
-3
core/modules/field/lib/Drupal/field/Tests/TranslationTest.php
.../modules/field/lib/Drupal/field/Tests/TranslationTest.php
+14
-13
core/modules/field/tests/modules/field_test/field_test.storage.inc
...les/field/tests/modules/field_test/field_test.storage.inc
+10
-10
core/modules/field/tests/modules/field_test_config/config/field.field.field_test_import.yml
...ield_test_config/config/field.field.field_test_import.yml
+20
-0
core/modules/field/tests/modules/field_test_config/config/field.instance.test_entity.test_bundle.field_test_import.yml
...ld.instance.test_entity.test_bundle.field_test_import.yml
+20
-0
core/modules/field/tests/modules/field_test_config/field_test_config.info.yml
...ests/modules/field_test_config/field_test_config.info.yml
+6
-0
core/modules/field/tests/modules/field_test_config/field_test_config.module
.../tests/modules/field_test_config/field_test_config.module
+6
-0
core/modules/field/tests/modules/field_test_config/staging/field.field.field_test_import_staging.yml
..._config/staging/field.field.field_test_import_staging.yml
+20
-0
core/modules/field/tests/modules/field_test_config/staging/field.instance.test_entity.test_bundle.field_test_import_staging.yml
...nce.test_entity.test_bundle.field_test_import_staging.yml
+20
-0
core/modules/field_sql_storage/field_sql_storage.install
core/modules/field_sql_storage/field_sql_storage.install
+63
-26
core/modules/field_sql_storage/field_sql_storage.module
core/modules/field_sql_storage/field_sql_storage.module
+37
-11
core/modules/field_sql_storage/lib/Drupal/field_sql_storage/Tests/FieldSqlStorageTest.php
...ib/Drupal/field_sql_storage/Tests/FieldSqlStorageTest.php
+2
-2
core/modules/field_ui/field_ui.admin.inc
core/modules/field_ui/field_ui.admin.inc
+8
-12
core/modules/file/file.install
core/modules/file/file.install
+16
-2
core/modules/file/lib/Drupal/file/Tests/FileFieldWidgetTest.php
...odules/file/lib/Drupal/file/Tests/FileFieldWidgetTest.php
+11
-2
core/modules/file/lib/Drupal/file/Tests/FileItemTest.php
core/modules/file/lib/Drupal/file/Tests/FileItemTest.php
+0
-3
core/modules/forum/forum.install
core/modules/forum/forum.install
+4
-7
core/modules/hal/lib/Drupal/hal/Tests/NormalizerTestBase.php
core/modules/hal/lib/Drupal/hal/Tests/NormalizerTestBase.php
+0
-1
core/modules/image/image.module
core/modules/image/image.module
+4
-4
core/modules/node/lib/Drupal/node/Tests/Condition/NodeConditionTest.php
...ode/lib/Drupal/node/Tests/Condition/NodeConditionTest.php
+0
-2
core/modules/number/lib/Drupal/number/Tests/NumberFieldTest.php
...odules/number/lib/Drupal/number/Tests/NumberFieldTest.php
+0
-5
core/modules/options/lib/Drupal/options/Tests/OptionsFieldTest.php
...les/options/lib/Drupal/options/Tests/OptionsFieldTest.php
+4
-5
core/modules/options/options.module
core/modules/options/options.module
+7
-4
core/modules/serialization/lib/Drupal/serialization/Tests/EntitySerializationTest.php
...ib/Drupal/serialization/Tests/EntitySerializationTest.php
+0
-1
core/modules/simpletest/lib/Drupal/simpletest/Tests/DrupalUnitTestBaseTest.php
...st/lib/Drupal/simpletest/Tests/DrupalUnitTestBaseTest.php
+0
-3
core/modules/system/lib/Drupal/system/Tests/Database/SelectComplexTest.php
...em/lib/Drupal/system/Tests/Database/SelectComplexTest.php
+0
-5
core/modules/system/lib/Drupal/system/Tests/Entity/EntityUnitTestBase.php
...tem/lib/Drupal/system/Tests/Entity/EntityUnitTestBase.php
+0
-1
core/modules/system/lib/Drupal/system/Tests/Entity/FieldAccessTest.php
...system/lib/Drupal/system/Tests/Entity/FieldAccessTest.php
+0
-2
core/modules/system/lib/Drupal/system/Tests/Upgrade/FieldUpgradePathTest.php
.../lib/Drupal/system/Tests/Upgrade/FieldUpgradePathTest.php
+128
-0
core/modules/system/lib/Drupal/system/Tests/Upgrade/UserPictureUpgradePathTest.php
...rupal/system/Tests/Upgrade/UserPictureUpgradePathTest.php
+1
-1
core/modules/system/tests/upgrade/drupal-7.field.database.php
.../modules/system/tests/upgrade/drupal-7.field.database.php
+335
-0
core/modules/taxonomy/lib/Drupal/taxonomy/Tests/VocabularyUnitTest.php
...taxonomy/lib/Drupal/taxonomy/Tests/VocabularyUnitTest.php
+6
-7
core/modules/text/lib/Drupal/text/Tests/Formatter/TextPlainUnitTest.php
...ext/lib/Drupal/text/Tests/Formatter/TextPlainUnitTest.php
+0
-3
core/modules/translation_entity/translation_entity.admin.inc
core/modules/translation_entity/translation_entity.admin.inc
+5
-4
core/modules/user/user.install
core/modules/user/user.install
+0
-4
core/modules/views/lib/Drupal/views/Tests/Plugin/RelationshipJoinTestBase.php
...ib/Drupal/views/Tests/Plugin/RelationshipJoinTestBase.php
+0
-1
No files found.
core/modules/datetime/lib/Drupal/datetime/Plugin/field/widget/DatetimeDatelistWidget.php
View file @
a820153f
...
...
@@ -12,7 +12,7 @@
use
Drupal\Component\Plugin\Discovery\DiscoveryInterface
;
use
Drupal\Core\Entity\EntityInterface
;
use
Drupal\field\Plugin\PluginSettingsBase
;
use
Drupal\field\FieldInstance
;
use
Drupal\field\
Plugin\Core\Entity\
FieldInstance
;
use
Drupal\Core\Datetime\DrupalDateTime
;
use
Drupal\datetime\DateHelper
;
...
...
core/modules/datetime/lib/Drupal/datetime/Plugin/field/widget/DatetimeDefaultWidget.php
View file @
a820153f
...
...
@@ -12,7 +12,7 @@
use
Drupal\Component\Plugin\Discovery\DiscoveryInterface
;
use
Drupal\Core\Entity\EntityInterface
;
use
Drupal\field\Plugin\PluginSettingsBase
;
use
Drupal\field\FieldInstance
;
use
Drupal\field\
Plugin\Core\Entity\
FieldInstance
;
use
Drupal\Core\Datetime\DrupalDateTime
;
/**
...
...
core/modules/datetime/lib/Drupal/datetime/Tests/DateTimeFieldTest.php
View file @
a820153f
...
...
@@ -48,13 +48,12 @@ function setUp() {
$this
->
drupalLogin
(
$web_user
);
// Create a field with settings to validate.
$this
->
field
=
array
(
$this
->
field
=
field_create_field
(
array
(
'field_name'
=>
drupal_strtolower
(
$this
->
randomName
()),
'type'
=>
'datetime'
,
'settings'
=>
array
(
'datetime_type'
=>
'date'
),
);
field_create_field
(
$this
->
field
);
$this
->
instance
=
array
(
));
$this
->
instance
=
field_create_instance
(
array
(
'field_name'
=>
$this
->
field
[
'field_name'
],
'entity_type'
=>
'test_entity'
,
'bundle'
=>
'test_bundle'
,
...
...
@@ -64,8 +63,7 @@ function setUp() {
'settings'
=>
array
(
'default_value'
=>
'blank'
,
),
);
field_create_instance
(
$this
->
instance
);
));
$this
->
display_options
=
array
(
'type'
=>
'datetime_default'
,
...
...
@@ -304,6 +302,7 @@ function testDefaultValue() {
// Set the default value to 'blank'.
$this
->
instance
[
'settings'
][
'default_value'
]
=
'blank'
;
$this
->
instance
[
'default_value_function'
]
=
'datetime_default_value'
;
field_update_instance
(
$this
->
instance
);
// Display creation form.
...
...
core/modules/edit/lib/Drupal/edit/EditorBase.php
View file @
a820153f
...
...
@@ -9,7 +9,7 @@
use
Drupal\Component\Plugin\PluginBase
;
use
Drupal\edit\EditorInterface
;
use
Drupal\field\FieldInstance
;
use
Drupal\field\
Plugin\Core\Entity\
FieldInstance
;
/**
* Defines a base editor (Create.js PropertyEditor widget) implementation.
...
...
core/modules/edit/lib/Drupal/edit/EditorInterface.php
View file @
a820153f
...
...
@@ -8,7 +8,7 @@
namespace
Drupal\edit
;
use
Drupal\Component\Plugin\PluginInspectionInterface
;
use
Drupal\field\FieldInstance
;
use
Drupal\field\
Plugin\Core\Entity\
FieldInstance
;
/**
* Defines an interface for in-place editors (Create.js PropertyEditor widgets).
...
...
core/modules/edit/lib/Drupal/edit/EditorSelector.php
View file @
a820153f
...
...
@@ -9,7 +9,7 @@
use
Drupal\Component\Plugin\PluginManagerInterface
;
use
Drupal\Component\Utility\NestedArray
;
use
Drupal\field\FieldInstance
;
use
Drupal\field\
Plugin\Core\Entity\
FieldInstance
;
/**
* Selects an in-place editor (an Editor plugin) for a field.
...
...
core/modules/edit/lib/Drupal/edit/EditorSelectorInterface.php
View file @
a820153f
...
...
@@ -7,7 +7,7 @@
namespace
Drupal\edit
;
use
Drupal\field\FieldInstance
;
use
Drupal\field\
Plugin\Core\Entity\
FieldInstance
;
/**
* Interface for selecting an in-place editor (an Editor plugin) for a field.
...
...
core/modules/edit/lib/Drupal/edit/MetadataGenerator.php
View file @
a820153f
...
...
@@ -9,7 +9,7 @@
use
Drupal\Core\Entity\EntityInterface
;
use
Drupal\Component\Plugin\PluginManagerInterface
;
use
Drupal\field\FieldInstance
;
use
Drupal\field\
Plugin\Core\Entity\
FieldInstance
;
use
Drupal\edit\Access\EditEntityFieldAccessCheckInterface
;
...
...
core/modules/edit/lib/Drupal/edit/MetadataGeneratorInterface.php
View file @
a820153f
...
...
@@ -8,7 +8,7 @@
namespace
Drupal\edit
;
use
Drupal\Core\Entity\EntityInterface
;
use
Drupal\field\FieldInstance
;
use
Drupal\field\
Plugin\Core\Entity\
FieldInstance
;
/**
* Interface for generating in-place editing metadata for an entity field.
...
...
core/modules/edit/lib/Drupal/edit/Plugin/edit/editor/DirectEditor.php
View file @
a820153f
...
...
@@ -9,7 +9,7 @@
use
Drupal\edit\EditorBase
;
use
Drupal\Component\Annotation\Plugin
;
use
Drupal\field\FieldInstance
;
use
Drupal\field\
Plugin\Core\Entity\
FieldInstance
;
/**
* Defines the "direct" Create.js PropertyEditor widget.
...
...
core/modules/edit/lib/Drupal/edit/Plugin/edit/editor/FormEditor.php
View file @
a820153f
...
...
@@ -9,7 +9,7 @@
use
Drupal\edit\EditorBase
;
use
Drupal\Component\Annotation\Plugin
;
use
Drupal\field\FieldInstance
;
use
Drupal\field\
Plugin\Core\Entity\
FieldInstance
;
/**
* Defines the "form" Create.js PropertyEditor widget.
...
...
core/modules/edit/lib/Drupal/edit/Tests/EditTestBase.php
View file @
a820153f
...
...
@@ -28,7 +28,6 @@ function setUp() {
parent
::
setUp
();
$this
->
installSchema
(
'system'
,
'variable'
);
$this
->
installSchema
(
'field'
,
array
(
'field_config'
,
'field_config_instance'
));
$this
->
installSchema
(
'entity_test'
,
array
(
'entity_test'
,
'entity_test_rev'
));
// Set default storage backend.
...
...
@@ -58,12 +57,12 @@ function setUp() {
*/
function
createFieldWithInstance
(
$field_name
,
$type
,
$cardinality
,
$label
,
$instance_settings
,
$widget_type
,
$widget_settings
,
$formatter_type
,
$formatter_settings
)
{
$field
=
$field_name
.
'_field'
;
$this
->
$
field
=
array
(
$this
->
field
=
array
(
'field_name'
=>
$field_name
,
'type'
=>
$type
,
'cardinality'
=>
$cardinality
,
);
$this
->
$field
_name
=
field_create_field
(
$this
->
$
field
);
$this
->
$field
=
field_create_field
(
$this
->
field
);
$instance
=
$field_name
.
'_instance'
;
$this
->
$instance
=
array
(
...
...
core/modules/edit/tests/modules/lib/Drupal/edit_test/Plugin/edit/editor/WysiwygEditor.php
View file @
a820153f
...
...
@@ -9,7 +9,7 @@
use
Drupal\edit\EditorBase
;
use
Drupal\Component\Annotation\Plugin
;
use
Drupal\field\FieldInstance
;
use
Drupal\field\
Plugin\Core\Entity\
FieldInstance
;
/**
* Defines the "wysiwyg" Create.js PropertyEditor widget.
...
...
core/modules/editor/lib/Drupal/editor/Plugin/edit/editor/Editor.php
View file @
a820153f
...
...
@@ -11,7 +11,7 @@
use
Drupal\Component\Annotation\Plugin
;
use
Drupal\Core\Annotation\Translation
;
use
Drupal\edit\EditorInterface
;
use
Drupal\field\FieldInstance
;
use
Drupal\field\
Plugin\Core\Entity\
FieldInstance
;
/**
...
...
core/modules/entity/lib/Drupal/entity/Tests/EntityDisplayTest.php
View file @
a820153f
...
...
@@ -24,12 +24,6 @@ public static function getInfo() {
);
}
protected
function
setUp
()
{
parent
::
setUp
();
$this
->
installSchema
(
'field'
,
array
(
'field_config'
,
'field_config_instance'
));
}
/**
* Tests basic CRUD operations on EntityDisplay objects.
*/
...
...
core/modules/field/field.api.php
View file @
a820153f
...
...
@@ -234,6 +234,9 @@ function hook_field_info_alter(&$info) {
* indexes specified by the field-type module. Some storage engines might
* not support indexes.
* - foreign keys: (optional) An array of Schema API foreign key definitions.
* Note, however, that the field data is not necessarily stored in SQL.
* Also, the possible usage is limited, as you cannot specify another field
* as related, only existing SQL tables, such as {taxonomy_term_data}.
*/
function
hook_field_schema
(
$field
)
{
if
(
$field
[
'type'
]
==
'text_long'
)
{
...
...
@@ -1302,7 +1305,7 @@ function hook_field_storage_details_alter(&$details, $field) {
* FIELD_LOAD_REVISION to load the version indicated by each entity.
* @param $fields
* An array listing the fields to be loaded. The keys of the array are field
* IDs, and the values of the array are the entity IDs (or revision IDs,
*
UU
IDs, and the values of the array are the entity IDs (or revision IDs,
* depending on the $age parameter) to add each field to.
* @param $options
* An associative array of additional options, with the following keys:
...
...
@@ -1370,7 +1373,7 @@ function hook_field_storage_load($entity_type, $entities, $age, $fields, $option
* FIELD_STORAGE_INSERT when inserting a new entity.
* @param $fields
* An array listing the fields to be written. The keys and values of the
* array are field IDs.
* array are field
UU
IDs.
*/
function
hook_field_storage_write
(
\Drupal\Core\Entity\EntityInterface
$entity
,
$op
,
$fields
)
{
$id
=
$entity
->
id
();
...
...
@@ -1464,7 +1467,7 @@ function hook_field_storage_write(\Drupal\Core\Entity\EntityInterface $entity, $
* The entity on which to operate.
* @param $fields
* An array listing the fields to delete. The keys and values of the
* array are field IDs.
* array are field
UU
IDs.
*/
function
hook_field_storage_delete
(
\Drupal\Core\Entity\EntityInterface
$entity
,
$fields
)
{
foreach
(
field_info_instances
(
$entity
->
entityType
(),
$entity
->
bundle
())
as
$instance
)
{
...
...
@@ -1488,7 +1491,7 @@ function hook_field_storage_delete(\Drupal\Core\Entity\EntityInterface $entity,
* The entity on which to operate.
* @param $fields
* An array listing the fields to delete. The keys and values of the
* array are field IDs.
* array are field
UU
IDs.
*/
function
hook_field_storage_delete_revision
(
\Drupal\Core\Entity\EntityInterface
$entity
,
$fields
)
{
$vid
=
$entity
->
getRevisionId
();
...
...
@@ -1712,13 +1715,13 @@ function hook_field_storage_delete_instance($instance) {
* FIELD_LOAD_CURRENT to load the most recent revision for all fields, or
* FIELD_LOAD_REVISION to load the version indicated by each entity.
* @param $skip_fields
* An array keyed by field IDs whose data has already been loaded and
* An array keyed by field
UU
IDs whose data has already been loaded and
* therefore should not be loaded again. Add a key to this array to indicate
* that your module has already loaded a field.
* @param $options
* An associative array of additional options, with the following keys:
* - field_id: The field
ID that should be loaded. If unset, all fields should
* be loaded.
* - field_id: The field
UUID that should be loaded. If unset, all fields
*
should
be loaded.
* - deleted: If TRUE, deleted fields should be loaded as well as non-deleted
* fields. If unset or FALSE, only non-deleted fields should be loaded.
*/
...
...
@@ -1735,11 +1738,11 @@ function hook_field_storage_pre_load($entity_type, $entities, $age, &$skip_field
* @param \Drupal\Core\Entity\EntityInterface $entity
* The entity with fields to save.
* @param $skip_fields
* An array keyed by field IDs whose data has already been written and
* An array keyed by field
UU
IDs whose data has already been written and
* therefore should not be written again. The values associated with these
* keys are not specified.
* @return
* Saved field
IDs are set
set as keys in $skip_fields.
* Saved field
UUIDs are
set as keys in $skip_fields.
*/
function
hook_field_storage_pre_insert
(
\Drupal\Core\Entity\EntityInterface
$entity
,
&
$skip_fields
)
{
if
(
$entity
->
entityType
()
==
'node'
&&
$entity
->
status
&&
_forum_node_check_node_type
(
$entity
))
{
...
...
@@ -1770,11 +1773,11 @@ function hook_field_storage_pre_insert(\Drupal\Core\Entity\EntityInterface $enti
* @param \Drupal\Core\Entity\EntityInterface $entity
* The entity with fields to save.
* @param $skip_fields
* An array keyed by field IDs whose data has already been written and
* An array keyed by field
UU
IDs whose data has already been written and
* therefore should not be written again. The values associated with these
* keys are not specified.
* @return
* Saved field
IDs are set
set as keys in $skip_fields.
* Saved field
UUIDs are
set as keys in $skip_fields.
*/
function
hook_field_storage_pre_update
(
\Drupal\Core\Entity\EntityInterface
$entity
,
&
$skip_fields
)
{
$first_call
=
&
drupal_static
(
__FUNCTION__
,
array
());
...
...
core/modules/field/field.attach.inc
View file @
a820153f
...
...
@@ -1170,7 +1170,7 @@ function field_attach_insert(EntityInterface $entity) {
$storages
=
array
();
foreach
(
field_info_instances
(
$entity
->
entityType
(),
$entity
->
bundle
())
as
$instance
)
{
$field
=
field_info_field_by_id
(
$instance
[
'field_id'
]);
$field_id
=
$field
[
'id'
];
$field_id
=
$field
[
'
uu
id'
];
$field_name
=
$field
[
'field_name'
];
if
(
!
empty
(
$entity
->
$field_name
))
{
// Collect the storage backend if the field has not been written yet.
...
...
@@ -1211,7 +1211,7 @@ function field_attach_update(EntityInterface $entity) {
$storages
=
array
();
foreach
(
field_info_instances
(
$entity
->
entityType
(),
$entity
->
bundle
())
as
$instance
)
{
$field
=
field_info_field_by_id
(
$instance
[
'field_id'
]);
$field_id
=
$field
[
'id'
];
$field_id
=
$field
[
'
uu
id'
];
$field_name
=
$field
[
'field_name'
];
// Leave the field untouched if $entity comes with no $field_name property,
// but empty the field if it comes as a NULL value or an empty array.
...
...
@@ -1254,7 +1254,7 @@ function field_attach_delete(EntityInterface $entity) {
$storages
=
array
();
foreach
(
field_info_instances
(
$entity
->
entityType
(),
$entity
->
bundle
())
as
$instance
)
{
$field
=
field_info_field_by_id
(
$instance
[
'field_id'
]);
$field_id
=
$field
[
'id'
];
$field_id
=
$field
[
'
uu
id'
];
$storages
[
$field
[
'storage'
][
'type'
]][
$field_id
]
=
$field_id
;
}
...
...
@@ -1287,7 +1287,7 @@ function field_attach_delete_revision(EntityInterface $entity) {
$storages
=
array
();
foreach
(
field_info_instances
(
$entity
->
entityType
(),
$entity
->
bundle
())
as
$instance
)
{
$field
=
field_info_field_by_id
(
$instance
[
'field_id'
]);
$field_id
=
$field
[
'id'
];
$field_id
=
$field
[
'
uu
id'
];
$storages
[
$field
[
'storage'
][
'type'
]][
$field_id
]
=
$field_id
;
}
...
...
@@ -1531,11 +1531,16 @@ function field_entity_bundle_create($entity_type, $bundle) {
* Implements hook_entity_bundle_rename().
*/
function
field_entity_bundle_rename
(
$entity_type
,
$bundle_old
,
$bundle_new
)
{
db_update
(
'field_config_instance'
)
->
fields
(
array
(
'bundle'
=>
$bundle_new
))
->
condition
(
'entity_type'
,
$entity_type
)
->
condition
(
'bundle'
,
$bundle_old
)
->
execute
();
$instances
=
field_read_instances
();
foreach
(
$instances
as
$instance
)
{
if
(
$instance
->
entity_type
==
$entity_type
&&
$instance
->
bundle
==
$bundle_old
)
{
$id_new
=
$instance
[
'entity_type'
]
.
'.'
.
$bundle_new
.
'.'
.
$instance
[
'field_name'
];
$instance
->
id
=
$id_new
;
$instance
->
bundle
=
$bundle_new
;
$instance
->
allowBundleRename
();
$instance
->
save
();
}
}
// Clear the cache.
field_cache_clear
();
...
...
core/modules/field/field.crud.inc
View file @
a820153f
This diff is collapsed.
Click to expand it.
core/modules/field/field.info.inc
View file @
a820153f
...
...
@@ -5,7 +5,7 @@
* Field Info API, providing information about available fields and field types.
*/
use
Drupal\field\FieldInstance
;
use
Drupal\field\
Plugin\Core\Entity\
FieldInstance
;
use
Drupal\field\FieldInfo
;
/**
...
...
core/modules/field/field.info.yml
View file @
a820153f
...
...
@@ -3,6 +3,4 @@ description: 'Field API to add fields to entities like nodes and users.'
package
:
Core
version
:
VERSION
core
:
8.x
dependencies
:
-
field_sql_storage
required
:
true
core/modules/field/field.install
View file @
a820153f
This diff is collapsed.
Click to expand it.
core/modules/field/field.module
View file @
a820153f
This diff is collapsed.
Click to expand it.
core/modules/field/field.views.inc
View file @
a820153f
...
...
@@ -72,7 +72,7 @@ function field_views_field_label($field_name) {
foreach
(
$instances
as
$entity_name
=>
$entity_type
)
{
foreach
(
$entity_type
as
$bundle
)
{
if
(
isset
(
$bundle
[
$field_name
]))
{
$label_counter
[
$bundle
[
$field_name
][
'label'
]]
=
isset
(
$label_counter
[
$bundle
[
$field_name
][
'label'
]])
?
++
$label_counter
[
$bundle
[
$field_name
]
[
'label'
]
]
:
1
;
$label_counter
[
$bundle
[
$field_name
][
'label'
]]
=
isset
(
$label_counter
[
$bundle
[
$field_name
][
'label'
]])
?
++
$label_counter
[
$bundle
[
$field_name
]
->
label
]
:
1
;
$all_labels
[
$entity_name
][
$bundle
[
$field_name
][
'label'
]]
=
TRUE
;
}
}
...
...
@@ -296,10 +296,10 @@ function field_views_field_default_views_data($field) {
else
{
$group
=
t
(
'@group (historical data)'
,
array
(
'@group'
=>
$group_name
));
}
$column_real_name
=
$field
[
'storage
'
][
'
details'
][
'sql'
][
$type
][
$table
][
$column
];
$column_real_name
=
$field
[
'storage
_
details'
][
'sql'
][
$type
][
$table
][
$column
];
// Load all the fields from the table by default.
$additional_fields
=
array_values
(
$field
[
'storage
'
][
'
details'
][
'sql'
][
$type
][
$table
]);
$additional_fields
=
array_values
(
$field
[
'storage
_
details'
][
'sql'
][
$type
][
$table
]);
$data
[
$table
][
$column_real_name
]
=
array
(
'group'
=>
$group
,
...
...
core/modules/field/lib/Drupal/field/FieldInfo.php
View file @
a820153f
...
...
@@ -142,17 +142,24 @@ public function getFieldMap() {
$map
=
array
();
$query
=
db_select
(
'field_config_instance'
,
'fci'
);
$query
->
join
(
'field_config'
,
'fc'
,
'fc.id = fci.field_id'
);
$query
->
fields
(
'fc'
,
array
(
'type'
));
$query
->
fields
(
'fci'
,
array
(
'field_name'
,
'entity_type'
,
'bundle'
))
->
condition
(
'fc.active'
,
1
)
->
condition
(
'fc.storage_active'
,
1
)
->
condition
(
'fc.deleted'
,
0
)
->
condition
(
'fci.deleted'
,
0
);
foreach
(
$query
->
execute
()
as
$row
)
{
$map
[
$row
->
field_name
][
'bundles'
][
$row
->
entity_type
][]
=
$row
->
bundle
;
$map
[
$row
->
field_name
][
'type'
]
=
$row
->
type
;
// Get active fields.
foreach
(
config_get_storage_names_with_prefix
(
'field.field'
)
as
$config_id
)
{
$field_config
=
\Drupal
::
config
(
$config_id
)
->
get
();
if
(
$field_config
[
'active'
]
&&
$field_config
[
'storage'
][
'active'
])
{
$fields
[
$field_config
[
'uuid'
]]
=
$field_config
;
}
}
// Get field instances.
foreach
(
config_get_storage_names_with_prefix
(
'field.instance'
)
as
$config_id
)
{
$instance_config
=
\Drupal
::
config
(
$config_id
)
->
get
();
$field_uuid
=
$instance_config
[
'field_uuid'
];
// Filter out instances of inactive fields, and instances on unknown
// entity types.
if
(
isset
(
$fields
[
$field_uuid
]))
{
$field
=
$fields
[
$field_uuid
];
$map
[
$field
[
'id'
]][
'bundles'
][
$instance_config
[
'entity_type'
]][]
=
$instance_config
[
'bundle'
];
$map
[
$field
[
'id'
]][
'type'
]
=
$field
[
'type'
];
}
}
// Save in "static" and persistent caches.
...
...
@@ -181,7 +188,7 @@ public function getFields() {
else
{
// Collect and prepare fields.
foreach
(
field_read_fields
(
array
(),
array
(
'include_deleted'
=>
TRUE
))
as
$field
)
{
$this
->
fieldsById
[
$field
[
'id'
]]
=
$this
->
prepareField
(
$field
);
$this
->
fieldsById
[
$field
[
'
uu
id'
]]
=
$this
->
prepareField
(
$field
);
}
// Store in persistent cache.
...
...
@@ -191,7 +198,7 @@ public function getFields() {
// Fill the name/ID map.
foreach
(
$this
->
fieldsById
as
$field
)
{
if
(
!
$field
[
'deleted'
])
{
$this
->
fieldIdsByName
[
$field
[
'
field_name'
]]
=
$field
[
'
id'
];
$this
->
fieldIdsByName
[
$field
[
'
id'
]]
=
$field
[
'uu
id'
];
}
}
...
...
@@ -229,7 +236,7 @@ public function getInstances($entity_type = NULL) {
foreach
(
field_read_instances
()
as
$instance
)
{
$field
=
$this
->
getField
(
$instance
[
'field_name'
]);
$instance
=
$this
->
prepareInstance
(
$instance
,
$field
[
'type'
]);
$this
->
bundleInstances
[
$instance
[
'entity_type'
]][
$instance
[
'bundle'
]][
$instance
[
'field_name'
]]
=
new
FieldInstance
(
$instance
)
;
$this
->
bundleInstances
[
$instance
[
'entity_type'
]][
$instance
[
'bundle'
]][
$instance
[
'field_name'
]]
=
$instance
;
}
// Store in persistent cache.
...
...
@@ -275,8 +282,8 @@ public function getField($field_name) {
$field
=
$this
->
prepareField
(
$field
);
// Save in the "static" cache.
$this
->
fieldsById
[
$field
[
'id'
]]
=
$field
;
$this
->
fieldIdsByName
[
$field
[
'field_name'
]]
=
$field
[
'id'
];
$this
->
fieldsById
[
$field
[
'
uu
id'
]]
=
$field
;
$this
->
fieldIdsByName
[
$field
[
'field_name'
]]
=
$field
[
'
uu
id'
];
return
$field
;
}
...
...
@@ -309,14 +316,14 @@ public function getFieldById($field_id) {
// bundle.
// Cache miss: read from definition.
if
(
$fields
=
field_read_fields
(
array
(
'id'
=>
$field_id
),
array
(
'include_deleted'
=>
TRUE
)))
{
if
(
$fields
=
field_read_fields
(
array
(
'
uu
id'
=>
$field_id
),
array
(
'include_deleted'
=>
TRUE
)))
{
$field
=
current
(
$fields
);
$field
=
$this
->
prepareField
(
$field
);
// Store in the static cache.
$this
->
fieldsById
[
$field
[
'id'
]]
=
$field
;
$this
->
fieldsById
[
$field
[
'
uu
id'
]]
=
$field
;
if
(
!
$field
[
'deleted'
])
{
$this
->
fieldIdsByName
[
$field
[
'field_name'
]]
=
$field
[
'id'
];
$this
->
fieldIdsByName
[
$field
[
'field_name'
]]
=
$field
[
'
uu
id'
];
}
return
$field
;
...
...
@@ -355,10 +362,10 @@ public function getBundleInstances($entity_type, $bundle) {
// Extract the field definitions and save them in the "static" cache.
foreach
(
$info
[
'fields'
]
as
$field
)
{
if
(
!
isset
(
$this
->
fieldsById
[
$field
[
'id'
]]))
{
$this
->
fieldsById
[
$field
[
'id'
]]
=
$field
;
if
(
!
isset
(
$this
->
fieldsById
[
$field
[
'
uu
id'
]]))
{
$this
->
fieldsById
[
$field
[
'
uu
id'
]]
=
$field
;
if
(
!
$field
[
'deleted'
])
{
$this
->
fieldIdsByName
[
$field
[
'field_name'
]]
=
$field
[
'id'
];
$this
->
fieldIdsByName
[
$field
[
'field_name'
]]
=
$field
[
'
uu
id'
];
}
}
}
...
...
@@ -377,27 +384,40 @@ public function getBundleInstances($entity_type, $bundle) {
}
// Cache miss: collect from the definitions.
$instances
=
array
();
// Collect the fields in the bundle.
$params
=
array
(
'entity_type'
=>
$entity_type
,
'bundle'
=>
$bundle
);
$fields
=
field_read_fields
(
$params
);
// Do not return anything for unknown entity types.
if
(
entity_get_info
(
$entity_type
))
{
// This iterates on non-deleted instances, so deleted fields are kept out of
// the persistent caches.
foreach
(
field_read_instances
(
$params
)
as
$instance
)
{
$field
=
$fields
[
$instance
[
'field_name'
]];
// Collect names of fields and instances involved in the bundle, using the
// field map. The field map is already filtered to active, non-deleted
// fields and instances, so those are kept out of the persistent caches.
$config_ids
=
array
();
foreach
(
$this
->
getFieldMap
()
as
$field_name
=>
$field_data
)
{
if
(
isset
(
$field_data
[
'bundles'
][
$entity_type
])
&&
in_array
(
$bundle
,
$field_data
[
'bundles'
][
$entity_type
]))
{
$config_ids
[
$field_name
]
=
"
$entity_type
.
$bundle
.
$field_name
"
;
}
}
$instance
=
$this
->
prepareInstance
(
$instance
,
$field
[
'type'
]);
$instances
[
$field
[
'field_name'
]]
=
new
FieldInstance
(
$instance
);
// Load and prepare the corresponding fields and instances entities.
if
(
$config_ids
)
{
$loaded_fields
=
entity_load_multiple
(
'field_entity'
,
array_keys
(
$config_ids
));
$loaded_instances
=
entity_load_multiple
(
'field_instance'
,
array_values
(
$config_ids
));
// If the field is not in our global "static" list yet, add it.
if
(
!
isset
(
$this
->
fieldsById
[
$field
[
'id'
]]))
{
$field
=
$this
->
prepareField
(
$field
);
foreach
(
$loaded_instances
as
$instance
)
{
$field
=
$loaded_fields
[
$instance
[
'field_name'
]];
$instance
=
$this
->
prepareInstance
(
$instance
,
$field
[
'type'
]);
$instances
[
$field
[
'field_name'
]]
=
$instance
;
$this
->
fieldsById
[
$field
[
'id'
]]
=
$field
;
$this
->
fieldIdsByName
[
$field
[
'field_name'
]]
=
$field
[
'id'
];
// If the field is not in our global "static" list yet, add it.
if
(
!
isset
(
$this
->
fieldsById
[
$field
[
'uuid'
]]))
{
$field
=
$this
->
prepareField
(
$field
);
$this
->
fieldsById
[
$field
[
'uuid'
]]
=
$field
;
$this
->
fieldIdsByName
[
$field
[
'field_name'
]]
=
$field
[
'uuid'
];
}
}
}
}
...
...
@@ -480,20 +500,6 @@ public function prepareField($field) {
$field
[
'settings'
]
+=
field_info_field_settings
(
$field
[
'type'
]);
$field
[
'storage'
][
'settings'
]
+=
field_info_storage_settings
(
$field
[
'storage'
][
'type'
]);
// Add storage details.
$details
=
(
array
)
module_invoke
(
$field
[
'storage'
][
'module'
],
'field_storage_details'
,
$field
);
drupal_alter
(
'field_storage_details'
,
$details
,
$field
);
$field
[
'storage'
][
'details'
]
=
$details
;
// Populate the list of bundles using the field.
$field
[
'bundles'
]
=
array
();
if
(
!
$field
[
'deleted'
])
{
$map
=
$this
->
getFieldMap
();
if
(
isset
(
$map
[
$field
[
'field_name'
]]))
{
$field
[
'bundles'
]
=
$map
[
$field
[
'field_name'
]][
'bundles'
];
}
}
return
$field
;
}
...
...
@@ -553,4 +559,5 @@ public function prepareExtraFields($extra_fields, $entity_type, $bundle) {
return
$result
;
}
}
core/modules/field/lib/Drupal/field/FieldInstance.php
deleted
100644 → 0
View file @
5a6647be
<?php
/**
* @file
* Definition of Drupal\field\FieldInstance.
*/
namespace
Drupal\field
;
/**
* Class for field instance objects.
*/
class
FieldInstance
implements
\ArrayAccess
{
/**
* The instance definition, as read from configuration storage.
*
* @var array
*/
public
$definition
;
/**
* The widget object used for this instance.
*
* @var Drupal\field\Plugin\Type\Widget\WidgetInterface
*/
protected
$widget
;
/**
* Constructs a FieldInstance object.
*
* @param array $definition
* The instance definition array, as read from configuration storage.
*/
public
function
__construct
(
array
$definition
)
{
$this
->
definition
=
$definition
;
}
/**
* Returns the Widget plugin for the instance.
*
* @return Drupal\field\Plugin\Type\Widget\WidgetInterface
* The Widget plugin to be used for the instance.
*/
public
function
getWidget
()
{
if
(
empty
(
$this
->
widget
))
{
$widget_properties
=
$this
->
definition
[
'widget'
];
// Let modules alter the widget properties.
$context
=
array
(
'entity_type'
=>
$this
->
definition
[
'entity_type'
],
'bundle'
=>
$this
->
definition
[
'bundle'
],
'field'
=>
field_info_field
(
$this
->
definition
[
'field_name'
]),
'instance'
=>
$this
,
);
drupal_alter
(
array
(
'field_widget_properties'
,
'field_widget_properties_'
.
$this
->
definition
[
'entity_type'
]),
$widget_properties
,
$context
);
$options
=
array
(
'instance'
=>
$this
,
'type'
=>
$widget_properties
[
'type'
],
'settings'
=>
$widget_properties
[
'settings'
],
'weight'
=>
$widget_properties
[
'weight'
],
);
$this
->
widget
=
drupal_container
()
->
get
(
'plugin.manager.field.widget'
)
->
getInstance
(
$options
);
}
return
$this
->
widget
;
}
/**
* Implements ArrayAccess::offsetExists().
*/
public
function
offsetExists
(
$offset
)
{
return
isset
(
$this
->
definition
[
$offset
])
||
array_key_exists
(
$offset
,
$this
->
definition
);
}
/**
* Implements ArrayAccess::offsetGet().
*/
public
function
&
offsetGet
(
$offset
)
{
return
$this
->
definition
[
$offset
];
}
/**
* Implements ArrayAccess::offsetSet().
*/
public
function
offsetSet
(
$offset
,
$value
)
{
if
(
!
isset
(
$offset
))
{
// Do nothing; $array[] syntax is not supported by this temporary wrapper.
return
;
}
$this
->
definition
[
$offset
]
=
$value
;
// If the widget or formatter properties changed, the corrsponding plugins
// need to be re-instanciated.
if
(
$offset
==
'widget'
)
{
unset
(
$this
->
widget
);
}
}
/**
* Implements ArrayAccess::offsetUnset().
*/
public
function
offsetUnset
(
$offset
)
{
unset
(
$this
->
definition
[
$offset
]);
// If the widget or formatter properties changed, the corrsponding plugins
// need to be re-instanciated.
if
(
$offset
==
'widget'
)
{
unset
(
$this
->
widget
);
}
}
/**