Commit f8f024e3 authored by alexpott's avatar alexpott

Issue #2030637 by yched, Mile23, daffie, Alumei, tidrif, chertzog, Berdir,...

Issue #2030637 by yched, Mile23, daffie, Alumei, tidrif, chertzog, Berdir, swentel, ofry: Expand FieldConfig/BaseFieldOverride/FieldConfigBase with methods
parent 6b8cc669
......@@ -1213,8 +1213,8 @@ public function onBundleRename($bundle_old, $bundle_new, $entity_type_id) {
// Rename existing base field bundle overrides.
$overrides = $this->getStorage('base_field_override')->loadByProperties(array('entity_type' => $entity_type_id, 'bundle' => $bundle_old));
foreach ($overrides as $override) {
$override->set('id', $entity_type_id . '.' . $bundle_new . '.' . $override->field_name);
$override->bundle = $bundle_new;
$override->set('id', $entity_type_id . '.' . $bundle_new . '.' . $override->getName());
$override->set('bundle', $bundle_new);
$override->allowBundleRename();
$override->save();
}
......
......@@ -28,14 +28,14 @@ abstract class FieldConfigBase extends ConfigEntityBase implements FieldConfigIn
*
* @var string
*/
public $id;
protected $id;
/**
* The field name.
*
* @var string
*/
public $field_name;
protected $field_name;
/**
* The field type.
......@@ -48,21 +48,21 @@ abstract class FieldConfigBase extends ConfigEntityBase implements FieldConfigIn
*
* @var string
*/
public $field_type;
protected $field_type;
/**
* The name of the entity type the field is attached to.
*
* @var string
*/
public $entity_type;
protected $entity_type;
/**
* The name of the bundle the field is attached to.
*
* @var string
*/
public $bundle;
protected $bundle;
/**
* The human-readable label for the field.
......@@ -75,7 +75,7 @@ abstract class FieldConfigBase extends ConfigEntityBase implements FieldConfigIn
*
* @var string
*/
public $label;
protected $label;
/**
* The field description.
......@@ -86,7 +86,7 @@ abstract class FieldConfigBase extends ConfigEntityBase implements FieldConfigIn
*
* @var string
*/
public $description = '';
protected $description = '';
/**
* Field-type specific settings.
......@@ -96,7 +96,7 @@ abstract class FieldConfigBase extends ConfigEntityBase implements FieldConfigIn
*
* @var array
*/
public $settings = array();
protected $settings = array();
/**
* Flag indicating whether the field is required.
......@@ -107,7 +107,7 @@ abstract class FieldConfigBase extends ConfigEntityBase implements FieldConfigIn
*
* @var bool
*/
public $required = FALSE;
protected $required = FALSE;
/**
* Flag indicating whether the field is translatable.
......@@ -116,7 +116,7 @@ abstract class FieldConfigBase extends ConfigEntityBase implements FieldConfigIn
*
* @var bool
*/
public $translatable = TRUE;
protected $translatable = TRUE;
/**
* Default field value.
......@@ -164,7 +164,7 @@ abstract class FieldConfigBase extends ConfigEntityBase implements FieldConfigIn
*
* @var string
*/
public $default_value_callback = '';
protected $default_value_callback = '';
/**
* The field storage object.
......@@ -302,20 +302,31 @@ public function postSave(EntityStorageInterface $storage, $update = TRUE) {
/**
* {@inheritdoc}
*/
public function getSettings() {
return $this->settings + $this->getFieldStorageDefinition()->getSettings();
public function getLabel() {
return $this->label();
}
/**
* {@inheritdoc}
*/
public function getSetting($setting_name) {
if (array_key_exists($setting_name, $this->settings)) {
return $this->settings[$setting_name];
}
else {
return $this->getFieldStorageDefinition()->getSetting($setting_name);
}
public function setLabel($label) {
$this->label = $label;
return $this;
}
/**
* {@inheritdoc}
*/
public function getDescription() {
return $this->description;
}
/**
* {@inheritdoc}
*/
public function setDescription($description) {
$this->description = $description;
return $this;
}
/**
......@@ -337,23 +348,35 @@ public function setTranslatable($translatable) {
/**
* {@inheritdoc}
*/
public function setLabel($label) {
$this->label = $label;
public function getSettings() {
return $this->settings + $this->getFieldStorageDefinition()->getSettings();
}
/**
* {@inheritdoc}
*/
public function setSettings(array $settings) {
$this->settings = $settings;
return $this;
}
/**
* {@inheritdoc}
*/
public function getLabel() {
return $this->label();
public function getSetting($setting_name) {
if (array_key_exists($setting_name, $this->settings)) {
return $this->settings[$setting_name];
}
else {
return $this->getFieldStorageDefinition()->getSetting($setting_name);
}
}
/**
* {@inheritdoc}
*/
public function getDescription() {
return $this->description;
public function setSetting($setting_name, $value) {
$this->settings[$setting_name] = $value;
}
/**
......@@ -363,6 +386,14 @@ public function isRequired() {
return $this->required;
}
/**
* [@inheritdoc}
*/
public function setRequired($required) {
$this->required = $required;
return $this;
}
/**
* {@inheritdoc}
*/
......@@ -420,6 +451,9 @@ public static function createFromDataType($type) {
return BaseFieldDefinition::createFromDataType($type);
}
/**
* {@inheritdoc}
*/
public function getDataType() {
return 'list';
}
......
......@@ -31,6 +31,19 @@ interface FieldConfigInterface extends FieldDefinitionInterface, ConfigEntityInt
*/
public function setLabel($label);
/**
* Sets a human readable description.
*
* Descriptions are usually used on user interfaces where the data is edited
* or displayed.
*
* @param string $description
* The description for this field.
*
* @return $this
*/
public function setDescription($description);
/**
* Sets whether the field is translatable.
*
......@@ -42,13 +55,43 @@ public function setLabel($label);
public function setTranslatable($translatable);
/**
* Allows a bundle to be renamed.
* Sets field settings (overwrites existing settings).
*
* Renaming a bundle on the instance is allowed when an entity's bundle
* is renamed and when field_entity_bundle_rename() does internal
* housekeeping.
* @param array $settings
* The array of field settings.
*
* @return $this
*/
public function allowBundleRename();
public function setSettings(array $settings);
/**
* Sets the value for a field setting by name.
*
* @param string $setting_name
* The name of the setting.
* @param mixed $value
* The value of the setting.
*
* @return $this
*/
public function setSetting($setting_name, $value);
/**
* Sets whether the field can be empty.
*
* If a field is required, an entity needs to have at least a valid,
* non-empty item in that field's FieldItemList in order to pass validation.
*
* An item is considered empty if its isEmpty() method returns TRUE.
* Typically, that is if at least one of its required properties is empty.
*
* @param bool $required
* TRUE if the field is required. FALSE otherwise.
*
* @return $this
* The current object, for a fluent interface.
*/
public function setRequired($required);
/**
* Sets a default value.
......@@ -191,4 +234,13 @@ public function addConstraint($constraint_name, $options = NULL);
*/
public function setConstraints(array $constraints);
/**
* Allows a bundle to be renamed.
*
* Renaming a bundle on the instance is allowed when an entity's bundle
* is renamed and when field_entity_bundle_rename() does internal
* housekeeping.
*/
public function allowBundleRename();
}
......@@ -12,7 +12,6 @@
use Drupal\Core\TypedData\DataDefinitionInterface;
use Drupal\Core\TypedData\Plugin\DataType\Map;
use Drupal\Core\TypedData\TypedDataInterface;
use Drupal\user;
/**
* An entity field item.
......
......@@ -314,7 +314,7 @@ public function defaultValuesFormValidate(array $element, array &$form, FormStat
$widget->extractFormValues($this, $element, $form_state);
// Force a non-required field definition.
// @see self::defaultValueWidget().
$this->definition->required = FALSE;
$this->getFieldDefinition()->setRequired(FALSE);
$violations = $this->validate();
// Assign reported errors to the correct form element.
......@@ -354,8 +354,9 @@ protected function defaultValueWidget(FormStateInterface $form_state) {
$entity = $this->getEntity();
// Force a non-required widget.
$this->getFieldDefinition()->required = FALSE;
$this->getFieldDefinition()->description = '';
$definition = $this->getFieldDefinition();
$definition->setRequired(FALSE);
$definition->setDescription('');
// Use the widget currently configured for the 'default' form mode, or
// fallback to the default widget for the field type.
......
......@@ -144,7 +144,7 @@ function comment_field_config_create(FieldConfigInterface $field) {
if ($field->getType() == 'comment' && !$field->isSyncing()) {
// Assign default values for the field.
if (!isset($field->default_value)) {
$field->default_value = array();
$field->setDefaultValue(array());
}
$field->default_value += array(array());
$field->default_value[0] += array(
......
......@@ -54,7 +54,7 @@ protected function createEntity() {
// Display comments in a flat list; threaded comments are not render cached.
$field = FieldConfig::loadByName('entity_test', 'bar', 'comment');
$field->settings['default_mode'] = CommentManagerInterface::COMMENT_MODE_FLAT;
$field->setSetting('default_mode', CommentManagerInterface::COMMENT_MODE_FLAT);
$field->save();
// Create a "Camelids" test entity.
......
......@@ -136,7 +136,7 @@ public function testAccessToAdministrativeFields() {
// Change the second field's anonymous contact setting.
$instance = FieldConfig::loadByName('entity_test', 'entity_test', 'comment_other');
// Default is 'May not contact', for this field - they may contact.
$instance->settings['anonymous'] = COMMENT_ANONYMOUS_MAY_CONTACT;
$instance->setSetting('anonymous', COMMENT_ANONYMOUS_MAY_CONTACT);
$instance->save();
// Create three "Comments". One is owned by our edit-enabled user.
......
......@@ -117,7 +117,7 @@ public function postComment($entity, $comment, $subject = '', $contact = NULL, $
else {
$field = FieldConfig::loadByName('node', 'article', $field_name);
}
$preview_mode = $field->settings['preview'];
$preview_mode = $field->getSetting('preview');
// Must get the page before we test for fields.
if ($entity !== NULL) {
......@@ -314,7 +314,7 @@ public function setCommentsPerPage($number, $field_name = 'comment') {
*/
public function setCommentSettings($name, $value, $message, $field_name = 'comment') {
$field = FieldConfig::loadByName('node', 'article', $field_name);
$field->settings[$name] = $value;
$field->setSetting($name, $value);
$field->save();
// Display status message.
$this->pass($message);
......
......@@ -139,7 +139,7 @@ public function testValidation() {
$comment->set('thread', NULL);
// Force anonymous users to enter contact details.
$field->settings['anonymous'] = COMMENT_ANONYMOUS_MUST_CONTACT;
$field->setSetting('anonymous', COMMENT_ANONYMOUS_MUST_CONTACT);
$field->save();
// Reset the node entity.
\Drupal::entityManager()->getStorage('node')->resetCache([$node->id()]);
......
......@@ -150,7 +150,7 @@ public function testExportImport() {
// Delete the custom field.
$fields = FieldConfig::loadMultiple();
foreach ($fields as $field) {
if ($field->field_name == $this->fieldName) {
if ($field->getName() == $this->fieldName) {
$field->delete();
}
}
......
......@@ -330,7 +330,7 @@ function content_translation_entity_extra_field_info() {
*/
function content_translation_form_field_config_edit_form_alter(array &$form, FormStateInterface $form_state) {
$field = $form_state->getFormObject()->getEntity();
$bundle_is_translatable = \Drupal::service('content_translation.manager')->isEnabled($field->entity_type, $field->bundle);
$bundle_is_translatable = \Drupal::service('content_translation.manager')->isEnabled($field->getTargetEntityTypeId(), $field->getTargetBundle());
$form['translatable'] = array(
'#type' => 'checkbox',
......
......@@ -75,7 +75,7 @@ protected function setUp() {
));
$this->field->save();
entity_get_form_display($this->field->entity_type, $this->field->bundle, 'default')
entity_get_form_display($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'default')
->setComponent($field_name, array(
'type' => 'datetime_default',
))
......@@ -86,7 +86,7 @@ protected function setUp() {
'label' => 'hidden',
'settings' => array('format_type' => 'medium'),
);
entity_get_display($this->field->entity_type, $this->field->bundle, 'full')
entity_get_display($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full')
->setComponent($field_name, $this->displayOptions)
->save();
}
......@@ -130,7 +130,7 @@ function testDateField() {
foreach ($values as $new_value) {
// Update the entity display settings.
$this->displayOptions['settings'] = array($setting => $new_value);
entity_get_display($this->field->entity_type, $this->field->bundle, 'full')
entity_get_display($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full')
->setComponent($field_name, $this->displayOptions)
->save();
......@@ -149,7 +149,7 @@ function testDateField() {
// Verify that the plain formatter works.
$this->displayOptions['type'] = 'datetime_plain';
$this->displayOptions['settings'] = array();
entity_get_display($this->field->entity_type, $this->field->bundle, 'full')
entity_get_display($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full')
->setComponent($field_name, $this->displayOptions)
->save();
$expected = $date->format(DATETIME_DATE_STORAGE_FORMAT);
......@@ -196,7 +196,7 @@ function testDatetimeField() {
foreach ($values as $new_value) {
// Update the entity display settings.
$this->displayOptions['settings'] = array($setting => $new_value);
entity_get_display($this->field->entity_type, $this->field->bundle, 'full')
entity_get_display($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full')
->setComponent($field_name, $this->displayOptions)
->save();
......@@ -215,7 +215,7 @@ function testDatetimeField() {
// Verify that the plain formatter works.
$this->displayOptions['type'] = 'datetime_plain';
$this->displayOptions['settings'] = array();
entity_get_display($this->field->entity_type, $this->field->bundle, 'full')
entity_get_display($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full')
->setComponent($field_name, $this->displayOptions)
->save();
$expected = $date->format(DATETIME_DATETIME_STORAGE_FORMAT);
......@@ -233,7 +233,7 @@ function testDatelistWidget() {
$this->fieldStorage->save();
// Change the widget to a datelist widget.
entity_get_form_display($this->field->entity_type, $this->field->bundle, 'default')
entity_get_form_display($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'default')
->setComponent($field_name, array(
'type' => 'datetime_datelist',
'settings' => array(
......
......@@ -95,7 +95,7 @@ function entity_reference_field_storage_config_update(FieldStorageConfigInterfac
foreach ($field_storage->getBundles() as $bundle) {
$field = FieldConfig::loadByName($field_storage->getTargetEntityTypeId(), $bundle, $field_storage->getName());
$field->settings['handler_settings'] = array();
$field->setSetting('handler_settings', []);
$field->save();
}
}
......@@ -119,7 +119,7 @@ function entity_reference_field_config_presave(FieldConfigInterface $field) {
$target_type = $field->getFieldStorageDefinition()->getSetting('target_type');
$selection_manager = \Drupal::service('plugin.manager.entity_reference_selection');
list($current_handler) = explode(':', $field->getSetting('handler'), 2);
$field->settings['handler'] = $selection_manager->getPluginId($target_type, $current_handler);
$field->setSetting('handler', $selection_manager->getPluginId($target_type, $current_handler));
}
/**
......
......@@ -227,9 +227,9 @@ function field_entity_bundle_field_info(EntityTypeInterface $entity_type, $bundl
function field_entity_bundle_rename($entity_type, $bundle_old, $bundle_new) {
$fields = entity_load_multiple_by_properties('field_config', array('entity_type' => $entity_type, 'bundle' => $bundle_old, 'include_deleted' => TRUE));
foreach ($fields as $field) {
$id_new = $field->entity_type . '.' . $bundle_new . '.' . $field->field_name;
$id_new = $field->getTargetEntityTypeId() . '.' . $bundle_new . '.' . $field->getName();
$field->set('id', $id_new);
$field->bundle = $bundle_new;
$field->set('bundle', $bundle_new);
// Save non-deleted fields.
if (!$field->isDeleted()) {
$field->allowBundleRename();
......
......@@ -46,7 +46,7 @@ class FieldConfig extends FieldConfigBase implements FieldConfigInterface {
*
* @var bool
*/
public $deleted = FALSE;
protected $deleted = FALSE;
/**
* The associated FieldStorageConfig entity.
......
......@@ -29,10 +29,10 @@ protected function checkAccess(EntityInterface $entity, $operation, $langcode, A
return AccessResult::forbidden()->cacheUntilEntityChanges($field_storage_entity);
}
else {
return AccessResult::allowedIfHasPermission($account, 'administer ' . $entity->entity_type . ' fields')->cacheUntilEntityChanges($field_storage_entity);
return AccessResult::allowedIfHasPermission($account, 'administer ' . $entity->getTargetEntityTypeId() . ' fields')->cacheUntilEntityChanges($field_storage_entity);
}
}
return AccessResult::allowedIfHasPermission($account, 'administer ' . $entity->entity_type . ' fields');
return AccessResult::allowedIfHasPermission($account, 'administer ' . $entity->getTargetEntityTypeId() . ' fields');
}
}
......@@ -158,8 +158,12 @@ public function loadByProperties(array $conditions = array()) {
$checked_value = $field->uuid();
break;
case 'deleted';
$checked_value = $field->isDeleted();
break;
default:
$checked_value = $field->$key;
$checked_value = $field->get($key);
break;
}
......
......@@ -179,7 +179,7 @@ function testDeleteField() {
$fields = entity_load_multiple_by_properties('field_config', array('field_storage_uuid' => $field_storage->uuid(), 'deleted' => TRUE, 'include_deleted' => TRUE));
$this->assertEqual(count($fields), 1, 'There is one deleted field');
$field = $fields[$field->uuid()];
$this->assertEqual($field->bundle, $bundle, 'The deleted field is for the correct bundle');
$this->assertEqual($field->getTargetBundle(), $bundle, 'The deleted field is for the correct bundle');
// Check that the actual stored content did not change during delete.
$storage = \Drupal::entityManager()->getStorage($this->entityTypeId);
......@@ -309,7 +309,7 @@ function testPurgeFieldStorage() {
// The field still exists, deleted.
$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');
$this->assertTrue(isset($fields[$field->uuid()]) && $fields[$field->uuid()]->isDeleted(), 'The field exists and is deleted');
// Purge again to purge the field.
field_purge_batch(0);
......@@ -344,7 +344,7 @@ function testPurgeFieldStorage() {
// The field and the storage still exist, deleted.
$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');
$this->assertTrue(isset($fields[$field->uuid()]) && $fields[$field->uuid()]->isDeleted(), 'The field exists and is deleted');
$storages = entity_load_multiple_by_properties('field_storage_config', array('uuid' => $field_storage->uuid(), 'include_deleted' => TRUE));
$this->assertTrue(isset($storages[$field_storage->uuid()]) && $storages[$field_storage->uuid()]->isDeleted(), 'The field storage exists and is deleted');
......
......@@ -246,7 +246,7 @@ public function testSelectionHandlerSettings() {
$field = FieldConfig::load($field->id());
$this->assertTrue($field->getSetting('handler') == 'default:entity_test');
$field->settings['handler'] = 'views';
$field->setSetting('handler', 'views');
$field->save();
$field = FieldConfig::load($field->id());
$this->assertTrue($field->getSetting('handler') == 'views');
......
......@@ -165,7 +165,7 @@ function testEntityDisplayViewMultiple() {
*/
function testEntityCache() {
// Initialize random values and a test entity.
$entity_init = entity_create('entity_test', array('type' => $this->fieldTestData->field->bundle));
$entity_init = entity_create('entity_test', array('type' => $this->fieldTestData->field->getTargetBundle()));
$values = $this->_generateTestFieldValues($this->fieldTestData->field_storage->getCardinality());
// Non-cacheable entity type.
......@@ -248,10 +248,10 @@ function testEntityFormDisplayBuildForm() {
$this->createFieldWithStorage('_2');
$entity_type = 'entity_test';
$entity = entity_create($entity_type, array('id' => 1, 'revision_id' => 1, 'type' => $this->fieldTestData->field->bundle));
$entity = entity_create($entity_type, array('id' => 1, 'revision_id' => 1, 'type' => $this->fieldTestData->field->getTargetBundle()));
// Test generating widgets for all fields.
$display = entity_get_form_display($entity_type, $this->fieldTestData->field->bundle, 'default');
$display = entity_get_form_display($entity_type, $this->fieldTestData->field->getTargetBundle(), 'default');
$form = array();
$form_state = new FormState();
$display->buildForm($entity, $form, $form_state);
......@@ -268,7 +268,7 @@ function testEntityFormDisplayBuildForm() {
}
// Test generating widgets for all fields.
$display = entity_get_form_display($entity_type, $this->fieldTestData->field->bundle, 'default');
$display = entity_get_form_display($entity_type, $this->fieldTestData->field->getTargetBundle(), 'default');
foreach ($display->getComponents() as $name => $options) {
if ($name != $this->fieldTestData->field_name_2) {
$display->removeComponent($name);
......@@ -293,10 +293,10 @@ function testEntityFormDisplayExtractFormValues() {
$this->createFieldWithStorage('_2');
$entity_type = 'entity_test';
$entity_init = entity_create($entity_type, array('id' => 1, 'revision_id' => 1, 'type' => $this->fieldTestData->field->bundle));
$entity_init = entity_create($entity_type, array('id' => 1, 'revision_id' => 1, 'type' => $this->fieldTestData->field->getTargetBundle()));
// Build the form for all fields.
$display = entity_get_form_display($entity_type, $this->fieldTestData->field->bundle, 'default');
$display = entity_get_form_display($entity_type, $this->fieldTestData->field->getTargetBundle(), 'default');
$form = array();
$form_state = new FormState();
$display->buildForm($entity_init, $form, $form_state);
......
......@@ -195,7 +195,7 @@ function testFieldAttachSaveEmptyDataDefaultValue() {
$this->createFieldWithStorage('', $entity_type);
// Add a default value function.
$this->fieldTestData->field->default_value_callback = 'field_test_default_value';
$this->fieldTestData->field->set('default_value_callback', 'field_test_default_value');
$this->fieldTestData->field->save();
// Verify that fields are populated with default values.
......@@ -223,7 +223,7 @@ function testFieldAttachDelete() {
$entity_type = 'entity_test_rev';
$this->createFieldWithStorage('', $entity_type);
$cardinality = $this->fieldTestData->field_storage->getCardinality();
$entity = entity_create($entity_type, array('type' => $this->fieldTestData->field->bundle));
$entity = entity_create($entity_type, array('type' => $this->fieldTestData->field->getTargetBundle()));
$vids = array();
// Create revision 0
......@@ -291,7 +291,7 @@ function testEntityCreateRenameBundle() {
entity_create('field_config', $this->fieldTestData->field_definition)->save();
// Save an entity with data in the field.
$entity = entity_create($entity_type, array('type' => $this->fieldTestData->field->bundle));
$entity = entity_create($entity_type, array('type' => $this->fieldTestData->field->getTargetBundle()));
$values = $this->_generateTestFieldValues($cardinality);
$entity->{$this->fieldTestData->field_name} = $values;
......@@ -305,7 +305,7 @@ function testEntityCreateRenameBundle() {
// Check that the field definition has been updated.
$this->fieldTestData->field = FieldConfig::loadByName($entity_type, $new_bundle, $this->fieldTestData->field_name);
$this->assertIdentical($this->fieldTestData->field->bundle, $new_bundle, "Bundle name has been updated in the field.");
$this->assertIdentical($this->fieldTestData->field->getTargetBundle(), $new_bundle, "Bundle name has been updated in the field.");
// Verify the field data is present on load.
$controller = $this->container->get('entity.manager')->getStorage($entity->getEntityTypeId());
......@@ -341,7 +341,7 @@ function testEntityDeleteBundle() {
$field = array(
'field_name' => $field_name,
'entity_type' => $entity_type,
'bundle' => $this->fieldTestData->field->bundle,
'bundle' => $this->fieldTestData->field->getTargetBundle(),
'label' => $this->randomMachineName() . '_label',
'description' => $this->randomMachineName() . '_description',
'weight' => mt_rand(0, 127),
......@@ -349,7 +349,7 @@ function testEntityDeleteBundle() {
entity_create('field_config', $field)->save();
// Save an entity with data for both fields
$entity = entity_create($entity_type, array('type' => $this->fieldTestData->field->bundle));
$entity = entity_create($entity_type, array('type' => $this->fieldTestData->field->getTargetBundle()));
$values = $this->_generateTestFieldValues($this->fieldTestData->field_storage->getCardinality());
$entity->{$this->fieldTestData->field_name} = $values;
$entity->{$field_name} = $this->_generateTestFieldValues(1);
......@@ -360,7 +360,7 @@ function testEntityDeleteBundle() {
$this->assertEqual(count($entity->{$field_name}), 1, 'Second field got loaded');
// Delete the bundle.
entity_test_delete_bundle($this->fieldTestData->field->bundle, $entity_type);
entity_test_delete_bundle($this->fieldTestData->field->getTargetBundle(), $entity_type);
// Verify no data gets loaded
$controller = $this->container->get('entity.manager')->getStorage($entity->getEntityTypeId());
......@@ -371,7 +371,7 @@ function testEntityDeleteBundle() {
$this->assertTrue(empty($entity->{$field_name}), 'No data for second field');
// Verify that the fields are gone.
$this->assertFalse(FieldConfig::load('entity_test.' . $this->fieldTestData->field->bundle . '.' . $this->fieldTestData->field_name), "First field is deleted");
$this->assertFalse(FieldConfig::load('entity_test.' . $this->fieldTestData->field->getTargetBundle() . '.' . $this->fieldTestData->field_name), "First field is deleted");
$this->assertFalse(FieldConfig::load('entity_test.' . $field['bundle']. '.' . $field_name), "Second field is deleted");
}
......
......@@ -146,8 +146,8 @@ function testReadField() {
// Read the field back.
$field = FieldConfig::load('entity_test.' . $this->fieldDefinition['bundle'] . '.' . $this->fieldDefinition['field_name']);
$this->assertTrue($this->fieldDefinition['field_name'] == $field