Issue #2095303 by swentel, plopesc, Berdir, claudiu.cristea, yched: Rename 'field_entity' to 'field_config' and 'field_instance' to 'field_instance_config'.

8.0.x
Alex Pott 2014-02-19 23:29:14 +00:00
parent b65c8f413d
commit 40dc8daf51
136 changed files with 600 additions and 631 deletions

View File

@ -18,7 +18,7 @@ use Drupal\field\FieldInfo;
use Drupal\field\FieldUpdateForbiddenException;
use Drupal\field\FieldInterface;
use Drupal\field\FieldInstanceInterface;
use Drupal\field\Entity\Field;
use Drupal\field\Entity\FieldConfig;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**

View File

@ -17,7 +17,7 @@ use Drupal\field\FieldInfo;
use Drupal\field\FieldUpdateForbiddenException;
use Drupal\field\FieldInterface;
use Drupal\field\FieldInstanceInterface;
use Drupal\field\Entity\Field;
use Drupal\field\Entity\FieldConfig;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
@ -1099,7 +1099,7 @@ class FieldableDatabaseStorageController extends FieldableEntityStorageControlle
// We need to account for deleted fields and instances. The method runs
// before the instance definitions are updated, so we need to fetch them
// using the old bundle name.
$instances = entity_load_multiple_by_properties('field_instance', array('entity_type' => $this->entityTypeId, 'bundle' => $bundle, 'include_deleted' => TRUE));
$instances = entity_load_multiple_by_properties('field_instance_config', array('entity_type' => $this->entityTypeId, 'bundle' => $bundle, 'include_deleted' => TRUE));
foreach ($instances as $instance) {
$field = $instance->getField();
$table_name = static::_fieldTableName($field);
@ -1451,7 +1451,7 @@ class FieldableDatabaseStorageController extends FieldableEntityStorageControlle
* unique among all other fields.
*/
static public function _fieldColumnName(FieldInterface $field, $column) {
return in_array($column, Field::getReservedColumns()) ? $column : $field->getName() . '_' . $column;
return in_array($column, FieldConfig::getReservedColumns()) ? $column : $field->getName() . '_' . $column;
}
}

View File

@ -12,7 +12,7 @@ use Drupal\Core\Entity\EntityStorageControllerInterface;
use Drupal\Core\Entity\FieldableDatabaseStorageController;
use Drupal\Core\Entity\Plugin\DataType\EntityReference;
use Drupal\Core\Entity\Query\QueryException;
use Drupal\field\Entity\Field;
use Drupal\field\Entity\FieldConfig;
use Drupal\field\Field as FieldInfo;
/**
@ -118,7 +118,7 @@ class Tables implements TablesInterface {
$next = $specifiers[$key + 1];
// Is this a field column?
$columns = $field->getColumns();
if (isset($columns[$next]) || in_array($next, Field::getReservedColumns())) {
if (isset($columns[$next]) || in_array($next, FieldConfig::getReservedColumns())) {
// Use it.
$column = $next;
// Do not process it again.

View File

@ -27,18 +27,19 @@ use Drupal\Core\TypedData\ListDefinitionInterface;
* It is up to the class implementing this interface to manage where the
* information comes from. For example, field.module provides an implementation
* based on two levels of configuration. It allows the site administrator to add
* custom fields to any entity type and bundle via the "field_entity" and
* "field_instance" configuration entities. The former for storing configuration
* that is independent of which entity type and bundle the field is added to,
* and the latter for storing configuration that is specific to the entity type
* and bundle. The class that implements "field_instance" configuration entities
* also implements this interface, returning information from either itself, or
* from the corresponding "field_entity" configuration, as appropriate.
* custom fields to any entity type and bundle via the "field_config" and
* "field_instance_config" configuration entities. The former for storing
* configuration that is independent of which entity type and bundle the field
* is added to, and the latter for storing configuration that is specific to the
* entity type and bundle. The class that implements "field_instance_config"
* configuration entities also implements this interface, returning information
* from either itself, or from the corresponding "field_config" configuration,
* as appropriate.
*
* However, entity base fields, such as $node->title, are not managed by
* field.module and its "field_entity"/"field_instance" configuration entities.
* Therefore, their definitions are provided by different objects based on the
* class \Drupal\Core\Field\FieldDefinition, which implements this
* field.module and its "field_config"/"field_instance_config" configuration
* entities. Therefore, their definitions are provided by different objects
* based on the class \Drupal\Core\Field\FieldDefinition, which implements this
* interface as well.
*
* Field definitions may fully define a concrete data object (e.g.,

View File

@ -176,7 +176,7 @@ function custom_block_add_body_field($block_type_id, $label = 'Block body') {
$field = field_info_field('custom_block', 'body');
$instance = field_info_instance('custom_block', 'body', $block_type_id);
if (empty($field)) {
$field = entity_create('field_entity', array(
$field = entity_create('field_config', array(
'name' => 'body',
'entity_type' => 'custom_block',
'type' => 'text_with_summary',
@ -184,7 +184,7 @@ function custom_block_add_body_field($block_type_id, $label = 'Block body') {
$field->save();
}
if (empty($instance)) {
$instance = entity_create('field_instance', array(
$instance = entity_create('field_instance_config', array(
'field_name' => 'body',
'entity_type' => 'custom_block',
'bundle' => $block_type_id,

View File

@ -25,14 +25,14 @@ class CustomBlockFieldTest extends CustomBlockTestBase {
/**
* The created field.
*
* @var \Drupal\field\Entity\Field
* @var \Drupal\field\Entity\FieldConfig
*/
protected $field;
/**
* The created instance.
*
* @var \Drupal\field\Entity\FieldInstance
* @var \Drupal\field\Entity\FieldInstanceConfig
*/
protected $instance;
@ -64,14 +64,14 @@ class CustomBlockFieldTest extends CustomBlockTestBase {
$this->blockType = $this->createCustomBlockType('link');
// Create a field with settings to validate.
$this->field = entity_create('field_entity', array(
$this->field = entity_create('field_config', array(
'name' => drupal_strtolower($this->randomName()),
'entity_type' => 'custom_block',
'type' => 'link',
'cardinality' => 2,
));
$this->field->save();
$this->instance = entity_create('field_instance', array(
$this->instance = entity_create('field_instance_config', array(
'field_name' => $this->field->getName(),
'entity_type' => 'custom_block',
'bundle' => 'link',

View File

@ -5,16 +5,12 @@
* Install, update and uninstall functions for the Comment module.
*/
use Drupal\Core\Language\Language;
use Drupal\comment\Plugin\Field\FieldType\CommentItem;
use Drupal\field\Entity\Field;
/**
* Implements hook_uninstall().
*/
function comment_uninstall() {
// Remove the comment fields.
$fields = entity_load_multiple_by_properties('field_entity', array('type' => 'comment'));
$fields = entity_load_multiple_by_properties('field_config', array('type' => 'comment'));
foreach ($fields as $field) {
entity_invoke_bundle_hook('delete', 'comment', $field->entity_type . '__' . $field->name);
$field->delete();

View File

@ -236,9 +236,9 @@ function comment_count_unpublished() {
}
/**
* Implements hook_ENTITY_TYPE_insert() for 'field_instance'.
* Implements hook_ENTITY_TYPE_insert() for 'field_instance_config'.
*/
function comment_field_instance_insert(FieldInstanceInterface $instance) {
function comment_field_instance_config_insert(FieldInstanceInterface $instance) {
if ($instance->getType() == 'comment' && !$instance->isSyncing()) {
\Drupal::service('comment.manager')->addBodyField($instance->entity_type, $instance->getName());
\Drupal::cache()->delete('comment_entity_info');
@ -246,9 +246,9 @@ function comment_field_instance_insert(FieldInstanceInterface $instance) {
}
/**
* Implements hook_ENTITY_TYPE_create() for 'field_instance'.
* Implements hook_ENTITY_TYPE_create() for 'field_instance_config'.
*/
function comment_field_instance_create(FieldInstanceInterface $instance) {
function comment_field_instance_config_create(FieldInstanceInterface $instance) {
if ($instance->getType() == 'comment' && !$instance->isSyncing()) {
// Assign default values for the field instance.
if (!isset($instance->default_value)) {
@ -267,9 +267,9 @@ function comment_field_instance_create(FieldInstanceInterface $instance) {
}
/**
* Implements hook_ENTITY_TYPE_update() for 'field_instance'.
* Implements hook_ENTITY_TYPE_update() for 'field_instance_config'.
*/
function comment_field_instance_update(FieldInstanceInterface $instance) {
function comment_field_instance_config_update(FieldInstanceInterface $instance) {
if ($instance->getType() == 'comment') {
\Drupal::entityManager()->getViewBuilder($instance->entity_type)->resetCache();
// Comment field settings also affects the rendering of *comment* entities,
@ -279,9 +279,9 @@ function comment_field_instance_update(FieldInstanceInterface $instance) {
}
/**
* Implements hook_ENTITY_TYPE_delete() for 'field_entity'.
* Implements hook_ENTITY_TYPE_delete() for 'field_config'.
*/
function comment_field_entity_delete(FieldInterface $field) {
function comment_field_config_delete(FieldInterface $field) {
if ($field->getType() == 'comment') {
// Delete all fields and displays attached to the comment bundle.
entity_invoke_bundle_hook('delete', 'comment', $field->getName());
@ -290,9 +290,9 @@ function comment_field_entity_delete(FieldInterface $field) {
}
/**
* Implements hook_ENTITY_TYPE_delete() for 'field_instance'.
* Implements hook_ENTITY_TYPE_delete() for 'field_instance_config'.
*/
function comment_field_instance_delete(FieldInstanceInterface $instance) {
function comment_field_instance_config_delete(FieldInstanceInterface $instance) {
if ($instance->getType() == 'comment') {
// Delete all comments that used by the entity bundle.
$comments = db_query("SELECT cid FROM {comment} WHERE entity_type = :entity_type AND field_id = :field_id", array(

View File

@ -142,7 +142,7 @@ class CommentManager implements CommentManagerInterface {
// Make sure the field doesn't already exist.
if (!$this->fieldInfo->getField($entity_type, $field_name)) {
// Add a default comment field for existing node comments.
$field = $this->entityManager->getStorageController('field_entity')->create(array(
$field = $this->entityManager->getStorageController('field_config')->create(array(
'entity_type' => $entity_type,
'name' => $field_name,
'type' => 'comment',
@ -153,7 +153,7 @@ class CommentManager implements CommentManagerInterface {
}
// Make sure the instance doesn't already exist.
if (!$this->fieldInfo->getInstance($entity_type, $bundle, $field_name)) {
$instance = $this->entityManager->getStorageController('field_instance')->create(array(
$instance = $this->entityManager->getStorageController('field_instance_config')->create(array(
'label' => 'Comment settings',
'description' => '',
'field_name' => $field_name,
@ -197,9 +197,9 @@ class CommentManager implements CommentManagerInterface {
*/
public function addBodyField($entity_type, $field_name) {
// Create the field if needed.
$field = $this->entityManager->getStorageController('field_entity')->load('comment.comment_body');
$field = $this->entityManager->getStorageController('field_config')->load('comment.comment_body');
if (!$field) {
$field = $this->entityManager->getStorageController('field_entity')->create(array(
$field = $this->entityManager->getStorageController('field_config')->create(array(
'name' => 'comment_body',
'type' => 'text_long',
'entity_type' => 'comment',
@ -209,11 +209,11 @@ class CommentManager implements CommentManagerInterface {
// Create the instance if needed, field name defaults to 'comment'.
$comment_bundle = $entity_type . '__' . $field_name;
$field_instance = $this->entityManager
->getStorageController('field_instance')
->getStorageController('field_instance_config')
->load("comment.$comment_bundle.comment_body");
if (!$field_instance) {
// Attaches the body field by default.
$field_instance = $this->entityManager->getStorageController('field_instance')->create(array(
$field_instance = $this->entityManager->getStorageController('field_instance_config')->create(array(
'field_name' => 'comment_body',
'label' => 'Comment',
'entity_type' => 'comment',

View File

@ -60,7 +60,7 @@ class CommentFieldsTest extends CommentTestBase {
// Test adding a field that defaults to COMMENT_CLOSED.
$this->container->get('comment.manager')->addDefaultField('node', 'test_node_type', 'who_likes_ponies', COMMENT_CLOSED);
$field = entity_load('field_instance', 'node.test_node_type.who_likes_ponies');
$field = entity_load('field_instance_config', 'node.test_node_type.who_likes_ponies');
$this->assertEqual($field->default_value[0]['status'], COMMENT_CLOSED);
}
@ -73,7 +73,7 @@ class CommentFieldsTest extends CommentTestBase {
$this->drupalLogin($this->admin_user);
// Drop default comment field added in CommentTestBase::setup().
entity_load('field_entity', 'node.comment')->delete();
entity_load('field_config', 'node.comment')->delete();
if ($field = $this->container->get('field.info')->getField('node', 'comment_node_forum')) {
$field->delete();
}

View File

@ -31,11 +31,11 @@ class CommentNodeChangesTest extends CommentTestBase {
$this->assertFalse(comment_load($comment->id()), 'The comment could not be loaded after the node was deleted.');
// Make sure the comment field and all its instances are deleted when node
// type is deleted.
$this->assertNotNull(entity_load('field_entity', 'node.comment'), 'Comment field exists');
$this->assertNotNull(entity_load('field_instance', 'node.article.comment'), 'Comment instance exists');
$this->assertNotNull(entity_load('field_config', 'node.comment'), 'Comment field exists');
$this->assertNotNull(entity_load('field_instance_config', 'node.article.comment'), 'Comment instance exists');
// Delete the node type.
entity_delete_multiple('node_type', array($this->node->bundle()));
$this->assertNull(entity_load('field_entity', 'node.comment'), 'Comment field deleted');
$this->assertNull(entity_load('field_instance', 'node.article.comment'), 'Comment instance deleted');
$this->assertNull(entity_load('field_config', 'node.comment'), 'Comment field deleted');
$this->assertNull(entity_load('field_instance_config', 'node.article.comment'), 'Comment instance deleted');
}
}

View File

@ -46,13 +46,13 @@ class CommentValidationTest extends EntityUnitTestBase {
*/
public function testValidation() {
// Add comment field to content.
$this->entityManager->getStorageController('field_entity')->create(array(
$this->entityManager->getStorageController('field_config')->create(array(
'entity_type' => 'node',
'name' => 'comment',
'type' => 'comment',
))->save();
// Add comment field instance to page content.
$this->entityManager->getStorageController('field_instance')->create(array(
$this->entityManager->getStorageController('field_instance_config')->create(array(
'field_name' => 'comment',
'entity_type' => 'node',
'bundle' => 'page',

View File

@ -52,7 +52,7 @@ function hook_config_translation_info(&$info) {
if ($entity_type->isFieldable() && !empty($base_route)) {
$info[$entity_type_id . '_fields'] = array(
'base_route_name' => 'field_ui.instance_edit_' . $entity_type_id,
'entity_type' => 'field_instance',
'entity_type' => 'field_instance_config',
'title' => t('!label field'),
'class' => '\Drupal\config_translation\ConfigFieldInstanceMapper',
'base_entity_type' => $entity_type_id,

View File

@ -94,9 +94,9 @@ function config_translation_entity_info_alter($entity_info) {
if ($entity_type_id == 'block') {
$class = 'Drupal\config_translation\Controller\ConfigTranslationBlockListController';
}
elseif ($entity_type_id == 'field_instance') {
elseif ($entity_type_id == 'field_instance_config') {
$class = 'Drupal\config_translation\Controller\ConfigTranslationFieldInstanceListController';
// Will be filled in dynamically, see \Drupal\field\Entity\FieldInstance::linkTemplates().
// Will be filled in dynamically, see \Drupal\field\Entity\FieldInstanceConfig::linkTemplates().
$entity_type->setLinkTemplate('drupal:config-translation-overview', 'config_translation.item.overview.');
}
else {
@ -135,7 +135,7 @@ function config_translation_config_translation_info(&$info) {
if ($entity_type->isFieldable() && !empty($base_route)) {
$info[$entity_type_id . '_fields'] = array(
'base_route_name' => 'field_ui.instance_edit_' . $entity_type_id,
'entity_type' => 'field_instance',
'entity_type' => 'field_instance_config',
'title' => '!label field',
'class' => '\Drupal\config_translation\ConfigFieldInstanceMapper',
'base_entity_type' => $entity_type_id,

View File

@ -25,7 +25,7 @@ class ContactFieldsTest extends ViewTestBase {
/**
* Contains the field definition array attached to contact used for this test.
*
* @var \Drupal\field\Entity\Field
* @var \Drupal\field\Entity\FieldConfig
*/
protected $field;
@ -40,14 +40,14 @@ class ContactFieldsTest extends ViewTestBase {
protected function setUp() {
parent::setUp();
$this->field = entity_create('field_entity', array(
$this->field = entity_create('field_config', array(
'name' => strtolower($this->randomName()),
'entity_type' => 'contact_message',
'type' => 'text'
));
$this->field->save();
entity_create('field_instance', array(
entity_create('field_instance_config', array(
'field_name' => $this->field->name,
'entity_type' => 'contact_message',
'bundle' => 'contact_message',

View File

@ -188,13 +188,13 @@ class ContentTranslationSettingsTest extends WebTestBase {
'entity_type' => 'node',
'type' => 'text',
);
entity_create('field_entity', $field)->save();
entity_create('field_config', $field)->save();
$instance = array(
'field_name' => 'article_text',
'entity_type' => 'node',
'bundle' => 'article',
);
entity_create('field_instance', $instance)->save();
entity_create('field_instance_config', $instance)->save();
// Tests that field instance doesn't have translatable setting if bundle
// is not translatable.

View File

@ -56,7 +56,7 @@ class ContentTranslationSyncImageTest extends ContentTranslationTestBase {
$this->fieldName = 'field_test_et_ui_image';
$this->cardinality = 3;
entity_create('field_entity', array(
entity_create('field_config', array(
'name' => $this->fieldName,
'entity_type' => $this->entityTypeId,
'type' => 'image',
@ -64,7 +64,7 @@ class ContentTranslationSyncImageTest extends ContentTranslationTestBase {
'translatable' => TRUE,
))->save();
entity_create('field_instance', array(
entity_create('field_instance_config', array(
'entity_type' => $this->entityTypeId,
'field_name' => $this->fieldName,
'bundle' => $this->entityTypeId,

View File

@ -175,14 +175,14 @@ abstract class ContentTranslationTestBase extends WebTestBase {
protected function setupTestFields() {
$this->fieldName = 'field_test_et_ui_test';
entity_create('field_entity', array(
entity_create('field_config', array(
'name' => $this->fieldName,
'type' => 'text',
'entity_type' => $this->entityTypeId,
'cardinality' => 1,
'translatable' => TRUE,
))->save();
entity_create('field_instance', array(
entity_create('field_instance_config', array(
'entity_type' => $this->entityTypeId,
'field_name' => $this->fieldName,
'bundle' => $this->bundle,

View File

@ -26,14 +26,14 @@ class DateTimeFieldTest extends WebTestBase {
/**
* A field to use in this test class.
*
* @var \Drupal\field\Entity\Field
* @var \Drupal\field\Entity\FieldConfig
*/
protected $field;
/**
* The instance used in this test class.
*
* @var \Drupal\field\Entity\FieldInstance
* @var \Drupal\field\Entity\FieldInstanceConfig
*/
protected $instance;
@ -58,14 +58,14 @@ class DateTimeFieldTest extends WebTestBase {
$this->drupalLogin($web_user);
// Create a field with settings to validate.
$this->field = entity_create('field_entity', array(
$this->field = entity_create('field_config', array(
'name' => drupal_strtolower($this->randomName()),
'entity_type' => 'entity_test',
'type' => 'datetime',
'settings' => array('datetime_type' => 'date'),
));
$this->field->save();
$this->instance = entity_create('field_instance', array(
$this->instance = entity_create('field_instance_config', array(
'field_name' => $this->field->name,
'entity_type' => 'entity_test',
'bundle' => 'entity_test',
@ -296,7 +296,7 @@ class DateTimeFieldTest extends WebTestBase {
$this->drupalCreateContentType(array('type' => 'date_content'));
// Create a field with settings to validate.
$field = entity_create('field_entity', array(
$field = entity_create('field_config', array(
'name' => drupal_strtolower($this->randomName()),
'entity_type' => 'node',
'type' => 'datetime',
@ -304,7 +304,7 @@ class DateTimeFieldTest extends WebTestBase {
));
$field->save();
$instance = entity_create('field_instance', array(
$instance = entity_create('field_instance_config', array(
'field_name' => $field->name,
'entity_type' => 'node',
'bundle' => 'date_content',

View File

@ -35,14 +35,14 @@ class DateTimeItemTest extends FieldUnitTestBase {
parent::setUp();
// Create a field with settings to validate.
$this->field = entity_create('field_entity', array(
$this->field = entity_create('field_config', array(
'name' => 'field_datetime',
'type' => 'datetime',
'entity_type' => 'entity_test',
'settings' => array('datetime_type' => 'date'),
));
$this->field->save();
$this->instance = entity_create('field_instance', array(
$this->instance = entity_create('field_instance_config', array(
'field_name' => $this->field->getName(),
'entity_type' => 'entity_test',
'bundle' => 'entity_test',

View File

@ -79,7 +79,7 @@ class EditAutocompleteTermTest extends WebTestBase {
));
$this->vocabulary->save();
$this->field_name = 'field_' . $this->vocabulary->id();
entity_create('field_entity', array(
entity_create('field_config', array(
'name' => $this->field_name,
'entity_type' => 'node',
'type' => 'taxonomy_term_reference',
@ -94,7 +94,7 @@ class EditAutocompleteTermTest extends WebTestBase {
),
),
))->save();
$instance = entity_create('field_instance', array(
$instance = entity_create('field_instance_config', array(
'field_name' => $this->field_name,
'entity_type' => 'node',
'label' => 'Tags',

View File

@ -54,7 +54,7 @@ class EditTestBase extends DrupalUnitTestBase {
*/
public function createFieldWithInstance($field_name, $type, $cardinality, $label, $instance_settings, $widget_type, $widget_settings, $formatter_type, $formatter_settings) {
$field = $field_name . '_field';
$this->$field = entity_create('field_entity', array(
$this->$field = entity_create('field_config', array(
'name' => $field_name,
'entity_type' => 'entity_test',
'type' => $type,
@ -63,7 +63,7 @@ class EditTestBase extends DrupalUnitTestBase {
$this->$field->save();
$instance = $field_name . '_instance';
$this->$instance = entity_create('field_instance', array(
$this->$instance = entity_create('field_instance_config', array(
'field_name' => $field_name,
'entity_type' => 'entity_test',
'bundle' => 'entity_test',

View File

@ -83,13 +83,13 @@ class EditEntityFieldAccessCheckTest extends UnitTestCase {
->method('access')
->will($this->returnValue(FALSE));
$field_with_access = $this->getMockBuilder('Drupal\field\Entity\Field')
$field_with_access = $this->getMockBuilder('Drupal\field\Entity\FieldConfig')
->disableOriginalConstructor()
->getMock();
$field_with_access->expects($this->any())
->method('access')
->will($this->returnValue(TRUE));
$field_without_access = $this->getMockBuilder('Drupal\field\Entity\Field')
$field_without_access = $this->getMockBuilder('Drupal\field\Entity\FieldConfig')
->disableOriginalConstructor()
->getMock();
$field_without_access->expects($this->any())

View File

@ -25,14 +25,14 @@ class EmailFieldTest extends WebTestBase {
/**
* A field to use in this test class.
*
* @var \Drupal\field\Entity\Field
* @var \Drupal\field\Entity\FieldConfig
*/
protected $field;
/**
* The instance used in this test class.
*
* @var \Drupal\field\Entity\FieldInstance
* @var \Drupal\field\Entity\FieldInstanceConfig
*/
protected $instance;
@ -61,13 +61,13 @@ class EmailFieldTest extends WebTestBase {
function testEmailField() {
// Create a field with settings to validate.
$field_name = drupal_strtolower($this->randomName());
$this->field = entity_create('field_entity', array(
$this->field = entity_create('field_config', array(
'name' => $field_name,
'entity_type' => 'entity_test',
'type' => 'email',
));
$this->field->save();
$this->instance = entity_create('field_instance', array(
$this->instance = entity_create('field_instance_config', array(
'field_name' => $field_name,
'entity_type' => 'entity_test',
'bundle' => 'entity_test',

View File

@ -35,12 +35,12 @@ class EmailItemTest extends FieldUnitTestBase {
parent::setUp();
// Create an email field and instance for validation.
entity_create('field_entity', array(
entity_create('field_config', array(
'name' => 'field_email',
'entity_type' => 'entity_test',
'type' => 'email',
))->save();
entity_create('field_instance', array(
entity_create('field_instance_config', array(
'entity_type' => 'entity_test',
'field_name' => 'field_email',
'bundle' => 'entity_test',

View File

@ -136,13 +136,13 @@ class EntityDisplayTest extends DrupalUnitTestBase {
$field_name = 'test_field';
// Create a field and an instance.
$field = entity_create('field_entity', array(
$field = entity_create('field_config', array(
'name' => $field_name,
'entity_type' => 'entity_test',
'type' => 'test_field'
));
$field->save();
$instance = entity_create('field_instance', array(
$instance = entity_create('field_instance_config', array(
'field_name' => $field_name,
'entity_type' => 'entity_test',
'bundle' => 'entity_test',
@ -303,13 +303,13 @@ class EntityDisplayTest extends DrupalUnitTestBase {
$field_name = 'test_field';
// Create a field and an instance.
$field = entity_create('field_entity', array(
$field = entity_create('field_config', array(
'name' => $field_name,
'entity_type' => 'entity_test',
'type' => 'test_field'
));
$field->save();
$instance = entity_create('field_instance', array(
$instance = entity_create('field_instance_config', array(
'field_name' => $field_name,
'entity_type' => 'entity_test',
'bundle' => 'entity_test',

View File

@ -57,13 +57,13 @@ class EntityFormDisplayTest extends DrupalUnitTestBase {
// Create a field and an instance.
$field_name = 'test_field';
$field = entity_create('field_entity', array(
$field = entity_create('field_config', array(
'name' => $field_name,
'entity_type' => 'entity_test',
'type' => 'test_field'
));
$field->save();
$instance = entity_create('field_instance', array(
$instance = entity_create('field_instance_config', array(
'field_name' => $field_name,
'entity_type' => 'entity_test',
'bundle' => 'entity_test',
@ -185,13 +185,13 @@ class EntityFormDisplayTest extends DrupalUnitTestBase {
$field_name = 'test_field';
// Create a field and an instance.
$field = entity_create('field_entity', array(
$field = entity_create('field_config', array(
'name' => $field_name,
'entity_type' => 'entity_test',
'type' => 'test_field'
));
$field->save();
$instance = entity_create('field_instance', array(
$instance = entity_create('field_instance_config', array(
'field_name' => $field_name,
'entity_type' => 'entity_test',
'bundle' => 'entity_test',

View File

@ -64,11 +64,11 @@ function entity_reference_field_widget_info_alter(&$info) {
}
/**
* Implements hook_ENTITY_TYPE_update() for 'field_entity'.
* Implements hook_ENTITY_TYPE_update() for 'field_config'.
*
* Reset the instance handler settings, when the target type is changed.
*/
function entity_reference_field_entity_update(FieldInterface $field) {
function entity_reference_field_config_update(FieldInterface $field) {
if ($field->type != 'entity_reference') {
// Only act on entity reference fields.
return;
@ -219,7 +219,7 @@ function entity_reference_create_instance($entity_type, $bundle, $field_name, $f
'target_type' => $target_entity_type,
),
);
entity_create('field_entity', $field)->save();
entity_create('field_config', $field)->save();
}
if (empty($instance)) {
@ -233,7 +233,7 @@ function entity_reference_create_instance($entity_type, $bundle, $field_name, $f
'handler_settings' => $selection_handler_settings,
),
);
entity_create('field_instance', $instance)->save();
entity_create('field_instance_config', $instance)->save();
}
}

View File

@ -36,7 +36,7 @@ class EntityReferenceAutoCreateTest extends WebTestBase {
$referenced = $this->drupalCreateContentType();
$this->referenced_type = $referenced->type;
entity_create('field_entity', array(
entity_create('field_config', array(
'name' => 'test_field',
'entity_type' => 'node',
'translatable' => FALSE,
@ -48,7 +48,7 @@ class EntityReferenceAutoCreateTest extends WebTestBase {
'cardinality' => FieldDefinitionInterface::CARDINALITY_UNLIMITED,
))->save();
entity_create('field_instance', array(
entity_create('field_instance_config', array(
'label' => 'Entity reference field',
'field_name' => 'test_field',
'entity_type' => 'node',

View File

@ -48,14 +48,14 @@ class EntityReferenceFieldDefaultValueTest extends WebTestBase {
// Create a node to be referenced.
$referenced_node = $this->drupalCreateNode(array('type' => 'referenced_content'));
$this->field = entity_create('field_entity', array(
$this->field = entity_create('field_config', array(
'name' => drupal_strtolower($this->randomName()),
'entity_type' => 'node',
'type' => 'entity_reference',
'settings' => array('target_type' => 'node'),
));
$this->field->save();
$this->instance = entity_create('field_instance', array(
$this->instance = entity_create('field_instance_config', array(
'field_name' => $this->field->name,
'entity_type' => 'node',
'bundle' => 'reference_content',

View File

@ -61,7 +61,7 @@ class EntityReferenceSelectionAccessTest extends WebTestBase {
*/
public function testNodeHandler() {
// Create a field and instance.
$field = entity_create('field_entity', array(
$field = entity_create('field_config', array(
'name' => 'test_field',
'entity_type' => 'entity_test',
'translatable' => FALSE,
@ -73,7 +73,7 @@ class EntityReferenceSelectionAccessTest extends WebTestBase {
'cardinality' => '1',
));
$field->save();
$instance = entity_create('field_instance', array(
$instance = entity_create('field_instance_config', array(
'field_name' => 'test_field',
'entity_type' => 'entity_test',
'bundle' => 'test_bundle',
@ -205,7 +205,7 @@ class EntityReferenceSelectionAccessTest extends WebTestBase {
*/
public function testUserHandler() {
// Create a field and instance.
$field = entity_create('field_entity', array(
$field = entity_create('field_config', array(
'name' => 'test_field',
'entity_type' => 'entity_test',
'translatable' => FALSE,
@ -216,7 +216,7 @@ class EntityReferenceSelectionAccessTest extends WebTestBase {
'cardinality' => '1',
));
$field->save();
$instance = entity_create('field_instance', array(
$instance = entity_create('field_instance_config', array(
'field_name' => 'test_field',
'entity_type' => 'entity_test',
'bundle' => 'test_bundle',
@ -350,7 +350,7 @@ class EntityReferenceSelectionAccessTest extends WebTestBase {
*/
public function testCommentHandler() {
// Create a field and instance.
$field = entity_create('field_entity', array(
$field = entity_create('field_config', array(
'name' => 'test_field',
'entity_type' => 'entity_test',
'translatable' => FALSE,
@ -362,7 +362,7 @@ class EntityReferenceSelectionAccessTest extends WebTestBase {
'cardinality' => '1',
));
$field->save();
$instance = entity_create('field_instance', array(
$instance = entity_create('field_instance_config', array(
'field_name' => 'test_field',
'entity_type' => 'entity_test',
'bundle' => 'test_bundle',

View File

@ -36,14 +36,14 @@ class EntityReferenceSelectionSortTest extends WebTestBase {
*/
public function testSort() {
// Add text field to entity, to sort by.
entity_create('field_entity', array(
entity_create('field_config', array(
'name' => 'field_text',
'entity_type' => 'node',
'type' => 'text',
'entity_types' => array('node'),
))->save();
entity_create('field_instance', array(
entity_create('field_instance_config', array(
'label' => 'Text Field',
'field_name' => 'field_text',
'entity_type' => 'node',
@ -54,7 +54,7 @@ class EntityReferenceSelectionSortTest extends WebTestBase {
// Create a field and instance.
$field = entity_create('field_entity', array(
$field = entity_create('field_config', array(
'name' => 'test_field',
'entity_type' => 'entity_test',
'translatable' => FALSE,
@ -65,7 +65,7 @@ class EntityReferenceSelectionSortTest extends WebTestBase {
'cardinality' => 1,
));
$field->save();
$instance = entity_create('field_instance', array(
$instance = entity_create('field_instance_config', array(
'field_name' => 'test_field',
'entity_type' => 'entity_test',
'bundle' => 'test_bundle',

View File

@ -40,7 +40,7 @@ class SelectionTest extends WebTestBase {
}
// Create a field and instance.
$field = entity_create('field_entity', array(
$field = entity_create('field_config', array(
'name' => 'test_field',
'entity_type' => 'entity_test',
'translatable' => FALSE,
@ -51,7 +51,7 @@ class SelectionTest extends WebTestBase {
'cardinality' => '1',
));
$field->save();
$instance = entity_create('field_instance', array(
$instance = entity_create('field_instance_config', array(
'field_name' => 'test_field',
'entity_type' => 'entity_test',
'bundle' => 'test_bundle',

View File

@ -159,7 +159,7 @@ function field_system_info_alter(&$info, $file, $type) {
// It is not safe to call entity_load_multiple_by_properties() during
// maintenance mode.
if ($type == 'module' && !defined('MAINTENANCE_MODE')) {
$fields = entity_load_multiple_by_properties('field_entity', array('module' => $file->name, 'include_deleted' => TRUE));
$fields = entity_load_multiple_by_properties('field_config', array('module' => $file->name, 'include_deleted' => TRUE));
if ($fields) {
$info['required'] = TRUE;
@ -226,7 +226,7 @@ function field_entity_bundle_create($entity_type, $bundle) {
* Implements hook_entity_bundle_rename().
*/
function field_entity_bundle_rename($entity_type, $bundle_old, $bundle_new) {
$instances = entity_load_multiple_by_properties('field_instance', array('entity_type' => $entity_type, 'bundle' => $bundle_old));
$instances = entity_load_multiple_by_properties('field_instance_config', array('entity_type' => $entity_type, 'bundle' => $bundle_old));
foreach ($instances as $instance) {
if ($instance->entity_type == $entity_type && $instance->bundle == $bundle_old) {
$id_new = $instance->entity_type . '.' . $bundle_new . '.' . $instance->field_name;
@ -255,7 +255,7 @@ function field_entity_bundle_delete($entity_type, $bundle) {
// Get the instances on the bundle. entity_load_multiple_by_properties() must
// be used here since field_info_instances() does not return instances for
// disabled entity types or bundles.
$instances = entity_load_multiple_by_properties('field_instance', array('entity_type' => $entity_type, 'bundle' => $bundle));
$instances = entity_load_multiple_by_properties('field_instance_config', array('entity_type' => $entity_type, 'bundle' => $bundle));
foreach ($instances as $instance) {
$instance->delete();
}

View File

@ -5,7 +5,7 @@
* Provides support for field data purge after mass deletion.
*/
use Drupal\field\Entity\Field;
use Drupal\field\Entity\FieldConfig;
use Drupal\field\FieldException;
/**
@ -72,7 +72,7 @@ use Drupal\field\FieldException;
function field_purge_batch($batch_size) {
// Retrieve all deleted field instances. We cannot use field_info_instances()
// because that function does not return deleted instances.
$instances = entity_load_multiple_by_properties('field_instance', array('deleted' => TRUE, 'include_deleted' => TRUE));
$instances = entity_load_multiple_by_properties('field_instance_config', array('deleted' => TRUE, 'include_deleted' => TRUE));
$factory = \Drupal::service('entity.query');
$info = \Drupal::entityManager()->getDefinitions();
foreach ($instances as $instance) {
@ -115,7 +115,7 @@ function field_purge_batch($batch_size) {
// Retrieve all deleted fields. Any that have no instances can be purged.
$deleted_fields = \Drupal::state()->get('field.field.deleted') ?: array();
foreach ($deleted_fields as $field) {
$field = new Field($field);
$field = new FieldConfig($field);
// We cannot purge anything if the entity type is unknown (e.g. the
// providing module was uninstalled).
@ -124,7 +124,7 @@ function field_purge_batch($batch_size) {
continue;
}
$instances = entity_load_multiple_by_properties('field_instance', array('field_id' => $field->uuid(), 'include_deleted' => TRUE));
$instances = entity_load_multiple_by_properties('field_instance_config', array('field_id' => $field->uuid(), 'include_deleted' => TRUE));
if (empty($instances)) {
field_purge_field($field);
}
@ -163,7 +163,7 @@ function field_purge_instance($instance) {
* The field record to purge.
*/
function field_purge_field($field) {
$instances = entity_load_multiple_by_properties('field_instance', array('field_id' => $field->uuid(), 'include_deleted' => TRUE));
$instances = entity_load_multiple_by_properties('field_instance_config', array('field_id' => $field->uuid(), 'include_deleted' => TRUE));
if (count($instances) > 0) {
throw new FieldException(t('Attempt to purge a field @field_name that still has instances.', array('@field_name' => $field->getName())));
}

View File

@ -2,7 +2,7 @@
/**
* @file
* Contains \Drupal\field\Entity\Field.
* Contains \Drupal\field\Entity\FieldConfig.
*/
namespace Drupal\field\Entity;
@ -18,14 +18,11 @@ use Drupal\field\FieldInterface;
/**
* Defines the Field entity.
*
* @todo use 'field' as the id once hook_field_load() and friends
* are removed.
*
* @ConfigEntityType(
* id = "field_entity",
* id = "field_config",
* label = @Translation("Field"),
* controllers = {
* "storage" = "Drupal\field\FieldStorageController"
* "storage" = "Drupal\field\FieldConfigStorageController"
* },
* config_prefix = "field.field",
* entity_keys = {
@ -35,7 +32,7 @@ use Drupal\field\FieldInterface;
* }
* )
*/
class Field extends ConfigEntityBase implements FieldInterface {
class FieldConfig extends ConfigEntityBase implements FieldInterface {
/**
* The maximum length of the field name, in characters.
@ -184,13 +181,6 @@ class Field extends ConfigEntityBase implements FieldInterface {
*/
protected $schema;
/**
* The original field.
*
* @var \Drupal\field\Entity\Field
*/
public $original = NULL;
/**
* The data definition of a field item.
*
@ -199,7 +189,7 @@ class Field extends ConfigEntityBase implements FieldInterface {
protected $itemDefinition;
/**
* Constructs a Field object.
* Constructs a FieldConfig object.
*
* @param array $values
* An array of field properties, keyed by property name. Most array
@ -212,14 +202,14 @@ class Field extends ConfigEntityBase implements FieldInterface {
* - type: required.
*
* In most cases, Field entities are created via
* entity_create('field_entity', $values)), where $values is the same
* entity_create('field_config', $values)), where $values is the same
* parameter as in this constructor.
*
* @see entity_create()
*
* @ingroup field_crud
*/
public function __construct(array $values, $entity_type = 'field_entity') {
public function __construct(array $values, $entity_type = 'field_config') {
// Check required properties.
if (empty($values['name'])) {
throw new FieldException('Attempt to create an unnamed field.');
@ -304,8 +294,8 @@ class Field extends ConfigEntityBase implements FieldInterface {
// Assign the ID.
$this->id = $this->id();
// Field name cannot be longer than Field::NAME_MAX_LENGTH characters. We
// use Unicode::strlen() because the DB layer assumes that column widths
// Field name cannot be longer than FieldConfig::NAME_MAX_LENGTH characters.
// We use Unicode::strlen() because the DB layer assumes that column widths
// are given in characters rather than bytes.
if (Unicode::strlen($this->name) > static::NAME_MAX_LENGTH) {
throw new FieldException(format_string(
@ -386,10 +376,10 @@ class Field extends ConfigEntityBase implements FieldInterface {
*/
public static function preDelete(EntityStorageControllerInterface $storage_controller, array $fields) {
$state = \Drupal::state();
$instance_controller = \Drupal::entityManager()->getStorageController('field_instance');
$instance_controller = \Drupal::entityManager()->getStorageController('field_instance_config');
// Delete instances first. Note: when deleting a field through
// FieldInstance::postDelete(), the instances have been deleted already, so
// FieldInstanceConfig::postDelete(), the instances have been deleted already, so
// no instances will be found here.
$instance_ids = array();
foreach ($fields as $field) {
@ -563,8 +553,7 @@ class Field extends ConfigEntityBase implements FieldInterface {
* @param bool $translatable
* Whether the field is translatable.
*
* @return \Drupal\field\Entity\Field
* The object itself for chaining.
* @return $this
*/
public function setTranslatable($translatable) {
$this->translatable = $translatable;

View File

@ -2,7 +2,7 @@
/**
* @file
* Contains \Drupal\field\Entity\FieldInstance.
* Contains \Drupal\field\Entity\FieldInstanceConfig.
*/
namespace Drupal\field\Entity;
@ -18,10 +18,10 @@ use Drupal\field\FieldInstanceInterface;
* Defines the Field instance entity.
*
* @ConfigEntityType(
* id = "field_instance",
* id = "field_instance_config",
* label = @Translation("Field instance"),
* controllers = {
* "storage" = "Drupal\field\FieldInstanceStorageController"
* "storage" = "Drupal\field\FieldInstanceConfigStorageController"
* },
* config_prefix = "field.instance",
* entity_keys = {
@ -31,7 +31,7 @@ use Drupal\field\FieldInstanceInterface;
* }
* )
*/
class FieldInstance extends ConfigEntityBase implements FieldInstanceInterface {
class FieldInstanceConfig extends ConfigEntityBase implements FieldInstanceInterface {
/**
* The instance ID.
@ -162,9 +162,9 @@ class FieldInstance extends ConfigEntityBase implements FieldInstanceInterface {
* The function will be called with the following arguments:
* - \Drupal\Core\Entity\EntityInterface $entity
* The entity being created.
* - \Drupal\field\Entity\Field $field
* - \Drupal\field\Entity\FieldConfig $field
* The field object.
* - \Drupal\field\Entity\FieldInstance $instance
* - \Drupal\field\Entity\FieldInstanceConfig $instance
* The field instance object.
* - string $langcode
* The language of the entity being created.
@ -196,7 +196,7 @@ class FieldInstance extends ConfigEntityBase implements FieldInstanceInterface {
/**
* The field ConfigEntity object corresponding to $field_uuid.
*
* @var \Drupal\field\Entity\Field
* @var \Drupal\field\Entity\FieldConfig
*/
protected $field;
@ -207,13 +207,6 @@ class FieldInstance extends ConfigEntityBase implements FieldInstanceInterface {
*/
protected $bundle_rename_allowed = FALSE;
/**
* The original instance.
*
* @var \Drupal\field\Entity\FieldInstance
*/
public $original = NULL;
/**
* The data definition of a field item.
*
@ -222,7 +215,7 @@ class FieldInstance extends ConfigEntityBase implements FieldInstanceInterface {
protected $itemDefinition;
/**
* Constructs a FieldInstance object.
* Constructs a FieldInstanceConfig object.
*
* @param array $values
* An array of field instance properties, keyed by property name. Most
@ -238,14 +231,14 @@ class FieldInstance extends ConfigEntityBase implements FieldInstanceInterface {
* - bundle: required.
*
* In most cases, Field instance entities are created via
* entity_create('field_instance', $values), where $values is the same
* entity_create('field_instance_config', $values), where $values is the same
* parameter as in this constructor.
*
* @see entity_create()
*
* @ingroup field_crud
*/
public function __construct(array $values, $entity_type = 'field_instance') {
public function __construct(array $values, $entity_type = 'field_instance_config') {
// Field instances configuration is stored with a 'field_uuid' property
// unambiguously identifying the field.
if (isset($values['field_uuid'])) {
@ -400,7 +393,7 @@ class FieldInstance extends ConfigEntityBase implements FieldInstanceInterface {
* {@inheritdoc}
*/
public static function postDelete(EntityStorageControllerInterface $storage_controller, array $instances) {
$field_controller = \Drupal::entityManager()->getStorageController('field_entity');
$field_controller = \Drupal::entityManager()->getStorageController('field_config');
// Clear the cache upfront, to refresh the results of getBundles().
field_cache_clear();

View File

@ -2,7 +2,7 @@
/**
* @file
* Contains \Drupal\field\FieldStorageController.
* Contains \Drupal\field\FieldConfigStorageController.
*/
namespace Drupal\field;
@ -22,7 +22,7 @@ use Drupal\Core\KeyValueStore\StateInterface;
/**
* Controller class for fields.
*/
class FieldStorageController extends ConfigStorageController {
class FieldConfigStorageController extends ConfigStorageController {
/**
* The module handler.
@ -46,7 +46,7 @@ class FieldStorageController extends ConfigStorageController {
protected $state;
/**
* Constructs a FieldStorageController object.
* Constructs a FieldConfigStorageController object.
*
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
* The entity type definition.

View File

@ -230,7 +230,7 @@ class FieldInfo {
}
else {
// Collect and prepare fields.
foreach (entity_load_multiple_by_properties('field_entity', array('include_deleted' => TRUE)) as $field) {
foreach (entity_load_multiple_by_properties('field_config', array('include_deleted' => TRUE)) as $field) {
$this->fieldsById[$field->uuid()] = $this->prepareField($field);
}
@ -276,7 +276,7 @@ class FieldInfo {
// be set by subsequent getBundleInstances() calls.
$this->getFields();
foreach (entity_load_multiple('field_instance') as $instance) {
foreach (entity_load_multiple('field_instance_config') as $instance) {
$instance = $this->prepareInstance($instance);
$this->bundleInstances[$instance->entity_type][$instance->bundle][$instance->getName()] = $instance;
}
@ -322,7 +322,7 @@ class FieldInfo {
// Do not check the (large) persistent cache, but read the definition.
// Cache miss: read from definition.
if ($field = entity_load('field_entity', $entity_type . '.' . $field_name)) {
if ($field = entity_load('field_config', $entity_type . '.' . $field_name)) {
$field = $this->prepareField($field);
// Save in the "static" cache.
@ -358,7 +358,7 @@ class FieldInfo {
// bundle.
// Cache miss: read from definition.
if ($fields = entity_load_multiple_by_properties('field_entity', array('uuid' => $field_id, 'include_deleted' => TRUE))) {
if ($fields = entity_load_multiple_by_properties('field_config', array('uuid' => $field_id, 'include_deleted' => TRUE))) {
$field = current($fields);
$field = $this->prepareField($field);
@ -451,7 +451,7 @@ class FieldInfo {
// Load and prepare the corresponding fields and instances entities.
if ($config_ids) {
// Place the fields in our global "static".
$loaded_fields = entity_load_multiple('field_entity', array_keys($config_ids));
$loaded_fields = entity_load_multiple('field_config', array_keys($config_ids));
foreach ($loaded_fields as $field) {
if (!isset($this->fieldsById[$field->uuid()])) {
$field = $this->prepareField($field);
@ -464,7 +464,7 @@ class FieldInfo {
}
// Then collect the instances.
$loaded_instances = entity_load_multiple('field_instance', array_values($config_ids));
$loaded_instances = entity_load_multiple('field_instance_config', array_values($config_ids));
foreach ($loaded_instances as $instance) {
$instance = $this->prepareInstance($instance);
$instances[$instance->getName()] = $instance;

View File

@ -2,7 +2,7 @@
/**
* @file
* Contains \Drupal\field\FieldInstanceStorageController.
* Contains \Drupal\field\FieldInstanceConfigStorageController.
*/
namespace Drupal\field;
@ -27,7 +27,7 @@ use Drupal\Core\KeyValueStore\StateInterface;
* (field.field.* entries are processed before field.instance.* entries).
* @todo Revisit after http://drupal.org/node/1944368.
*/
class FieldInstanceStorageController extends ConfigStorageController {
class FieldInstanceConfigStorageController extends ConfigStorageController {
/**
* The entity manager.
@ -44,7 +44,7 @@ class FieldInstanceStorageController extends ConfigStorageController {
protected $state;
/**
* Constructs a FieldInstanceStorageController object.
* Constructs a FieldInstanceConfigStorageController object.
*
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
* The entity type definition.

View File

@ -113,7 +113,7 @@ class BulkDeleteTest extends FieldUnitTestBase {
}
// Create two fields.
$field = entity_create('field_entity', array(
$field = entity_create('field_config', array(
'name' => 'bf_1',
'entity_type' => $this->entity_type,
'type' => 'test_field',
@ -121,7 +121,7 @@ class BulkDeleteTest extends FieldUnitTestBase {
));
$field->save();
$this->fields[] = $field;
$field = entity_create('field_entity', array(
$field = entity_create('field_config', array(
'name' => 'bf_2',
'entity_type' => $this->entity_type,
'type' => 'test_field',
@ -134,7 +134,7 @@ class BulkDeleteTest extends FieldUnitTestBase {
// entities with values for each field.
foreach ($this->bundles as $bundle) {
foreach ($this->fields as $field) {
entity_create('field_instance', array(
entity_create('field_instance_config', array(
'field_name' => $field->name,
'entity_type' => $this->entity_type,
'bundle' => $bundle,
@ -180,7 +180,7 @@ class BulkDeleteTest extends FieldUnitTestBase {
$instance->delete();
// The instance still exists, deleted.
$instances = entity_load_multiple_by_properties('field_instance', array('field_id' => $field->uuid, 'deleted' => TRUE, 'include_deleted' => TRUE));
$instances = entity_load_multiple_by_properties('field_instance_config', array('field_id' => $field->uuid, 'deleted' => TRUE, 'include_deleted' => TRUE));
$this->assertEqual(count($instances), 1, 'There is one deleted instance');
$instance = $instances[0];
$this->assertEqual($instance->bundle, $bundle, 'The deleted instance is for the correct bundle');
@ -247,7 +247,7 @@ class BulkDeleteTest extends FieldUnitTestBase {
}
// Check hooks invocations.
// hook_field_delete() should have been called once for each entity in the
// FieldItemInterface::delete() should have been called once for each entity in the
// bundle.
$actual_hooks = field_test_memorize();
$hooks = array();
@ -258,18 +258,18 @@ class BulkDeleteTest extends FieldUnitTestBase {
$this->checkHooksInvocations($hooks, $actual_hooks);
// The instance still exists, deleted.
$instances = entity_load_multiple_by_properties('field_instance', array('field_id' => $field->uuid, 'deleted' => TRUE, 'include_deleted' => TRUE));
$instances = entity_load_multiple_by_properties('field_instance_config', array('field_id' => $field->uuid, 'deleted' => TRUE, 'include_deleted' => TRUE));
$this->assertEqual(count($instances), 1, 'There is one deleted instance');
// Purge the instance.
field_purge_batch($batch_size);
// The instance is gone.
$instances = entity_load_multiple_by_properties('field_instance', array('field_id' => $field->uuid, 'deleted' => TRUE, 'include_deleted' => TRUE));
$instances = entity_load_multiple_by_properties('field_instance_config', array('field_id' => $field->uuid, 'deleted' => TRUE, 'include_deleted' => TRUE));
$this->assertEqual(count($instances), 0, 'The instance is gone');
// The field still exists, not deleted, because it has a second instance.
$fields = entity_load_multiple_by_properties('field_entity', array('uuid' => $field->uuid, 'include_deleted' => TRUE));
$fields = entity_load_multiple_by_properties('field_config', array('uuid' => $field->uuid, 'include_deleted' => TRUE));
$this->assertTrue(isset($fields[$field->uuid]), 'The field exists and is not deleted');
}
@ -288,7 +288,7 @@ class BulkDeleteTest extends FieldUnitTestBase {
$instance = field_info_instance($this->entity_type, $field->name, $bundle);
$instance->delete();
// Assert that hook_field_delete() was not called yet.
// Assert that FieldItemInterface::delete() was not called yet.
$mem = field_test_memorize();
$this->assertEqual(count($mem), 0, 'No field hooks were called.');
@ -296,7 +296,7 @@ class BulkDeleteTest extends FieldUnitTestBase {
field_purge_batch(10);
// Check hooks invocations.
// hook_field_delete() should have been called once for each entity in the
// FieldItemInterface::delete() should have been called once for each entity in the
// bundle.
$actual_hooks = field_test_memorize();
$hooks = array();
@ -310,7 +310,7 @@ class BulkDeleteTest extends FieldUnitTestBase {
field_purge_batch(0);
// The field still exists, not deleted.
$fields = entity_load_multiple_by_properties('field_entity', array('uuid' => $field->uuid, 'include_deleted' => TRUE));
$fields = entity_load_multiple_by_properties('field_config', array('uuid' => $field->uuid, 'include_deleted' => TRUE));
$this->assertTrue(isset($fields[$field->uuid]) && !$fields[$field->uuid]->deleted, 'The field exists and is not deleted');
// Delete the second instance.
@ -318,7 +318,7 @@ class BulkDeleteTest extends FieldUnitTestBase {
$instance = field_info_instance($this->entity_type, $field->name, $bundle);
$instance->delete();
// Assert that hook_field_delete() was not called yet.
// Assert that FieldItemInterface::delete() was not called yet.
$mem = field_test_memorize();
$this->assertEqual(count($mem), 0, 'No field hooks were called.');
@ -335,14 +335,14 @@ class BulkDeleteTest extends FieldUnitTestBase {
$this->checkHooksInvocations($hooks, $actual_hooks);
// The field still exists, deleted.
$fields = entity_load_multiple_by_properties('field_entity', array('uuid' => $field->uuid, 'include_deleted' => TRUE));
$fields = entity_load_multiple_by_properties('field_config', array('uuid' => $field->uuid, 'include_deleted' => TRUE));
$this->assertTrue(isset($fields[$field->uuid]) && $fields[$field->uuid]->deleted, 'The field exists and is deleted');
// Purge again to purge the instance and the field.
field_purge_batch(0);
// The field is gone.
$fields = entity_load_multiple_by_properties('field_entity', array('uuid' => $field->uuid, 'include_deleted' => TRUE));
$fields = entity_load_multiple_by_properties('field_config', array('uuid' => $field->uuid, 'include_deleted' => TRUE));
$this->assertEqual(count($fields), 0, 'The field is purged.');
}

View File

@ -42,11 +42,11 @@ class CrudTest extends FieldUnitTestBase {
'type' => 'test_field',
);
field_test_memorize();
$field = entity_create('field_entity', $field_definition);
$field = entity_create('field_config', $field_definition);
$field->save();
$mem = field_test_memorize();
$this->assertIdentical($mem['field_test_field_entity_create'][0][0]->getName(), $field_definition['name'], 'hook_entity_create() called with correct arguments.');
$this->assertIdentical($mem['field_test_field_entity_create'][0][0]->getType(), $field_definition['type'], 'hook_entity_create() called with correct arguments.');
$this->assertIdentical($mem['field_test_field_config_create'][0][0]->getName(), $field_definition['name'], 'hook_entity_create() called with correct arguments.');
$this->assertIdentical($mem['field_test_field_config_create'][0][0]->getType(), $field_definition['type'], 'hook_entity_create() called with correct arguments.');
// Read the configuration. Check against raw configuration data rather than
// the loaded ConfigEntity, to be sure we check that the defaults are
@ -68,7 +68,7 @@ class CrudTest extends FieldUnitTestBase {
// Guarantee that the name is unique.
try {
entity_create('field_entity', $field_definition)->save();
entity_create('field_config', $field_definition)->save();
$this->fail(t('Cannot create two fields with the same name.'));
}
catch (EntityStorageException $e) {
@ -81,7 +81,7 @@ class CrudTest extends FieldUnitTestBase {
'name' => 'field_1',
'entity_type' => 'entity_type',
);
entity_create('field_entity', $field_definition)->save();
entity_create('field_config', $field_definition)->save();
$this->fail(t('Cannot create a field with no type.'));
}
catch (FieldException $e) {
@ -94,7 +94,7 @@ class CrudTest extends FieldUnitTestBase {
'type' => 'test_field',
'entity_type' => 'entity_test',
);
entity_create('field_entity', $field_definition)->save();
entity_create('field_config', $field_definition)->save();
$this->fail(t('Cannot create an unnamed field.'));
}
catch (FieldException $e) {
@ -106,7 +106,7 @@ class CrudTest extends FieldUnitTestBase {
'name' => 'test_field',
'type' => 'test_field'
);
entity_create('field_entity', $field_definition)->save();
entity_create('field_config', $field_definition)->save();
$this->fail('Cannot create a field without an entity type.');
}
catch (FieldException $e) {
@ -120,7 +120,7 @@ class CrudTest extends FieldUnitTestBase {
'entity_type' => 'entity_test',
'type' => 'test_field',
);
entity_create('field_entity', $field_definition)->save();
entity_create('field_config', $field_definition)->save();
$this->fail(t('Cannot create a field with a name starting with a digit.'));
}
catch (FieldException $e) {
@ -134,7 +134,7 @@ class CrudTest extends FieldUnitTestBase {
'entity_type' => 'entity_test',
'type' => 'test_field',
);
entity_create('field_entity', $field_definition)->save();
entity_create('field_config', $field_definition)->save();
$this->fail(t('Cannot create a field with a name containing an illegal character.'));
}
catch (FieldException $e) {
@ -148,7 +148,7 @@ class CrudTest extends FieldUnitTestBase {
'entity_type' => 'entity_test',
'type' => 'test_field',
);
entity_create('field_entity', $field_definition)->save();
entity_create('field_config', $field_definition)->save();
$this->fail(t('Cannot create a field with a name longer than 32 characters.'));
}
catch (FieldException $e) {
@ -163,7 +163,7 @@ class CrudTest extends FieldUnitTestBase {
'name' => 'id',
'entity_type' => 'entity_test',
);
entity_create('field_entity', $field_definition)->save();
entity_create('field_config', $field_definition)->save();
$this->fail(t('Cannot create a field bearing the name of an entity key.'));
}
catch (FieldException $e) {
@ -186,7 +186,7 @@ class CrudTest extends FieldUnitTestBase {
'dummy' => 'foobar'
),
);
$field = entity_create('field_entity', $field_definition);
$field = entity_create('field_config', $field_definition);
$this->assertEqual($field->getSchema(), $field_definition['schema']);
}
@ -199,18 +199,18 @@ class CrudTest extends FieldUnitTestBase {
'entity_type' => 'entity_test',
'type' => 'test_field',
);
$field = entity_create('field_entity', $field_definition);
$field = entity_create('field_config', $field_definition);
$field->save();
$id = $field->id();
// Check that 'single column' criteria works.
$fields = entity_load_multiple_by_properties('field_entity', array('field_name' => $field_definition['name']));
$fields = entity_load_multiple_by_properties('field_config', array('field_name' => $field_definition['name']));
$this->assertTrue(count($fields) == 1 && isset($fields[$id]), 'The field was properly read.');
// Check that 'multi column' criteria works.
$fields = entity_load_multiple_by_properties('field_entity', array('field_name' => $field_definition['name'], 'type' => $field_definition['type']));
$fields = entity_load_multiple_by_properties('field_config', array('field_name' => $field_definition['name'], 'type' => $field_definition['type']));
$this->assertTrue(count($fields) == 1 && isset($fields[$id]), 'The field was properly read.');
$fields = entity_load_multiple_by_properties('field_entity', array('field_name' => $field_definition['name'], 'type' => 'foo'));
$fields = entity_load_multiple_by_properties('field_config', array('field_name' => $field_definition['name'], 'type' => 'foo'));
$this->assertTrue(empty($fields), 'No field was found.');
// Create an instance of the field.
@ -219,7 +219,7 @@ class CrudTest extends FieldUnitTestBase {
'entity_type' => 'entity_test',
'bundle' => 'entity_test',
);
entity_create('field_instance', $instance_definition)->save();
entity_create('field_instance_config', $instance_definition)->save();
}
/**
@ -232,10 +232,10 @@ class CrudTest extends FieldUnitTestBase {
'entity_type' => 'entity_test',
'type' => 'test_field',
);
$field = entity_create('field_entity', $field_definition);
$field = entity_create('field_config', $field_definition);
$field->save();
field_cache_clear();
$field = entity_load('field_entity', $field->id());
$field = entity_load('field_config', $field->id());
$schema = $field->getSchema();
$expected_indexes = array('value' => array('value'));
$this->assertEqual($schema['indexes'], $expected_indexes, 'Field type indexes saved by default');
@ -250,10 +250,10 @@ class CrudTest extends FieldUnitTestBase {
'value' => array(),
),
);
$field = entity_create('field_entity', $field_definition);
$field = entity_create('field_config', $field_definition);
$field->save();
field_cache_clear();
$field = entity_load('field_entity', $field->id());
$field = entity_load('field_config', $field->id());
$schema = $field->getSchema();
$expected_indexes = array('value' => array());
$this->assertEqual($schema['indexes'], $expected_indexes, 'Field definition indexes override field type indexes');
@ -268,11 +268,11 @@ class CrudTest extends FieldUnitTestBase {
'value_2' => array('value'),
),
);
$field = entity_create('field_entity', $field_definition);
$field = entity_create('field_config', $field_definition);
$field->save();
$id = $field->id();
field_cache_clear();
$field = entity_load('field_entity', $id);
$field = entity_load('field_config', $id);
$schema = $field->getSchema();
$expected_indexes = array('value' => array('value'), 'value_2' => array('value'));
$this->assertEqual($schema['indexes'], $expected_indexes, 'Field definition indexes are merged with field type indexes');
@ -290,13 +290,13 @@ class CrudTest extends FieldUnitTestBase {
'type' => 'test_field',
'entity_type' => 'entity_test',
);
entity_create('field_entity', $this->field)->save();
entity_create('field_config', $this->field)->save();
$this->another_field = array(
'name' => 'field_2',
'type' => 'test_field',
'entity_type' => 'entity_test',
);
entity_create('field_entity', $this->another_field)->save();
entity_create('field_config', $this->another_field)->save();
// Create instances for each.
$this->instance_definition = array(
@ -304,47 +304,47 @@ class CrudTest extends FieldUnitTestBase {
'entity_type' => 'entity_test',
'bundle' => 'entity_test',
);
entity_create('field_instance', $this->instance_definition)->save();
entity_create('field_instance_config', $this->instance_definition)->save();
$another_instance_definition = $this->instance_definition;
$another_instance_definition['field_name'] = $this->another_field['name'];
entity_create('field_instance', $another_instance_definition)->save();
entity_create('field_instance_config', $another_instance_definition)->save();
// Test that the first field is not deleted, and then delete it.
$field = current(entity_load_multiple_by_properties('field_entity', array('field_name' => $this->field['name'], 'include_deleted' => TRUE)));
$field = current(entity_load_multiple_by_properties('field_config', array('field_name' => $this->field['name'], 'include_deleted' => TRUE)));
$this->assertTrue(!empty($field) && empty($field->deleted), 'A new field is not marked for deletion.');
field_info_field('entity_test', $this->field['name'])->delete();
// Make sure that the field is marked as deleted when it is specifically
// loaded.
$field = current(entity_load_multiple_by_properties('field_entity', array('field_name' => $this->field['name'], 'include_deleted' => TRUE)));
$field = current(entity_load_multiple_by_properties('field_config', array('field_name' => $this->field['name'], 'include_deleted' => TRUE)));
$this->assertTrue(!empty($field->deleted), 'A deleted field is marked for deletion.');
// Make sure that this field's instance is marked as deleted when it is
// specifically loaded.
$instance = current(entity_load_multiple_by_properties('field_instance', array('entity_type' => 'entity_test', 'field_name' => $this->instance_definition['field_name'], 'bundle' => $this->instance_definition['bundle'], 'include_deleted' => TRUE)));
$instance = current(entity_load_multiple_by_properties('field_instance_config', array('entity_type' => 'entity_test', 'field_name' => $this->instance_definition['field_name'], 'bundle' => $this->instance_definition['bundle'], 'include_deleted' => TRUE)));
$this->assertTrue(!empty($instance->deleted), 'An instance for a deleted field is marked for deletion.');
// Try to load the field normally and make sure it does not show up.
$field = entity_load('field_entity', 'entity_test.' . $this->field['name']);
$field = entity_load('field_config', 'entity_test.' . $this->field['name']);
$this->assertTrue(empty($field), 'A deleted field is not loaded by default.');
// Try to load the instance normally and make sure it does not show up.
$instance = entity_load('field_instance', 'entity_test.' . '.' . $this->instance_definition['bundle'] . '.' . $this->instance_definition['field_name']);
$instance = entity_load('field_instance_config', 'entity_test.' . '.' . $this->instance_definition['bundle'] . '.' . $this->instance_definition['field_name']);
$this->assertTrue(empty($instance), 'An instance for a deleted field is not loaded by default.');
// Make sure the other field (and its field instance) are not deleted.
$another_field = entity_load('field_entity', 'entity_test.' . $this->another_field['name']);
$another_field = entity_load('field_config', 'entity_test.' . $this->another_field['name']);
$this->assertTrue(!empty($another_field) && empty($another_field->deleted), 'A non-deleted field is not marked for deletion.');
$another_instance = entity_load('field_instance', 'entity_test.' . $another_instance_definition['bundle'] . '.' . $another_instance_definition['field_name']);
$another_instance = entity_load('field_instance_config', 'entity_test.' . $another_instance_definition['bundle'] . '.' . $another_instance_definition['field_name']);
$this->assertTrue(!empty($another_instance) && empty($another_instance->deleted), 'An instance of a non-deleted field is not marked for deletion.');
// Try to create a new field the same name as a deleted field and
// write data into it.
entity_create('field_entity', $this->field)->save();
entity_create('field_instance', $this->instance_definition)->save();
$field = entity_load('field_entity', 'entity_test.' . $this->field['name']);
entity_create('field_config', $this->field)->save();
entity_create('field_instance_config', $this->instance_definition)->save();
$field = entity_load('field_config', 'entity_test.' . $this->field['name']);
$this->assertTrue(!empty($field) && empty($field->deleted), 'A new field with a previously used name is created.');
$instance = entity_load('field_instance', 'entity_test.' . $this->instance_definition['bundle'] . '.' . $this->instance_definition['field_name'] );
$instance = entity_load('field_instance_config', 'entity_test.' . $this->instance_definition['bundle'] . '.' . $this->instance_definition['field_name'] );
$this->assertTrue(!empty($instance) && empty($instance->deleted), 'A new instance for a previously used field name is created.');
// Save an entity with data for the field
@ -366,7 +366,7 @@ class CrudTest extends FieldUnitTestBase {
'entity_type' => 'entity_test',
'type' => 'number_decimal',
);
$field = entity_create('field_entity', $field_definition);
$field = entity_create('field_config', $field_definition);
$field->save();
try {
@ -387,14 +387,14 @@ class CrudTest extends FieldUnitTestBase {
// respected. Since cardinality enforcement is consistent across database
// systems, it makes a good test case.
$cardinality = 4;
$field = entity_create('field_entity', array(
$field = entity_create('field_config', array(
'name' => 'field_update',
'entity_type' => 'entity_test',
'type' => 'test_field',
'cardinality' => $cardinality,
));
$field->save();
$instance = entity_create('field_instance', array(
$instance = entity_create('field_instance_config', array(
'field_name' => 'field_update',
'entity_type' => 'entity_test',
'bundle' => 'entity_test',
@ -425,7 +425,7 @@ class CrudTest extends FieldUnitTestBase {
* Test field type modules forbidding an update.
*/
function testUpdateFieldForbid() {
$field = entity_create('field_entity', array(
$field = entity_create('field_config', array(
'name' => 'forbidden',
'entity_type' => 'entity_test',
'type' => 'test_field',

View File

@ -97,8 +97,8 @@ class DisplayApiTest extends FieldUnitTestBase {
),
);
entity_create('field_entity', $field)->save();
entity_create('field_instance', $instance)->save();
entity_create('field_config', $field)->save();
entity_create('field_instance_config', $instance)->save();
// Create a display for the default view mode.
entity_get_display($instance['entity_type'], $instance['bundle'], 'default')
->setComponent($this->field_name, $this->display_options['default'])

View File

@ -56,13 +56,13 @@ class FieldAccessTest extends FieldTestBase {
'entity_type' => 'node',
'type' => 'text',
);
entity_create('field_entity', $field)->save();
entity_create('field_config', $field)->save();
$instance = array(
'field_name' => $field['name'],
'entity_type' => 'node',
'bundle' => $content_type,
);
entity_create('field_instance', $instance)->save();
entity_create('field_instance_config', $instance)->save();
// Assign display properties for the 'default' and 'teaser' view modes.
foreach (array('default', 'teaser') as $view_mode) {

View File

@ -15,7 +15,7 @@ class FieldAttachStorageTest extends FieldUnitTestBase {
/**
* The field instance.
*
* @var \Drupal\field\Entity\FieldInstance
* @var \Drupal\field\Entity\FieldInstanceConfig
*/
protected $instance;
@ -121,7 +121,7 @@ class FieldAttachStorageTest extends FieldUnitTestBase {
);
for ($i = 1; $i <= 3; $i++) {
$field_names[$i] = 'field_' . $i;
$field = entity_create('field_entity', array(
$field = entity_create('field_config', array(
'name' => $field_names[$i],
'entity_type' => $entity_type,
'type' => 'test_field',
@ -129,7 +129,7 @@ class FieldAttachStorageTest extends FieldUnitTestBase {
$field->save();
$field_ids[$i] = $field->uuid();
foreach ($field_bundles_map[$i] as $bundle) {
entity_create('field_instance', array(
entity_create('field_instance_config', array(
'field_name' => $field_names[$i],
'entity_type' => $entity_type,
'bundle' => $bundles[$bundle],
@ -314,7 +314,7 @@ class FieldAttachStorageTest extends FieldUnitTestBase {
// Add an instance to that bundle.
$this->instance_definition['bundle'] = $new_bundle;
entity_create('field_instance', $this->instance_definition)->save();
entity_create('field_instance_config', $this->instance_definition)->save();
// Save an entity with data in the field.
$entity = entity_create($entity_type, array('type' => $this->instance->bundle));
@ -353,7 +353,7 @@ class FieldAttachStorageTest extends FieldUnitTestBase {
// Add an instance to that bundle.
$this->instance_definition['bundle'] = $new_bundle;
entity_create('field_instance', $this->instance_definition)->save();
entity_create('field_instance_config', $this->instance_definition)->save();
// Create a second field for the test bundle
$field_name = drupal_strtolower($this->randomName() . '_field_name');
@ -363,7 +363,7 @@ class FieldAttachStorageTest extends FieldUnitTestBase {
'type' => 'test_field',
'cardinality' => 1,
);
entity_create('field_entity', $field)->save();
entity_create('field_config', $field)->save();
$instance = array(
'field_name' => $field_name,
'entity_type' => $entity_type,
@ -372,7 +372,7 @@ class FieldAttachStorageTest extends FieldUnitTestBase {
'description' => $this->randomName() . '_description',
'weight' => mt_rand(0, 127),
);
entity_create('field_instance', $instance)->save();
entity_create('field_instance_config', $instance)->save();
// Save an entity with data for both fields
$entity = entity_create($entity_type, array('type' => $this->instance->bundle));
@ -397,8 +397,8 @@ class FieldAttachStorageTest extends FieldUnitTestBase {
$this->assertTrue(empty($entity->{$field_name}), 'No data for second field');
// Verify that the instances are gone.
$this->assertFalse(entity_load('field_instance', 'entity_test.' . $this->instance->bundle . '.' . $this->field_name), "First field is deleted");
$this->assertFalse(entity_load('field_instance', 'entity_test.' . $instance['bundle']. '.' . $field_name), "Second field is deleted");
$this->assertFalse(entity_load('field_instance_config', 'entity_test.' . $this->instance->bundle . '.' . $this->field_name), "First field is deleted");
$this->assertFalse(entity_load('field_instance_config', 'entity_test.' . $instance['bundle']. '.' . $field_name), "Second field is deleted");
}
}

View File

@ -51,7 +51,7 @@ class FieldImportChangeTest extends FieldUnitTestBase {
$this->configImporter()->import();
// Check that the updated config was correctly imported.
$instance = entity_load('field_instance', $instance_id);
$instance = entity_load('field_instance_config', $instance_id);
$this->assertEqual($instance->getLabel(), $new_label, 'Instance label updated');
}
}

View File

@ -35,11 +35,11 @@ class FieldImportCreateTest extends FieldUnitTestBase {
$instance_id_2b = "entity_test.test_bundle.$field_name_2";
// Check that the fields and instances do not exist yet.
$this->assertFalse(entity_load('field_entity', $field_id));
$this->assertFalse(entity_load('field_instance', $instance_id));
$this->assertFalse(entity_load('field_entity', $field_id_2));
$this->assertFalse(entity_load('field_instance', $instance_id_2a));
$this->assertFalse(entity_load('field_instance', $instance_id_2b));
$this->assertFalse(entity_load('field_config', $field_id));
$this->assertFalse(entity_load('field_instance_config', $instance_id));
$this->assertFalse(entity_load('field_config', $field_id_2));
$this->assertFalse(entity_load('field_instance_config', $instance_id_2a));
$this->assertFalse(entity_load('field_instance_config', $instance_id_2b));
// Create a second bundle for the 'Entity test' entity type.
entity_test_create_bundle('test_bundle');
@ -49,13 +49,13 @@ class FieldImportCreateTest extends FieldUnitTestBase {
\Drupal::moduleHandler()->install(array('field_test_config'));
// A field with one instance.
$field = entity_load('field_entity', $field_id);
$field = entity_load('field_config', $field_id);
$this->assertTrue($field, 'The field was created.');
$instance = entity_load('field_instance', $instance_id);
$instance = entity_load('field_instance_config', $instance_id);
$this->assertTrue($instance, 'The field instance was deleted.');
// A field with multiple instances.
$field_2 = entity_load('field_entity', $field_id_2);
$field_2 = entity_load('field_config', $field_id_2);
$this->assertTrue($field_2, 'The second field was created.');
$this->assertTrue($instance->bundle, 'test_bundle', 'The second field instance was created on bundle test_bundle.');
$this->assertTrue($instance->bundle, 'test_bundle_2', 'The second field instance was created on bundle test_bundle_2.');
@ -106,15 +106,15 @@ class FieldImportCreateTest extends FieldUnitTestBase {
$this->configImporter()->import();
// Check that the field and instance were created.
$field = entity_load('field_entity', $field_id);
$field = entity_load('field_config', $field_id);
$this->assertTrue($field, 'Test import field from staging exists');
$instance = entity_load('field_instance', $instance_id);
$instance = entity_load('field_instance_config', $instance_id);
$this->assertTrue($instance, 'Test import field instance from staging exists');
$field = entity_load('field_entity', $field_id_2);
$field = entity_load('field_config', $field_id_2);
$this->assertTrue($field, 'Test import field 2 from staging exists');
$instance = entity_load('field_instance', $instance_id_2a);
$instance = entity_load('field_instance_config', $instance_id_2a);
$this->assertTrue($instance, 'Test import field instance 2a from staging exists');
$instance = entity_load('field_instance', $instance_id_2b);
$instance = entity_load('field_instance_config', $instance_id_2b);
$this->assertTrue($instance, 'Test import field instance 2b from staging exists');
}
}

View File

@ -51,8 +51,8 @@ class FieldImportDeleteTest extends FieldUnitTestBase {
$this->installConfig(array('field_test_config'));
// Get the uuid's for the fields.
$field_uuid = entity_load('field_entity', $field_id)->uuid();
$field_uuid_2 = entity_load('field_entity', $field_id_2)->uuid();
$field_uuid = entity_load('field_config', $field_id)->uuid();
$field_uuid_2 = entity_load('field_config', $field_id_2)->uuid();
$active = $this->container->get('config.storage');
$staging = $this->container->get('config.storage.staging');
@ -67,15 +67,15 @@ class FieldImportDeleteTest extends FieldUnitTestBase {
$this->configImporter()->import();
// Check that the fields and instances are gone.
$field = entity_load('field_entity', $field_id, TRUE);
$field = entity_load('field_config', $field_id, TRUE);
$this->assertFalse($field, 'The field was deleted.');
$field_2 = entity_load('field_entity', $field_id_2, TRUE);
$field_2 = entity_load('field_config', $field_id_2, TRUE);
$this->assertFalse($field_2, 'The second field was deleted.');
$instance = entity_load('field_instance', $instance_id, TRUE);
$instance = entity_load('field_instance_config', $instance_id, TRUE);
$this->assertFalse($instance, 'The field instance was deleted.');
$instance_2a = entity_load('field_instance', $instance_id_2a, TRUE);
$instance_2a = entity_load('field_instance_config', $instance_id_2a, TRUE);
$this->assertFalse($instance_2a, 'The second field instance on test bundle was deleted.');
$instance_2b = entity_load('field_instance', $instance_id_2b, TRUE);
$instance_2b = entity_load('field_instance_config', $instance_id_2b, TRUE);
$this->assertFalse($instance_2b, 'The second field instance on test bundle 2 was deleted.');
// Check that all config files are gone.

View File

@ -41,7 +41,7 @@ class FieldInfoTest extends FieldUnitTestBase {
// Create a field, verify it shows up.
$core_fields = field_info_fields();
$field = entity_create('field_entity', array(
$field = entity_create('field_config', array(
'name' => drupal_strtolower($this->randomName()),
'entity_type' => 'entity_test',
'type' => 'test_field',
@ -67,7 +67,7 @@ class FieldInfoTest extends FieldUnitTestBase {
'description' => $this->randomName(),
'weight' => mt_rand(0, 127),
);
$instance = entity_create('field_instance', $instance_definition);
$instance = entity_create('field_instance_config', $instance_definition);
$instance->save();
$entity_type = \Drupal::entityManager()->getDefinition('entity_test');
@ -116,7 +116,7 @@ class FieldInfoTest extends FieldUnitTestBase {
'entity_type' => 'entity_test',
'type' => 'test_field',
);
$field = entity_create('field_entity', $field_definition);
$field = entity_create('field_config', $field_definition);
$field->save();
// Simulate a stored field definition missing a field setting (e.g. a
@ -144,13 +144,13 @@ class FieldInfoTest extends FieldUnitTestBase {
'entity_type' => 'entity_test',
'type' => 'test_field',
);
entity_create('field_entity', $field_definition)->save();
entity_create('field_config', $field_definition)->save();
$instance_definition = array(
'field_name' => $field_definition['name'],
'entity_type' => 'entity_test',
'bundle' => 'entity_test',
);
$instance = entity_create('field_instance', $instance_definition);
$instance = entity_create('field_instance_config', $instance_definition);
$instance->save();
// Simulate a stored instance definition missing various settings (e.g. a
@ -186,13 +186,13 @@ class FieldInfoTest extends FieldUnitTestBase {
'entity_type' => 'comment',
'type' => 'test_field',
);
entity_create('field_entity', $field_definition)->save();
entity_create('field_config', $field_definition)->save();
$instance_definition = array(
'field_name' => 'field',
'entity_type' => 'comment',
'bundle' => 'comment_node_article',
);
entity_create('field_instance', $instance_definition)->save();
entity_create('field_instance_config', $instance_definition)->save();
$this->assertNotNull(field_info_instance('comment', 'field', 'comment_node_article'), 'Instance is returned on enabled entity types.');
// Disable comment module. This clears field_info cache.
@ -229,7 +229,7 @@ class FieldInfoTest extends FieldUnitTestBase {
),
);
foreach ($fields as $field) {
entity_create('field_entity', $field)->save();
entity_create('field_config', $field)->save();
}
// Create a couple instances.
@ -256,7 +256,7 @@ class FieldInfoTest extends FieldUnitTestBase {
),
);
foreach ($instances as $instance) {
entity_create('field_instance', $instance)->save();
entity_create('field_instance_config', $instance)->save();
}
$expected = array(
@ -303,7 +303,7 @@ class FieldInfoTest extends FieldUnitTestBase {
// Create a test field and ensure it's in the array returned by
// field_info_fields().
$field_name = drupal_strtolower($this->randomName());
$field = entity_create('field_entity', array(
$field = entity_create('field_config', array(
'name' => $field_name,
'entity_type' => 'entity_test',
'type' => 'test_field',

View File

@ -15,7 +15,7 @@ class FieldInstanceCrudTest extends FieldUnitTestBase {
/**
* The field entity.
*
* @var \Drupal\field\Entity\Field
* @var \Drupal\field\Entity\FieldConfig
*/
protected $field;
@ -49,7 +49,7 @@ class FieldInstanceCrudTest extends FieldUnitTestBase {
'entity_type' => 'entity_test',
'type' => 'test_field',
);
$this->field = entity_create('field_entity', $this->field_definition);
$this->field = entity_create('field_config', $this->field_definition);
$this->field->save();
$this->instance_definition = array(
'field_name' => $this->field->getName(),
@ -68,7 +68,7 @@ class FieldInstanceCrudTest extends FieldUnitTestBase {
* Test the creation of a field instance.
*/
function testCreateFieldInstance() {
$instance = entity_create('field_instance', $this->instance_definition);
$instance = entity_create('field_instance_config', $this->instance_definition);
$instance->save();
// Read the configuration. Check against raw configuration data rather than
@ -88,7 +88,7 @@ class FieldInstanceCrudTest extends FieldUnitTestBase {
// Guarantee that the field/bundle combination is unique.
try {
entity_create('field_instance', $this->instance_definition)->save();
entity_create('field_instance_config', $this->instance_definition)->save();
$this->fail(t('Cannot create two instances with the same field / bundle combination.'));
}
catch (EntityStorageException $e) {
@ -98,7 +98,7 @@ class FieldInstanceCrudTest extends FieldUnitTestBase {
// Check that the specified field exists.
try {
$this->instance_definition['field_name'] = $this->randomName();
entity_create('field_instance', $this->instance_definition)->save();
entity_create('field_instance_config', $this->instance_definition)->save();
$this->fail(t('Cannot create an instance of a non-existing field.'));
}
catch (FieldException $e) {
@ -112,10 +112,10 @@ class FieldInstanceCrudTest extends FieldUnitTestBase {
* Test reading back an instance definition.
*/
function testReadFieldInstance() {
entity_create('field_instance', $this->instance_definition)->save();
entity_create('field_instance_config', $this->instance_definition)->save();
// Read the instance back.
$instance = entity_load('field_instance', 'entity_test.' . $this->instance_definition['bundle'] . '.' . $this->instance_definition['field_name']);
$instance = entity_load('field_instance_config', 'entity_test.' . $this->instance_definition['bundle'] . '.' . $this->instance_definition['field_name']);
$this->assertTrue($this->instance_definition['field_name'] == $instance->getName(), 'The field was properly read.');
$this->assertTrue($this->instance_definition['entity_type'] == $instance->entity_type, 'The field was properly read.');
$this->assertTrue($this->instance_definition['bundle'] == $instance->bundle, 'The field was properly read.');
@ -125,17 +125,17 @@ class FieldInstanceCrudTest extends FieldUnitTestBase {
* Test the update of a field instance.
*/
function testUpdateFieldInstance() {
entity_create('field_instance', $this->instance_definition)->save();
entity_create('field_instance_config', $this->instance_definition)->save();
// Check that basic changes are saved.
$instance = entity_load('field_instance', 'entity_test.' . $this->instance_definition['bundle'] . '.' . $this->instance_definition['field_name']);
$instance = entity_load('field_instance_config', 'entity_test.' . $this->instance_definition['bundle'] . '.' . $this->instance_definition['field_name']);
$instance->required = !$instance->isRequired();
$instance->label = $this->randomName();
$instance->description = $this->randomName();
$instance->settings['test_instance_setting'] = $this->randomName();
$instance->save();
$instance_new = entity_load('field_instance', 'entity_test.' . $this->instance_definition['bundle'] . '.' . $this->instance_definition['field_name']);
$instance_new = entity_load('field_instance_config', 'entity_test.' . $this->instance_definition['bundle'] . '.' . $this->instance_definition['field_name']);
$this->assertEqual($instance->isRequired(), $instance_new->isRequired(), '"required" change is saved');
$this->assertEqual($instance->getLabel(), $instance_new->getLabel(), '"label" change is saved');
$this->assertEqual($instance->getDescription(), $instance_new->getDescription(), '"description" change is saved');
@ -153,27 +153,27 @@ class FieldInstanceCrudTest extends FieldUnitTestBase {
// Create two instances for the same field so we can test that only one
// is deleted.
entity_create('field_instance', $this->instance_definition)->save();
entity_create('field_instance_config', $this->instance_definition)->save();
$another_instance_definition = $this->instance_definition;
$another_instance_definition['bundle'] .= '_another_bundle';
entity_create('field_instance', $another_instance_definition)->save();
entity_create('field_instance_config', $another_instance_definition)->save();
// Test that the first instance is not deleted, and then delete it.
$instance = current(entity_load_multiple_by_properties('field_instance', array('entity_type' => 'entity_test', 'field_name' => $this->instance_definition['field_name'], 'bundle' => $this->instance_definition['bundle'], 'include_deleted' => TRUE)));
$instance = current(entity_load_multiple_by_properties('field_instance_config', array('entity_type' => 'entity_test', 'field_name' => $this->instance_definition['field_name'], 'bundle' => $this->instance_definition['bundle'], 'include_deleted' => TRUE)));
$this->assertTrue(!empty($instance) && empty($instance->deleted), 'A new field instance is not marked for deletion.');
$instance->delete();
// Make sure the instance is marked as deleted when the instance is
// specifically loaded.
$instance = current(entity_load_multiple_by_properties('field_instance', array('entity_type' => 'entity_test', 'field_name' => $this->instance_definition['field_name'], 'bundle' => $this->instance_definition['bundle'], 'include_deleted' => TRUE)));
$instance = current(entity_load_multiple_by_properties('field_instance_config', array('entity_type' => 'entity_test', 'field_name' => $this->instance_definition['field_name'], 'bundle' => $this->instance_definition['bundle'], 'include_deleted' => TRUE)));
$this->assertTrue(!empty($instance->deleted), 'A deleted field instance is marked for deletion.');
// Try to load the instance normally and make sure it does not show up.
$instance = entity_load('field_instance', 'entity_test.' . '.' . $this->instance_definition['bundle'] . '.' . $this->instance_definition['field_name']);
$instance = entity_load('field_instance_config', 'entity_test.' . '.' . $this->instance_definition['bundle'] . '.' . $this->instance_definition['field_name']);
$this->assertTrue(empty($instance), 'A deleted field instance is not loaded by default.');
// Make sure the other field instance is not deleted.
$another_instance = entity_load('field_instance', 'entity_test.' . $another_instance_definition['bundle'] . '.' . $another_instance_definition['field_name']);
$another_instance = entity_load('field_instance_config', 'entity_test.' . $another_instance_definition['bundle'] . '.' . $another_instance_definition['field_name']);
$this->assertTrue(!empty($another_instance) && empty($another_instance->deleted), 'A non-deleted field instance is not marked for deletion.');
}
@ -186,18 +186,18 @@ class FieldInstanceCrudTest extends FieldUnitTestBase {
// Check that deletion of a field deletes its instances.
$field = $this->field;
entity_create('field_instance', $this->instance_definition)->save();
entity_create('field_instance', $instance_definition_2)->save();
entity_create('field_instance_config', $this->instance_definition)->save();
entity_create('field_instance_config', $instance_definition_2)->save();
$field->delete();
$this->assertFalse(field_info_instance('entity_test', $this->instance_definition['bundle'], $field->name));
$this->assertFalse(field_info_instance('entity_test', $instance_definition_2['bundle'], $field->name));
// Chack that deletion of the last instance deletes the field.
$field = entity_create('field_entity', $this->field_definition);
$field = entity_create('field_config', $this->field_definition);
$field->save();
$instance = entity_create('field_instance', $this->instance_definition);
$instance = entity_create('field_instance_config', $this->instance_definition);
$instance->save();
$instance_2 = entity_create('field_instance', $instance_definition_2);
$instance_2 = entity_create('field_instance_config', $instance_definition_2);
$instance_2->save();
$instance->delete();
$this->assertTrue(field_info_field('entity_test', $field->name));
@ -206,13 +206,13 @@ class FieldInstanceCrudTest extends FieldUnitTestBase {
// Check that deletion of all instances of the same field simultaneously
// deletes the field.
$field = entity_create('field_entity', $this->field_definition);
$field = entity_create('field_config', $this->field_definition);
$field->save();
$instance = entity_create('field_instance', $this->instance_definition);
$instance = entity_create('field_instance_config', $this->instance_definition);
$instance->save();
$instance_2 = entity_create('field_instance', $instance_definition_2);
$instance_2 = entity_create('field_instance_config', $instance_definition_2);
$instance_2->save();
$instance_controller = $this->container->get('entity.manager')->getStorageController('field_instance');
$instance_controller = $this->container->get('entity.manager')->getStorageController('field_instance_config');
$instance_controller->delete(array($instance, $instance_2));
$this->assertFalse(field_info_field('entity_test', $field->name));
}

View File

@ -67,7 +67,7 @@ abstract class FieldUnitTestBase extends DrupalUnitTestBase {
$instance_definition = 'instance_definition' . $suffix;
$this->$field_name = drupal_strtolower($this->randomName() . '_field_name' . $suffix);
$this->$field = entity_create('field_entity', array(
$this->$field = entity_create('field_config', array(
'name' => $this->$field_name,
'entity_type' => $entity_type,
'type' => 'test_field',
@ -85,7 +85,7 @@ abstract class FieldUnitTestBase extends DrupalUnitTestBase {
'test_instance_setting' => $this->randomName(),
),
);
$this->$instance = entity_create('field_instance', $this->$instance_definition);
$this->$instance = entity_create('field_instance_config', $this->$instance_definition);
$this->$instance->save();
entity_get_form_display($entity_type, $bundle, 'default')

View File

@ -94,8 +94,8 @@ class FormTest extends FieldTestBase {
$field = $this->field_single;
$field_name = $field['name'];
$this->instance['field_name'] = $field_name;
entity_create('field_entity', $field)->save();
entity_create('field_instance', $this->instance)->save();
entity_create('field_config', $field)->save();
entity_create('field_instance_config', $this->instance)->save();
entity_get_form_display($this->instance['entity_type'], $this->instance['bundle'], 'default')
->setComponent($field_name)
->save();
@ -178,8 +178,8 @@ class FormTest extends FieldTestBase {
$this->instance['field_name'] = $field_name;
$default = rand(1, 127);
$this->instance['default_value'] = array(array('value' => $default));
entity_create('field_entity', $field)->save();
entity_create('field_instance', $this->instance)->save();
entity_create('field_config', $field)->save();
entity_create('field_instance_config', $this->instance)->save();
entity_get_form_display($this->instance['entity_type'], $this->instance['bundle'], 'default')
->setComponent($field_name)
->save();
@ -208,8 +208,8 @@ class FormTest extends FieldTestBase {
$field_name = $field['name'];
$this->instance['field_name'] = $field_name;
$this->instance['required'] = TRUE;
entity_create('field_entity', $field)->save();
entity_create('field_instance', $this->instance)->save();
entity_create('field_config', $field)->save();
entity_create('field_instance_config', $this->instance)->save();
entity_get_form_display($this->instance['entity_type'], $this->instance['bundle'], 'default')
->setComponent($field_name)
->save();
@ -248,16 +248,16 @@ class FormTest extends FieldTestBase {
// $this->field = $this->field_multiple;
// $field_name = $this->field['field_name'];
// $this->instance['field_name'] = $field_name;
// entity_create('field_entity', $this->field)->save();
// entity_create('field_instance', $this->instance)->save();
// entity_create('field_config', $this->field)->save();
// entity_create('field_instance_config', $this->instance)->save();
// }
function testFieldFormUnlimited() {
$field = $this->field_unlimited;
$field_name = $field['name'];
$this->instance['field_name'] = $field_name;
entity_create('field_entity', $field)->save();
entity_create('field_instance', $this->instance)->save();
entity_create('field_config', $field)->save();
entity_create('field_instance_config', $this->instance)->save();
entity_get_form_display($this->instance['entity_type'], $this->instance['bundle'], 'default')
->setComponent($field_name)
->save();
@ -342,14 +342,14 @@ class FormTest extends FieldTestBase {
$field = $this->field_unlimited;
$field_name = $field['name'];
$this->instance['field_name'] = $field_name;
entity_create('field_entity', $field)->save();
entity_create('field_instance', $this->instance)->save();
entity_create('field_config', $field)->save();
entity_create('field_instance_config', $this->instance)->save();
entity_get_form_display($this->instance['entity_type'], $this->instance['bundle'], 'default')
->setComponent($field_name)
->save();
// Add a required radio field.
entity_create('field_entity', array(
entity_create('field_config', array(
'name' => 'required_radio_test',
'entity_type' => 'entity_test',
'type' => 'list_text',
@ -363,7 +363,7 @@ class FormTest extends FieldTestBase {
'bundle' => 'entity_test',
'required' => TRUE,
);
entity_create('field_instance', $instance)->save();
entity_create('field_instance_config', $instance)->save();
entity_get_form_display($instance['entity_type'], $instance['bundle'], 'default')
->setComponent($instance['field_name'], array(
'type' => 'options_buttons',
@ -389,8 +389,8 @@ class FormTest extends FieldTestBase {
$field = $this->field_unlimited;
$field_name = $field['name'];
$this->instance['field_name'] = $field_name;
entity_create('field_entity', $field)->save();
entity_create('field_instance', $this->instance)->save();
entity_create('field_config', $field)->save();
entity_create('field_instance_config', $this->instance)->save();
entity_get_form_display($this->instance['entity_type'], $this->instance['bundle'], 'default')
->setComponent($field_name)
->save();
@ -450,8 +450,8 @@ class FormTest extends FieldTestBase {
$field = $this->field_multiple;
$field_name = $field['name'];
$this->instance['field_name'] = $field_name;
entity_create('field_entity', $field)->save();
entity_create('field_instance', $this->instance)->save();
entity_create('field_config', $field)->save();
entity_create('field_instance_config', $this->instance)->save();
entity_get_form_display($this->instance['entity_type'], $this->instance['bundle'], 'default')
->setComponent($field_name, array(
'type' => 'test_field_widget_multiple',
@ -501,8 +501,8 @@ class FormTest extends FieldTestBase {
$instance['field_name'] = $field_name;
$instance['entity_type'] = $entity_type;
$instance['bundle'] = $entity_type;
entity_create('field_entity', $field)->save();
entity_create('field_instance', $instance)->save();
entity_create('field_config', $field)->save();
entity_create('field_instance_config', $instance)->save();
entity_get_form_display($entity_type, $entity_type, 'default')
->setComponent($field_name)
->save();
@ -521,8 +521,8 @@ class FormTest extends FieldTestBase {
'bundle' => $entity_type,
'default_value' => array(0 => array('value' => 99)),
);
entity_create('field_entity', $field_no_access)->save();
entity_create('field_instance', $instance_no_access)->save();
entity_create('field_config', $field_no_access)->save();
entity_create('field_instance_config', $instance_no_access)->save();
entity_get_form_display($instance_no_access['entity_type'], $instance_no_access['bundle'], 'default')
->setComponent($field_name_no_access)
->save();
@ -591,8 +591,8 @@ class FormTest extends FieldTestBase {
$this->instance['default_value'] = array(0 => array('value' => 99));
$this->instance['entity_type'] = $entity_type;
$this->instance['bundle'] = $entity_type;
entity_create('field_entity', $field)->save();
$this->instance = entity_create('field_instance', $this->instance);
entity_create('field_config', $field)->save();
$this->instance = entity_create('field_instance_config', $this->instance);
$this->instance->save();
// We explicitly do not assign a widget in a form display, so the field
// stays hidden in forms.

View File

@ -61,17 +61,17 @@ class NestedFormTest extends FieldTestBase {
*/
function testNestedFieldForm() {
// Add two instances on the 'entity_test'
entity_create('field_entity', $this->field_single)->save();
entity_create('field_entity', $this->field_unlimited)->save();
entity_create('field_config', $this->field_single)->save();
entity_create('field_config', $this->field_unlimited)->save();
$this->instance['field_name'] = 'field_single';
$this->instance['label'] = 'Single field';
entity_create('field_instance', $this->instance)->save();
entity_create('field_instance_config', $this->instance)->save();
entity_get_form_display($this->instance['entity_type'], $this->instance['bundle'], 'default')
->setComponent($this->instance['field_name'])
->save();
$this->instance['field_name'] = 'field_unlimited';
$this->instance['label'] = 'Unlimited field';
entity_create('field_instance', $this->instance)->save();
entity_create('field_instance_config', $this->instance)->save();
entity_get_form_display($this->instance['entity_type'], $this->instance['bundle'], 'default')
->setComponent($this->instance['field_name'])
->save();

View File

@ -46,13 +46,13 @@ class ShapeItemTest extends FieldUnitTestBase {
'entity_type' => 'entity_test',
'type' => 'shape',
);
entity_create('field_entity', $field)->save();
entity_create('field_config', $field)->save();
$instance = array(
'entity_type' => 'entity_test',
'field_name' => $this->field_name,
'bundle' => 'entity_test',
);
entity_create('field_instance', $instance)->save();
entity_create('field_instance_config', $instance)->save();
}
/**

View File

@ -47,13 +47,13 @@ class TestItemTest extends FieldUnitTestBase {
'entity_type' => 'entity_test',
'type' => 'test_field',
);
entity_create('field_entity', $field)->save();
entity_create('field_config', $field)->save();
$instance = array(
'entity_type' => 'entity_test',
'field_name' => $this->field_name,
'bundle' => 'entity_test',
);
entity_create('field_instance', $instance)->save();
entity_create('field_instance_config', $instance)->save();
}
/**

View File

@ -57,14 +57,14 @@ class TranslationTest extends FieldUnitTestBase {
/**
* The field to use in this test.
*
* @var \Drupal\field\Entity\Field
* @var \Drupal\field\Entity\FieldConfig
*/
protected $field;
/**
* The field instance to use in this test.
*
* @var \Drupal\field\Entity\FieldInstance
* @var \Drupal\field\Entity\FieldInstanceConfig
*/
protected $instance;
@ -92,7 +92,7 @@ class TranslationTest extends FieldUnitTestBase {
'cardinality' => 4,
'translatable' => TRUE,
);
$this->field = entity_create('field_entity', $this->field_definition);
$this->field = entity_create('field_config', $this->field_definition);
$this->field->save();
$this->instance_definition = array(
@ -100,7 +100,7 @@ class TranslationTest extends FieldUnitTestBase {
'entity_type' => $this->entity_type,
'bundle' => 'entity_test',
);
$this->instance = entity_create('field_instance', $this->instance_definition);
$this->instance = entity_create('field_instance_config', $this->instance_definition);
$this->instance->save();
for ($i = 0; $i < 3; ++$i) {
@ -149,12 +149,12 @@ class TranslationTest extends FieldUnitTestBase {
$field_name_default = drupal_strtolower($this->randomName() . '_field_name');
$field_definition = $this->field_definition;
$field_definition['name'] = $field_name_default;
entity_create('field_entity', $field_definition)->save();
entity_create('field_config', $field_definition)->save();
$instance_definition = $this->instance_definition;
$instance_definition['field_name'] = $field_name_default;
$instance_definition['default_value'] = array(array('value' => rand(1, 127)));
$instance = entity_create('field_instance', $instance_definition);
$instance = entity_create('field_instance_config', $instance_definition);
$instance->save();
entity_info_cache_clear();

View File

@ -38,14 +38,14 @@ class TranslationWebTest extends FieldTestBase {
/**
* The field to use in this test.
*
* @var \Drupal\field\Entity\Field
* @var \Drupal\field\Entity\FieldConfig
*/
protected $field;
/**
* The field instance to use in this test.
*
* @var \Drupal\field\Entity\FieldInstance
* @var \Drupal\field\Entity\FieldInstanceConfig
*/
protected $instance;
@ -69,16 +69,16 @@ class TranslationWebTest extends FieldTestBase {
'cardinality' => 4,
'translatable' => TRUE,
);
entity_create('field_entity', $field)->save();
$this->field = entity_load('field_entity', $this->entity_type . '.' . $this->field_name);
entity_create('field_config', $field)->save();
$this->field = entity_load('field_config', $this->entity_type . '.' . $this->field_name);
$instance = array(
'field_name' => $this->field_name,
'entity_type' => $this->entity_type,
'bundle' => $this->entity_type,
);
entity_create('field_instance', $instance)->save();
$this->instance = entity_load('field_instance', 'entity_test.' . $instance['bundle'] . '.' . $this->field_name);
entity_create('field_instance_config', $instance)->save();
$this->instance = entity_load('field_instance_config', 'entity_test.' . $instance['bundle'] . '.' . $this->field_name);
entity_get_form_display($this->entity_type, $this->entity_type, 'default')
->setComponent($this->field_name)

View File

@ -37,7 +37,7 @@ class ApiDataTest extends FieldTestBase {
'entity_type' => 'node',
'bundle' => 'page',
);
entity_create('field_instance', $instance)->save();
entity_create('field_instance_config', $instance)->save();
// Now create some example nodes/users for the view result.
for ($i = 0; $i < 5; $i++) {

View File

@ -66,7 +66,7 @@ abstract class FieldTestBase extends ViewTestBase {
'type' => 'text',
);
$this->fields[$i] = $field = entity_create('field_entity', $field);
$this->fields[$i] = $field = entity_create('field_config', $field);
$field->save();
}
return $field_names;
@ -79,7 +79,7 @@ abstract class FieldTestBase extends ViewTestBase {
'entity_type' => 'node',
'bundle' => 'page',
);
$this->instances[$key] = entity_create('field_instance', $instance);
$this->instances[$key] = entity_create('field_instance_config', $instance);
$this->instances[$key]->save();
}
}

View File

@ -48,7 +48,7 @@ class HandlerFieldFieldTest extends FieldTestBase {
$this->setUpFields(3);
// Setup a field with cardinality > 1.
$this->fields[3] = $field = entity_create('field_entity', array(
$this->fields[3] = $field = entity_create('field_config', array(
'name' => 'field_name_3',
'entity_type' => 'node',
'type' => 'text',
@ -56,7 +56,7 @@ class HandlerFieldFieldTest extends FieldTestBase {
));
$field->save();
// Setup a field that will have no value.
$this->fields[4] = $field = entity_create('field_entity', array(
$this->fields[4] = $field = entity_create('field_config', array(
'name' => 'field_name_4',
'entity_type' => 'node',
'type' => 'text',

View File

@ -49,13 +49,13 @@ class reEnableModuleFieldTest extends WebTestBase {
function testReEnabledField() {
// Add a telephone field to the article content type.
$field = entity_create('field_entity', array(
$field = entity_create('field_config', array(
'name' => 'field_telephone',
'entity_type' => 'node',
'type' => 'telephone',
));
$field->save();
entity_create('field_instance', array(
entity_create('field_instance_config', array(
'field_name' => 'field_telephone',
'label' => 'Telephone Number',
'entity_type' => 'node',

View File

@ -72,14 +72,14 @@ function field_test_menu() {
* field_test_memorize();
*
* // call some Field API functions that invoke field_test hooks
* entity_create('field_entity', $field_definition)->save();
* entity_create('field_config', $field_definition)->save();
*
* // retrieve and reset the memorized hook call data
* $mem = field_test_memorize();
*
* // make sure hook_field_create_field() is invoked correctly
* assertEqual(count($mem['field_test_field_entity_create']), 1);
* assertEqual($mem['field_test_field_entity_create'][0], array($field));
* // make sure hook_field_config_create() is invoked correctly
* assertEqual(count($mem['field_test_field_config_create']), 1);
* assertEqual($mem['field_test_field_config_create'][0], array($field));
* @endcode
*
* @param $key
@ -104,9 +104,9 @@ function field_test_memorize($key = NULL, $value = NULL) {
}
/**
* Memorize calls to field_test_field_entity_create() for field creation.
* Memorize calls to field_test_field_config_create() for field creation.
*/
function field_test_field_entity_create(FieldInterface $field) {
function field_test_field_config_create(FieldInterface $field) {
$args = func_get_args();
field_test_memorize(__FUNCTION__, $args);
}

View File

@ -134,8 +134,8 @@ function field_ui_element_info() {
*/
function field_ui_entity_info(&$entity_info) {
/** @var $entity_info \Drupal\Core\Entity\EntityTypeInterface[] */
$entity_info['field_instance']->setFormClass('delete', 'Drupal\field_ui\Form\FieldDeleteForm');
$entity_info['field_entity']->setListClass('Drupal\field_ui\FieldListController');
$entity_info['field_instance_config']->setFormClass('delete', 'Drupal\field_ui\Form\FieldInstanceConfigDeleteForm');
$entity_info['field_config']->setListClass('Drupal\field_ui\FieldConfigListController');
foreach ($entity_info as $info) {
if ($bundle = $info->getBundleOf()) {

View File

@ -1,7 +1,7 @@
field_ui.list:
path: '/admin/reports/fields'
defaults:
_entity_list: 'field_entity'
_entity_list: 'field_config'
_title: 'Field list'
requirements:
_permission: 'administer content types'

View File

@ -21,7 +21,7 @@ class FieldDeleteAccessCheck implements AccessInterface {
* {@inheritdoc}
*/
public function access(Route $route, Request $request, AccountInterface $account) {
$field_instance = $request->attributes->get('field_instance');
$field_instance = $request->attributes->get('field_instance_config');
if (!$field_instance->getField()->isLocked()) {
$permission = $route->getRequirement('_field_ui_field_delete_access');
return $account->hasPermission($permission) ? static::ALLOW : static::DENY;

View File

@ -2,7 +2,7 @@
/**
* @file
* Contains \Drupal\field_ui\FieldListController.
* Contains \Drupal\field_ui\FieldConfigListController.
*/
namespace Drupal\field_ui;
@ -17,7 +17,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Provides a listing of fields.
*/
class FieldListController extends ConfigEntityListController {
class FieldConfigListController extends ConfigEntityListController {
/**
* An array of information about field types.
@ -48,7 +48,7 @@ class FieldListController extends ConfigEntityListController {
protected $fieldTypeManager;
/**
* Constructs a new EntityListController object.
* Constructs a new FieldConfigListController object.
*
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
* The entity type definition.

View File

@ -12,7 +12,7 @@ use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Field\FieldTypePluginManagerInterface;
use Drupal\field_ui\OverviewBase;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\field\Entity\Field;
use Drupal\field\Entity\FieldConfig;
/**
* Field UI field overview form.
@ -124,7 +124,7 @@ class FieldOverview extends OverviewBase {
$field = $instance->getField();
$route_parameters = array(
$this->bundleEntityType => $this->bundle,
'field_instance' => $instance->id(),
'field_instance_config' => $instance->id(),
);
$table[$name] = array(
'#attributes' => array(
@ -212,7 +212,7 @@ class FieldOverview extends OverviewBase {
'#description' => $this->t('A unique machine-readable name containing letters, numbers, and underscores.'),
// Calculate characters depending on the length of the field prefix
// setting. Maximum length is 32.
'#maxlength' => Field::NAME_MAX_LENGTH - strlen($field_prefix),
'#maxlength' => FieldConfig::NAME_MAX_LENGTH - strlen($field_prefix),
'#prefix' => '<div class="add-new-placeholder">&nbsp;</div>',
'#machine_name' => array(
'source' => array('fields', $name, 'label'),
@ -406,8 +406,8 @@ class FieldOverview extends OverviewBase {
// Create the field and instance.
try {
$this->entityManager->getStorageController('field_entity')->create($field)->save();
$new_instance = $this->entityManager->getStorageController('field_instance')->create($instance);
$this->entityManager->getStorageController('field_config')->create($field)->save();
$new_instance = $this->entityManager->getStorageController('field_instance_config')->create($instance);
$new_instance->save();
// Make sure the field is displayed in the 'default' form mode (using
@ -428,7 +428,7 @@ class FieldOverview extends OverviewBase {
// configured for new fields.
$route_parameters = array(
$this->bundleEntityType => $this->bundle,
'field_instance' => $new_instance->id(),
'field_instance_config' => $new_instance->id(),
);
$destinations[] = array('route_name' => 'field_ui.field_edit_' . $this->entity_type, 'route_parameters' => $route_parameters);
$destinations[] = array('route_name' => 'field_ui.instance_edit_' . $this->entity_type, 'route_parameters' => $route_parameters);
@ -458,7 +458,7 @@ class FieldOverview extends OverviewBase {
);
try {
$new_instance = $this->entityManager->getStorageController('field_instance')->create($instance);
$new_instance = $this->entityManager->getStorageController('field_instance_config')->create($instance);
$new_instance->save();
// Make sure the field is displayed in the 'default' form mode (using
@ -479,7 +479,7 @@ class FieldOverview extends OverviewBase {
'route_name' => 'field_ui.instance_edit_' . $this->entity_type,
'route_parameters' => array(
$this->bundleEntityType => $this->bundle,
'field_instance' => $new_instance->id(),
'field_instance_config' => $new_instance->id(),
),
);
// Store new field information for any additional submit handlers.
@ -526,7 +526,7 @@ class FieldOverview extends OverviewBase {
// Load the instances and build the list of options.
if ($instance_ids) {
$field_types = $this->fieldTypeManager->getDefinitions();
$instances = $this->entityManager->getStorageController('field_instance')->loadMultiple($instance_ids);
$instances = $this->entityManager->getStorageController('field_instance_config')->loadMultiple($instance_ids);
foreach ($instances as $instance) {
// Do not show:
// - locked fields,

View File

@ -85,8 +85,8 @@ class FieldEditForm extends FormBase {
/**
* {@inheritdoc}
*/
public function buildForm(array $form, array &$form_state, FieldInstanceInterface $field_instance = NULL) {
$this->instance = $form_state['instance'] = $field_instance;
public function buildForm(array $form, array &$form_state, FieldInstanceInterface $field_instance_config = NULL) {
$this->instance = $form_state['instance'] = $field_instance_config;
$form['#title'] = $this->instance->label();
$field = $this->instance->getField();

View File

@ -2,7 +2,7 @@
/**
* @file
* Contains \Drupal\field_ui\Form\FieldDeleteForm.
* Contains \Drupal\field_ui\Form\FieldInstanceConfigDeleteForm.
*/
namespace Drupal\field_ui\Form;
@ -15,7 +15,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Provides a form for removing a field instance from a bundle.
*/
class FieldDeleteForm extends EntityConfirmFormBase {
class FieldInstanceConfigDeleteForm extends EntityConfirmFormBase {
/**
* The entity manager.
@ -25,7 +25,7 @@ class FieldDeleteForm extends EntityConfirmFormBase {
protected $entityManager;
/**
* Constructs a new FieldDeleteForm object.
* Constructs a new FieldInstanceConfigDeleteForm object.
*
* @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
* The entity manager.

View File

@ -62,8 +62,8 @@ class FieldInstanceEditForm extends FormBase {
/**
* {@inheritdoc}
*/
public function buildForm(array $form, array &$form_state, FieldInstanceInterface $field_instance = NULL) {
$this->instance = $form_state['instance'] = $field_instance;
public function buildForm(array $form, array &$form_state, FieldInstanceInterface $field_instance_config = NULL) {
$this->instance = $form_state['instance'] = $field_instance_config;
$bundle = $this->instance->bundle;
$entity_type = $this->instance->entity_type;
@ -220,7 +220,7 @@ class FieldInstanceEditForm extends FormBase {
'route_name' => 'field_ui.delete_' . $this->instance->entity_type,
'route_parameters' => array(
$entity_type->getBundleEntityType() => $this->instance->bundle,
'field_instance' => $this->instance->id(),
'field_instance_config' => $this->instance->id(),
),
'options' => array(
'query' => $destination,
@ -231,14 +231,14 @@ class FieldInstanceEditForm extends FormBase {
/**
* The _title_callback for the field instance settings form.
*
* @param \Drupal\field\FieldInstanceInterface $field_instance
* @param \Drupal\field\FieldInstanceInterface $field_instance_config
* The field instance.
*
* @return string
* The label of the field instance.
*/
public function getTitle(FieldInstanceInterface $field_instance) {
return String::checkPlain($field_instance->label());
public function getTitle(FieldInstanceInterface $field_instance_config) {
return String::checkPlain($field_instance_config->label());
}
}

View File

@ -49,7 +49,7 @@ class RouteSubscriber extends RouteSubscriberBase {
$path = $entity_route->getPath();
$route = new Route(
"$path/fields/{field_instance}",
"$path/fields/{field_instance_config}",
array(
'_form' => '\Drupal\field_ui\Form\FieldInstanceEditForm',
'_title_callback' => '\Drupal\field_ui\Form\FieldInstanceEditForm::getTitle',
@ -59,15 +59,15 @@ class RouteSubscriber extends RouteSubscriberBase {
$collection->add("field_ui.instance_edit_$entity_type_id", $route);
$route = new Route(
"$path/fields/{field_instance}/field",
"$path/fields/{field_instance_config}/field",
array('_form' => '\Drupal\field_ui\Form\FieldEditForm'),
array('_permission' => 'administer ' . $entity_type_id . ' fields')
);
$collection->add("field_ui.field_edit_$entity_type_id", $route);
$route = new Route(
"$path/fields/{field_instance}/delete",
array('_entity_form' => 'field_instance.delete'),
"$path/fields/{field_instance_config}/delete",
array('_entity_form' => 'field_instance_config.delete'),
array('_field_ui_field_delete_access' => 'administer ' . $entity_type_id . ' fields')
);
$collection->add("field_ui.delete_$entity_type_id", $route);

View File

@ -48,7 +48,7 @@ class ManageFieldsTest extends FieldUiTestBase {
'entity_type' => 'node',
'type' => 'taxonomy_term_reference',
);
entity_create('field_entity', $field)->save();
entity_create('field_config', $field)->save();
$instance = array(
'field_name' => 'field_' . $vocabulary->id(),
@ -56,7 +56,7 @@ class ManageFieldsTest extends FieldUiTestBase {
'label' => 'Tags',
'bundle' => 'article',
);
entity_create('field_instance', $instance)->save();
entity_create('field_instance_config', $instance)->save();
entity_get_form_display('node', 'article', 'default')
->setComponent('field_' . $vocabulary->id())
@ -282,12 +282,12 @@ class ManageFieldsTest extends FieldUiTestBase {
function testDefaultValue() {
// Create a test field and instance.
$field_name = 'test';
entity_create('field_entity', array(
entity_create('field_config', array(
'name' => $field_name,
'entity_type' => 'node',
'type' => 'test_field'
))->save();
$instance = entity_create('field_instance', array(
$instance = entity_create('field_instance_config', array(
'field_name' => $field_name,
'entity_type' => 'node',
'bundle' => $this->type,
@ -388,7 +388,7 @@ class ManageFieldsTest extends FieldUiTestBase {
function testLockedField() {
// Create a locked field and attach it to a bundle. We need to do this
// programatically as there's no way to create a locked field through UI.
$field = entity_create('field_entity', array(
$field = entity_create('field_config', array(
'name' => strtolower($this->randomName(8)),
'entity_type' => 'node',
'type' => 'test_field',
@ -396,7 +396,7 @@ class ManageFieldsTest extends FieldUiTestBase {
'locked' => TRUE
));
$field->save();
entity_create('field_instance', array(
entity_create('field_instance_config', array(
'field_name' => $field->name,
'entity_type' => 'node',
'bundle' => $this->type,
@ -431,7 +431,7 @@ class ManageFieldsTest extends FieldUiTestBase {
// Create a field and an instance programmatically.
$field_name = 'hidden_test_field';
entity_create('field_entity', array(
entity_create('field_config', array(
'name' => $field_name,
'entity_type' => 'node',
'type' => $field_name,
@ -442,11 +442,11 @@ class ManageFieldsTest extends FieldUiTestBase {
'entity_type' => 'node',
'label' => t('Hidden field'),
);
entity_create('field_instance', $instance)->save();
entity_create('field_instance_config', $instance)->save();
entity_get_form_display('node', $this->type, 'default')
->setComponent($field_name)
->save();
$this->assertTrue(entity_load('field_instance', 'node.' . $this->type . '.' . $field_name), format_string('An instance of the field %field was created programmatically.', array('%field' => $field_name)));
$this->assertTrue(entity_load('field_instance_config', 'node.' . $this->type . '.' . $field_name), format_string('An instance of the field %field was created programmatically.', array('%field' => $field_name)));
// Check that the newly added instance appears on the 'Manage Fields'
// screen.
@ -530,13 +530,13 @@ class ManageFieldsTest extends FieldUiTestBase {
*/
function testHelpDescriptions() {
// Create an image field
entity_create('field_entity', array(
entity_create('field_config', array(
'name' => 'field_image',
'entity_type' => 'node',
'type' => 'image',
))->save();
entity_create('field_instance', array(
entity_create('field_instance_config', array(
'field_name' => 'field_image',
'entity_type' => 'node',
'label' => 'Image',

View File

@ -5,9 +5,6 @@
* Install, update and uninstall functions for File module.
*/
use Drupal\Core\Entity\FieldableDatabaseStorageController;
use Drupal\field\Entity\Field;
/**
* Implements hook_schema().
*/

View File

@ -76,7 +76,7 @@ abstract class FileFieldTestBase extends WebTestBase {
'cardinality' => !empty($field_settings['cardinality']) ? $field_settings['cardinality'] : 1,
);
$field_definition['settings'] = array_merge($field_definition['settings'], $field_settings);
$field = entity_create('field_entity', $field_definition);
$field = entity_create('field_config', $field_definition);
$field->save();
$this->attachFileField($name, $entity_type, $bundle, $instance_settings, $widget_settings);
@ -109,7 +109,7 @@ abstract class FileFieldTestBase extends WebTestBase {
'settings' => array(),
);
$instance['settings'] = array_merge($instance['settings'], $instance_settings);
entity_create('field_instance', $instance)->save();
entity_create('field_instance_config', $instance)->save();
entity_get_form_display($entity_type, $bundle, 'default')
->setComponent($name, array(

View File

@ -45,13 +45,13 @@ class FileItemTest extends FieldUnitTestBase {
$this->installSchema('file', 'file_managed');
$this->installSchema('file', 'file_usage');
entity_create('field_entity', array(
entity_create('field_config', array(
'name' => 'file_test',
'entity_type' => 'entity_test',
'type' => 'file',
'cardinality' => FieldDefinitionInterface::CARDINALITY_UNLIMITED,
))->save();
entity_create('field_instance', array(
entity_create('field_instance_config', array(
'entity_type' => 'entity_test',
'field_name' => 'file_test',
'bundle' => 'entity_test',

View File

@ -22,7 +22,7 @@ function forum_install() {
// is being enabled at the same time as taxonomy after both modules have been
// enabled, the field might exist but still be marked inactive.
if (!field_info_field('node', 'taxonomy_forums')) {
entity_create('field_entity', array(
entity_create('field_config', array(
'name' => 'taxonomy_forums',
'entity_type' => 'node',
'type' => 'taxonomy_term_reference',
@ -47,7 +47,7 @@ function forum_install() {
$term->save();
// Create the instance on the bundle.
entity_create('field_instance', array(
entity_create('field_instance_config', array(
'field_name' => 'taxonomy_forums',
'entity_type' => 'node',
'label' => 'Forums',
@ -77,7 +77,7 @@ function forum_install() {
->save();
}
// Add the comment field to the forum node type.
$fields = entity_load_multiple_by_properties('field_entity', array(
$fields = entity_load_multiple_by_properties('field_config', array(
'type' => 'comment',
'name' => 'comment_forum',
'include_deleted' => FALSE,

View File

@ -79,33 +79,33 @@ abstract class NormalizerTestBase extends DrupalUnitTestBase {
language_save($german);
// Create the test text field.
entity_create('field_entity', array(
entity_create('field_config', array(
'name' => 'field_test_text',
'entity_type' => 'entity_test',
'type' => 'text',
'translatable' => FALSE,
))->save();
entity_create('field_instance', array(
entity_create('field_instance_config', array(
'entity_type' => 'entity_test',
'field_name' => 'field_test_text',
'bundle' => 'entity_test',
))->save();
// Create the test translatable field.
entity_create('field_entity', array(
entity_create('field_config', array(
'name' => 'field_test_translatable_text',
'entity_type' => 'entity_test',
'type' => 'text',
'translatable' => TRUE,
))->save();
entity_create('field_instance', array(
entity_create('field_instance_config', array(
'entity_type' => 'entity_test',
'field_name' => 'field_test_translatable_text',
'bundle' => 'entity_test',
))->save();
// Create the test entity reference field.
entity_create('field_entity', array(
entity_create('field_config', array(
'name' => 'field_test_entity_reference',
'entity_type' => 'entity_test',
'type' => 'entity_reference',
@ -114,7 +114,7 @@ abstract class NormalizerTestBase extends DrupalUnitTestBase {
'target_type' => 'entity_test',
),
))->save();
entity_create('field_instance', array(
entity_create('field_instance_config', array(
'entity_type' => 'entity_test',
'field_name' => 'field_test_entity_reference',
'bundle' => 'entity_test',

View File

@ -7,10 +7,9 @@
use Drupal\Core\Entity\EntityInterface;
use Drupal\Component\Plugin\Exception\PluginNotFoundException;
use Drupal\field\Entity\Field;
use Drupal\field\Entity\FieldInstance;
use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldInstanceConfig;
use Drupal\file\Entity\File;
use Drupal\image\Entity\ImageStyle;
use Drupal\field\FieldInterface;
use Drupal\field\FieldInstanceInterface;
@ -423,10 +422,11 @@ function image_filter_keyword($value, $current_pixels, $new_pixels) {
*/
function image_entity_presave(EntityInterface $entity) {
$field = FALSE;
if ($entity instanceof FieldInstance) {
$entity_type_id = $entity->getEntityTypeId();
if ($entity_type_id == 'field_instance_config') {
$field = $entity->getField();
}
elseif ($entity instanceof Field) {
elseif ($entity_type_id == 'field_config') {
$field = $entity;
}
// Exit, if not saving an image field or image field instance entity.
@ -455,9 +455,9 @@ function image_entity_presave(EntityInterface $entity) {
}
/**
* Implements hook_ENTITY_TYPE_update() for 'field_entity'.
* Implements hook_ENTITY_TYPE_update() for 'field_config'.
*/
function image_field_entity_update(FieldInterface $field) {
function image_field_config_update(FieldInterface $field) {
if ($field->type != 'image') {
// Only act on image fields.
return;
@ -495,9 +495,9 @@ function image_field_entity_update(FieldInterface $field) {
}
/**
* Implements hook_ENTITY_TYPE_update() for 'field_instance'.
* Implements hook_ENTITY_TYPE_update() for 'field_instance_config'.
*/
function image_field_instance_update(FieldInstanceInterface $field_instance) {
function image_field_instance_config_update(FieldInstanceInterface $field_instance) {
$field = $field_instance->getField();
if ($field->type != 'image') {
// Only act on image fields.
@ -533,9 +533,9 @@ function image_field_instance_update(FieldInstanceInterface $field_instance) {
}
/**
* Implements hook_ENTITY_TYPE_delete() for 'field_entity'.
* Implements hook_ENTITY_TYPE_delete() for 'field_config'.
*/
function image_field_entity_delete(FieldInterface $field) {
function image_field_config_delete(FieldInterface $field) {
if ($field->type != 'image') {
// Only act on image fields.
return;
@ -549,9 +549,9 @@ function image_field_entity_delete(FieldInterface $field) {
}
/**
* Implements hook_ENTITY_TYPE_delete() for 'field_instance'.
* Implements hook_ENTITY_TYPE_delete() for 'field_instance_config'.
*/
function image_field_instance_delete(FieldInstanceInterface $field_instance) {
function image_field_instance_config_delete(FieldInstanceInterface $field_instance) {
$field = $field_instance->getField();
if ($field->type != 'image') {
// Only act on image fields.

View File

@ -73,7 +73,7 @@ class ImageFieldDefaultImagesTest extends ImageFieldTestBase {
$default_image = $instance->getSetting('default_image');
$this->assertEqual($default_image['fid'], $default_images['instance']->id());
// Also test \Drupal\field\Entity\FieldInstance::getSetting().
// Also test \Drupal\field\Entity\FieldInstanceConfig::getSetting().
$instance_field_settings = $instance->getSettings();
$this->assertEqual($instance_field_settings['default_image']['fid'], $default_images['instance']->id());
@ -83,12 +83,12 @@ class ImageFieldDefaultImagesTest extends ImageFieldTestBase {
$default_image = $field->getSetting('default_image');
$this->assertEqual($default_image['fid'], $default_images['field']->id());
// Also test \Drupal\field\Entity\Field::getSettings().
// Also test \Drupal\field\Entity\FieldConfig::getSettings().
$field_field_settings = $field->getSettings();
$this->assertEqual($field_field_settings['default_image']['fid'], $default_images['field']->id());
// Add another instance with another default image to the page content type.
$instance2 = entity_create('field_instance', array(
$instance2 = entity_create('field_instance_config', array(
'field_name' => $field->name,
'entity_type' => 'node',
'bundle' => 'page',

View File

@ -64,41 +64,37 @@ abstract class ImageFieldTestBase extends WebTestBase {
* A list of widget settings that will be added to the widget defaults.
*/
function createImageField($name, $type_name, $field_settings = array(), $instance_settings = array(), $widget_settings = array()) {
$field = array(
entity_create('field_config', array(
'name' => $name,
'entity_type' => 'node',
'type' => 'image',
'settings' => array(),
'settings' => $field_settings,
'cardinality' => !empty($field_settings['cardinality']) ? $field_settings['cardinality'] : 1,
);
$field['settings'] = array_merge($field['settings'], $field_settings);
entity_create('field_entity', $field)->save();
))->save();
$instance = array(
'field_name' => $field['name'],
$field_instance_config = entity_create('field_instance_config', array(
'field_name' => $name,
'label' => $name,
'entity_type' => 'node',
'bundle' => $type_name,
'required' => !empty($instance_settings['required']),
'description' => !empty($instance_settings['description']) ? $instance_settings['description'] : '',
'settings' => array(),
);
$instance['settings'] = array_merge($instance['settings'], $instance_settings);
$field_instance = entity_create('field_instance', $instance);
$field_instance->save();
'settings' => $instance_settings,
));
$field_instance_config->save();
entity_get_form_display('node', $type_name, 'default')
->setComponent($field['name'], array(
->setComponent($name, array(
'type' => 'image_image',
'settings' => $widget_settings,
))
->save();
entity_get_display('node', $type_name, 'default')
->setComponent($field['name'])
->setComponent($name)
->save();
return $field_instance;
return $field_instance_config;
}

View File

@ -49,13 +49,13 @@ class ImageItemTest extends FieldUnitTestBase {
$this->installSchema('file', array('file_managed', 'file_usage'));
entity_create('field_entity', array(
entity_create('field_config', array(
'name' => 'image_test',
'entity_type' => 'entity_test',
'type' => 'image',
'cardinality' => FieldDefinitionInterface::CARDINALITY_UNLIMITED,
))->save();
entity_create('field_instance', array(
entity_create('field_instance_config', array(
'entity_type' => 'entity_test',
'field_name' => 'image_test',
'bundle' => 'entity_test',

View File

@ -45,13 +45,13 @@ class ImageThemeFunctionTest extends WebTestBase {
public function setUp() {
parent::setUp();
entity_create('field_entity', array(
entity_create('field_config', array(
'name' => 'image_test',
'entity_type' => 'entity_test',
'type' => 'image',
'cardinality' => FieldDefinitionInterface::CARDINALITY_UNLIMITED,
))->save();
entity_create('field_instance', array(
entity_create('field_instance_config', array(
'entity_type' => 'entity_test',
'field_name' => 'image_test',
'bundle' => 'entity_test',

View File

@ -24,14 +24,14 @@ class LinkFieldTest extends WebTestBase {
/**
* A field to use in this test class.
*
* @var \Drupal\field\Entity\Field
* @var \Drupal\field\Entity\FieldConfig
*/
protected $field;
/**
* The instance used in this test class.
*
* @var \Drupal\field\Entity\FieldInstance
* @var \Drupal\field\Entity\FieldInstanceConfig
*/
protected $instance;
@ -66,13 +66,13 @@ class LinkFieldTest extends WebTestBase {
function testURLValidation() {
$field_name = drupal_strtolower($this->randomName());
// Create a field with settings to validate.
$this->field = entity_create('field_entity', array(
$this->field = entity_create('field_config', array(
'name' => $field_name,
'entity_type' => 'entity_test',
'type' => 'link',
));
$this->field->save();
entity_create('field_instance', array(
entity_create('field_instance_config', array(
'field_name' => $field_name,
'entity_type' => 'entity_test',
'bundle' => 'entity_test',
@ -139,13 +139,13 @@ class LinkFieldTest extends WebTestBase {
function testLinkTitle() {
$field_name = drupal_strtolower($this->randomName());
// Create a field with settings to validate.
$this->field = entity_create('field_entity', array(
$this->field = entity_create('field_config', array(
'name' => $field_name,
'entity_type' => 'entity_test',
'type' => 'link',
));
$this->field->save();
$this->instance = entity_create('field_instance', array(
$this->instance = entity_create('field_instance_config', array(
'field_name' => $field_name,
'entity_type' => 'entity_test',
'bundle' => 'entity_test',
@ -257,14 +257,14 @@ class LinkFieldTest extends WebTestBase {
function testLinkFormatter() {
$field_name = drupal_strtolower($this->randomName());
// Create a field with settings to validate.
$this->field = entity_create('field_entity', array(
$this->field = entity_create('field_config', array(
'name' => $field_name,
'entity_type' => 'entity_test',
'type' => 'link',
'cardinality' => 2,
));
$this->field->save();
entity_create('field_instance', array(
entity_create('field_instance_config', array(
'field_name' => $field_name,
'entity_type' => 'entity_test',
'label' => 'Read more about this entity',
@ -399,14 +399,14 @@ class LinkFieldTest extends WebTestBase {
function testLinkSeparateFormatter() {
$field_name = drupal_strtolower($this->randomName());
// Create a field with settings to validate.
$this->field = entity_create('field_entity', array(
$this->field = entity_create('field_config', array(
'name' => $field_name,
'entity_type' => 'entity_test',
'type' => 'link',
'cardinality' => 2,
));
$this->field->save();
entity_create('field_instance', array(
entity_create('field_instance_config', array(
'field_name' => $field_name,
'entity_type' => 'entity_test',
'bundle' => 'entity_test',

View File

@ -35,12 +35,12 @@ class LinkItemTest extends FieldUnitTestBase {
parent::setUp();
// Create an link field and instance for validation.
entity_create('field_entity', array(
entity_create('field_config', array(
'name' => 'field_test',
'entity_type' => 'entity_test',
'type' => 'link',
))->save();
entity_create('field_instance', array(
entity_create('field_instance_config', array(
'entity_type' => 'entity_test',
'field_name' => 'field_test',
'bundle' => 'entity_test',

View File

@ -37,7 +37,7 @@ class MultiStepNodeFormBasicOptionsTest extends NodeTestBase {
// Create an unlimited cardinality field.
$this->field_name = drupal_strtolower($this->randomName());
entity_create('field_entity', array(
entity_create('field_config', array(
'name' => $this->field_name,
'entity_type' => 'node',
'type' => 'text',
@ -45,7 +45,7 @@ class MultiStepNodeFormBasicOptionsTest extends NodeTestBase {
))->save();
// Attach an instance of the field to the page content type.
entity_create('field_instance', array(
entity_create('field_instance_config', array(
'field_name' => $this->field_name,
'entity_type' => 'node',
'bundle' => 'page',

View File

@ -59,12 +59,12 @@ class NodeAccessFieldTest extends NodeTestBase {
// Add a custom field to the page content type.
$this->field_name = drupal_strtolower($this->randomName() . '_field_name');
entity_create('field_entity', array(
entity_create('field_config', array(
'name' => $this->field_name,
'entity_type' => 'node',
'type' => 'text'
))->save();
entity_create('field_instance', array(
entity_create('field_instance_config', array(
'field_name' => $this->field_name,
'entity_type' => 'node',
'bundle' => 'page',

View File

@ -67,7 +67,7 @@ class PagePreviewTest extends NodeTestBase {
// Set up a field and instance.
$this->field_name = drupal_strtolower($this->randomName());
entity_create('field_entity', array(
entity_create('field_config', array(
'name' => $this->field_name,
'entity_type' => 'node',
'type' => 'taxonomy_term_reference',
@ -81,7 +81,7 @@ class PagePreviewTest extends NodeTestBase {
),
'cardinality' => '-1',
))->save();
entity_create('field_instance', array(
entity_create('field_instance_config', array(
'field_name' => $this->field_name,
'entity_type' => 'node',
'bundle' => 'page',

View File

@ -415,7 +415,7 @@ function node_add_body_field(NodeTypeInterface $type, $label = 'Body') {
$field = field_info_field('node', 'body');
$instance = field_info_instance('node', 'body', $type->id());
if (empty($field)) {
$field = entity_create('field_entity', array(
$field = entity_create('field_config', array(
'name' => 'body',
'entity_type' => 'node',
'type' => 'text_with_summary',
@ -423,7 +423,7 @@ function node_add_body_field(NodeTypeInterface $type, $label = 'Body') {
$field->save();
}
if (empty($instance)) {
$instance = entity_create('field_instance', array(
$instance = entity_create('field_instance_config', array(
'field_name' => 'body',
'entity_type' => 'node',
'bundle' => $type->id(),

View File

@ -13,7 +13,7 @@
* (restricted access) in a given translation.
*/
function node_access_test_language_install() {
$field_private = entity_create('field_entity', array(
$field_private = entity_create('field_config', array(
'name' => 'field_private',
'entity_type' => 'node',
'type' => 'list_boolean',
@ -25,7 +25,7 @@ function node_access_test_language_install() {
));
$field_private->save();
entity_create('field_instance', array(
entity_create('field_instance_config', array(
'field_name' => $field_private->name,
'entity_type' => 'node',
'bundle' => 'page',
@ -39,5 +39,5 @@ function node_access_test_language_install() {
* Implements hook_uninstall().
*/
function node_access_test_language_uninstall() {
entity_load('field_instance', 'node.page.field_private')->delete();
entity_load('field_instance_config', 'node.page.field_private')->delete();
}

View File

@ -24,14 +24,14 @@ class NumberFieldTest extends WebTestBase {
/**
* A field to use in this class.
*
* @var \Drupal\field\Entity\Field
* @var \Drupal\field\Entity\FieldConfig
*/
protected $field;
/**
* A field instance to use in this test class.
*
* @var \Drupal\field\Entity\FieldInstance
* @var \Drupal\field\Entity\FieldInstanceConfig
*/
protected $instance;
@ -63,7 +63,7 @@ class NumberFieldTest extends WebTestBase {
function testNumberDecimalField() {
// Create a field with settings to validate.
$field_name = drupal_strtolower($this->randomName());
entity_create('field_entity', array(
entity_create('field_config', array(
'name' => $field_name,
'entity_type' => 'entity_test',
'type' => 'number_decimal',
@ -71,7 +71,7 @@ class NumberFieldTest extends WebTestBase {
'precision' => 8, 'scale' => 4, 'decimal_separator' => '.',
)
))->save();
entity_create('field_instance', array(
entity_create('field_instance_config', array(
'field_name' => $field_name,
'entity_type' => 'entity_test',
'bundle' => 'entity_test',
@ -208,19 +208,19 @@ class NumberFieldTest extends WebTestBase {
// Create a content type containing float and integer fields.
$this->drupalCreateContentType(array('type' => $type));
entity_create('field_entity', array(
entity_create('field_config', array(
'name' => $float_field,
'entity_type' => 'node',
'type' => 'number_float',
))->save();
entity_create('field_entity', array(
entity_create('field_config', array(
'name' => $integer_field,
'entity_type' => 'node',
'type' => 'number_integer',
))->save();
entity_create('field_instance', array(
entity_create('field_instance_config', array(
'field_name' => $float_field,
'entity_type' => 'node',
'bundle' => $type,
@ -230,7 +230,7 @@ class NumberFieldTest extends WebTestBase {
),
))->save();
entity_create('field_instance', array(
entity_create('field_instance_config', array(
'field_name' => $integer_field,
'entity_type' => 'node',
'bundle' => $type,

View File

@ -36,12 +36,12 @@ class NumberItemTest extends FieldUnitTestBase {
// Create number fields and instances for validation.
foreach (array('integer', 'float', 'decimal') as $type) {
entity_create('field_entity', array(
entity_create('field_config', array(
'name' => 'field_' . $type,
'entity_type' => 'entity_test',
'type' => 'number_' . $type,
))->save();
entity_create('field_instance', array(
entity_create('field_instance_config', array(
'entity_type' => 'entity_test',
'field_name' => 'field_' . $type,
'bundle' => 'entity_test',

View File

@ -32,7 +32,7 @@ class OptionsDynamicValuesTest extends FieldTestBase {
parent::setUp();
$this->field_name = 'test_options';
entity_create('field_entity', array(
entity_create('field_config', array(
'name' => $this->field_name,
'entity_type' => 'entity_test_rev',
'type' => 'list_text',
@ -41,7 +41,7 @@ class OptionsDynamicValuesTest extends FieldTestBase {
'allowed_values_function' => 'options_test_dynamic_values_callback',
),
))->save();
$this->instance = entity_create('field_instance', array(
$this->instance = entity_create('field_instance_config', array(
'field_name' => $this->field_name,
'entity_type' => 'entity_test_rev',
'bundle' => 'entity_test_rev',

View File

@ -81,8 +81,8 @@ class OptionsFieldTest extends OptionsFieldUnitTestBase {
// Options are reset when a new field with the same name is created.
$this->field->delete();
entity_create('field_entity', $this->fieldDefinition)->save();
entity_create('field_instance', array(
entity_create('field_config', $this->fieldDefinition)->save();
entity_create('field_instance_config', array(
'field_name' => $this->fieldName,
'entity_type' => 'entity_test',
'bundle' => 'entity_test',

View File

@ -258,12 +258,12 @@ class OptionsFieldUITest extends FieldTestBase {
*/
protected function createOptionsField($type) {
// Create a test field and instance.
entity_create('field_entity', array(
entity_create('field_config', array(
'name' => $this->field_name,
'entity_type' => 'node',
'type' => $type,
))->save();
entity_create('field_instance', array(
entity_create('field_instance_config', array(
'field_name' => $this->field_name,
'entity_type' => 'node',
'bundle' => $this->type,

View File

@ -39,14 +39,14 @@ class OptionsFieldUnitTestBase extends FieldUnitTestBase {
/**
* The list field used in the test.
*
* @var \Drupal\field\Entity\Field
* @var \Drupal\field\Entity\FieldConfig
*/
protected $field;
/**
* The list field instance used in the test.
*
* @var \Drupal\field\Entity\FieldInstance
* @var \Drupal\field\Entity\FieldInstanceConfig
*/
protected $instance;
@ -66,7 +66,7 @@ class OptionsFieldUnitTestBase extends FieldUnitTestBase {
'allowed_values' => array(1 => 'One', 2 => 'Two', 3 => 'Three'),
),
);
$this->field = entity_create('field_entity', $this->fieldDefinition);
$this->field = entity_create('field_config', $this->fieldDefinition);
$this->field->save();
$instance = array(
@ -74,7 +74,7 @@ class OptionsFieldUnitTestBase extends FieldUnitTestBase {
'entity_type' => 'entity_test',
'bundle' => 'entity_test',
);
$this->instance = entity_create('field_instance', $instance);
$this->instance = entity_create('field_instance_config', $instance);
$this->instance->save();
entity_get_form_display('entity_test', 'entity_test', 'default')

View File

@ -24,21 +24,21 @@ class OptionsWidgetsTest extends FieldTestBase {
/**
* A field with cardinality 1 to use in this test class.
*
* @var \Drupal\field\Entity\Field
* @var \Drupal\field\Entity\FieldConfig
*/
protected $card_1;
/**
* A field with cardinality 2 to use in this test class.
*
* @var \Drupal\field\Entity\Field
* @var \Drupal\field\Entity\FieldConfig
*/
protected $card_2;
/**
* A boolean field to use in this test class.
*
* @var \Drupal\field\Entity\Field
* @var \Drupal\field\Entity\FieldConfig
*/
protected $bool;
@ -62,7 +62,7 @@ class OptionsWidgetsTest extends FieldTestBase {
parent::setUp();
// Field with cardinality 1.
$this->card_1 = entity_create('field_entity', array(
$this->card_1 = entity_create('field_config', array(
'name' => 'card_1',
'entity_type' => 'entity_test',
'type' => 'list_integer',
@ -75,7 +75,7 @@ class OptionsWidgetsTest extends FieldTestBase {
$this->card_1->save();
// Field with cardinality 2.
$this->card_2 = entity_create('field_entity', array(
$this->card_2 = entity_create('field_config', array(
'name' => 'card_2',
'entity_type' => 'entity_test',
'type' => 'list_integer',
@ -88,7 +88,7 @@ class OptionsWidgetsTest extends FieldTestBase {
$this->card_2->save();
// Boolean field.
$this->bool = entity_create('field_entity', array(
$this->bool = entity_create('field_config', array(
'name' => 'bool',
'entity_type' => 'entity_test',
'type' => 'list_boolean',
@ -109,7 +109,7 @@ class OptionsWidgetsTest extends FieldTestBase {
*/
function testRadioButtons() {
// Create an instance of the 'single value' field.
$instance = entity_create('field_instance', array(
$instance = entity_create('field_instance_config', array(
'field_name' => $this->card_1->getName(),
'entity_type' => 'entity_test',
'bundle' => 'entity_test',
@ -166,7 +166,7 @@ class OptionsWidgetsTest extends FieldTestBase {
*/
function testCheckBoxes() {
// Create an instance of the 'multiple values' field.
$instance = entity_create('field_instance', array(
$instance = entity_create('field_instance_config', array(
'field_name' => $this->card_2->getName(),
'entity_type' => 'entity_test',
'bundle' => 'entity_test',
@ -256,7 +256,7 @@ class OptionsWidgetsTest extends FieldTestBase {
*/
function testSelectListSingle() {
// Create an instance of the 'single value' field.
$instance = entity_create('field_instance', array(
$instance = entity_create('field_instance_config', array(
'field_name' => $this->card_1->getName(),
'entity_type' => 'entity_test',
'bundle' => 'entity_test',
@ -356,7 +356,7 @@ class OptionsWidgetsTest extends FieldTestBase {
*/
function testSelectListMultiple() {
// Create an instance of the 'multiple values' field.
$instance = entity_create('field_instance', array(
$instance = entity_create('field_instance_config', array(
'field_name' => $this->card_2->getName(),
'entity_type' => 'entity_test',
'bundle' => 'entity_test',
@ -477,7 +477,7 @@ class OptionsWidgetsTest extends FieldTestBase {
*/
function testOnOffCheckbox() {
// Create an instance of the 'boolean' field.
entity_create('field_instance', array(
entity_create('field_instance_config', array(
'field_name' => $this->bool->getName(),
'entity_type' => 'entity_test',
'bundle' => 'entity_test',
@ -533,7 +533,7 @@ class OptionsWidgetsTest extends FieldTestBase {
// Create a test field instance.
$field_name = 'bool';
entity_create('field_entity', array(
entity_create('field_config', array(
'name' => $field_name,
'entity_type' => 'node',
'type' => 'list_boolean',
@ -542,7 +542,7 @@ class OptionsWidgetsTest extends FieldTestBase {
'allowed_values' => array(0 => 'Zero', 1 => 'Some <script>dangerous</script> & unescaped <strong>markup</strong>'),
),
))->save();
entity_create('field_instance', array(
entity_create('field_instance_config', array(
'field_name' => $field_name,
'entity_type' => 'node',
'bundle' => 'page',

View File

@ -43,16 +43,16 @@ function options_field_settings_form_value_boolean_allowed_values($element, $inp
}
/**
* Implements hook_ENTITY_TYPE_update() for 'field_entity'.
* Implements hook_ENTITY_TYPE_update() for 'field_config'.
*/
function options_field_entity_update(FieldInterface $field) {
function options_field_config_update(FieldInterface $field) {
drupal_static_reset('options_allowed_values');
}
/**
* Implements hook_ENTITY_TYPE_delete() for 'field_entity'.
* Implements hook_ENTITY_TYPE_delete() for 'field_config'.
*/
function options_field_entity_delete(FieldInterface $field) {
function options_field_config_delete(FieldInterface $field) {
drupal_static_reset('options_allowed_values');
}

View File

@ -88,12 +88,12 @@ abstract class FieldRdfaTestBase extends FieldUnitTestBase {
* Creates the field for testing.
*/
protected function createTestField() {
entity_create('field_entity', array(
entity_create('field_config', array(
'name' => $this->fieldName,
'entity_type' => 'entity_test',
'type' => $this->fieldType,
))->save();
entity_create('field_instance', array(
entity_create('field_instance_config', array(
'entity_type' => 'entity_test',
'field_name' => $this->fieldName,
'bundle' => 'entity_test',

View File

@ -59,7 +59,7 @@ class TaxonomyTermReferenceRdfaTest extends FieldRdfaTestBase {
));
$vocabulary->save();
entity_create('field_entity', array(
entity_create('field_config', array(
'name' => $this->fieldName,
'entity_type' => 'entity_test',
'type' => 'taxonomy_term_reference',
@ -73,7 +73,7 @@ class TaxonomyTermReferenceRdfaTest extends FieldRdfaTestBase {
),
),
))->save();
entity_create('field_instance', array(
entity_create('field_instance_config', array(
'entity_type' => 'entity_test',
'field_name' => $this->fieldName,
'bundle' => 'entity_test',

View File

@ -155,7 +155,7 @@ class TaxonomyTermFieldAttributesTest extends TaxonomyTestBase {
* @todo Move this to TaxonomyTestBase, like the other field modules.
*/
protected function createTaxonomyTermReferenceField($field_name, $vocabulary) {
entity_create('field_entity', array(
entity_create('field_config', array(
'name' => $field_name,
'entity_type' => 'node',
'type' => 'taxonomy_term_reference',
@ -169,7 +169,7 @@ class TaxonomyTermFieldAttributesTest extends TaxonomyTestBase {
),
),
))->save();
entity_create('field_instance', array(
entity_create('field_instance_config', array(
'field_name' => $field_name,
'entity_type' => 'node',
'bundle' => 'article',

Some files were not shown because too many files have changed in this diff Show More