Issue #2143263 by plopesc | yched: Remove "Field" prefix from FieldDefinitionInterface methods.

8.0.x
Alex Pott 2013-12-09 19:19:58 -04:00
parent 1a80341de7
commit cdac25ee08
146 changed files with 548 additions and 677 deletions

View File

@ -401,8 +401,9 @@ abstract class ContentEntityBase extends Entity implements \IteratorAggregate, C
}
// Non-translatable fields are always stored with
// Language::LANGCODE_DEFAULT as key.
$default = $langcode == Language::LANGCODE_DEFAULT;
if (!$default && !$definition->isFieldTranslatable()) {
if (!$default && !$definition->isTranslatable()) {
if (!isset($this->fields[$name][Language::LANGCODE_DEFAULT])) {
$this->fields[$name][Language::LANGCODE_DEFAULT] = $this->getTranslatedField($name, Language::LANGCODE_DEFAULT);
}
@ -728,7 +729,7 @@ abstract class ContentEntityBase extends Entity implements \IteratorAggregate, C
$definitions = $translation->getPropertyDefinitions();
foreach ($values as $name => $value) {
if (isset($definitions[$name]) && $definitions[$name]->isFieldTranslatable()) {
if (isset($definitions[$name]) && $definitions[$name]->isTranslatable()) {
$translation->$name = $value;
}
}
@ -742,7 +743,7 @@ abstract class ContentEntityBase extends Entity implements \IteratorAggregate, C
public function removeTranslation($langcode) {
if (isset($this->translations[$langcode]) && $langcode != Language::LANGCODE_DEFAULT && $langcode != $this->defaultLangcode) {
foreach ($this->getPropertyDefinitions() as $name => $definition) {
if ($definition->isFieldTranslatable()) {
if ($definition->isTranslatable()) {
unset($this->values[$name][$langcode]);
unset($this->fields[$name][$langcode]);
}
@ -928,7 +929,7 @@ abstract class ContentEntityBase extends Entity implements \IteratorAggregate, C
// object keyed by language. To avoid creating different field objects
// we retain just the original value, as references will be recreated
// later as needed.
if (!$definitions[$name]->isFieldTranslatable() && count($values) > 1) {
if (!$definitions[$name]->isTranslatable() && count($values) > 1) {
$values = array_intersect_key($values, array(Language::LANGCODE_DEFAULT => TRUE));
}
foreach ($values as $langcode => $items) {

View File

@ -357,7 +357,7 @@ class EntityManager extends PluginManagerBase implements EntityManagerInterface
foreach (array('definitions', 'optional') as $key) {
foreach ($this->entityFieldInfo[$entity_type][$key] as $field_name => &$definition) {
if ($definition instanceof FieldDefinition) {
$definition->setFieldName($field_name);
$definition->setName($field_name);
}
}
}
@ -372,8 +372,8 @@ class EntityManager extends PluginManagerBase implements EntityManagerInterface
$untranslatable_fields = array_flip(array('langcode') + $keys);
foreach (array('definitions', 'optional') as $key) {
foreach ($this->entityFieldInfo[$entity_type][$key] as $field_name => &$definition) {
if (isset($untranslatable_fields[$field_name]) && $definition->isFieldTranslatable()) {
throw new \LogicException(format_string('The @field field cannot be translatable.', array('@field' => $definition->getFieldLabel())));
if (isset($untranslatable_fields[$field_name]) && $definition->isTranslatable()) {
throw new \LogicException(format_string('The @field field cannot be translatable.', array('@field' => $definition->getLabel())));
}
}
}

View File

@ -917,14 +917,15 @@ class FieldableDatabaseStorageController extends FieldableEntityStorageControlle
$delta_count = array();
foreach ($results as $row) {
// Ensure that records for non-translatable fields having invalid
// languages are skipped.
if ($row->langcode == $default_langcodes[$row->entity_id] || $field->isFieldTranslatable()) {
if ($row->langcode == $default_langcodes[$row->entity_id] || $field->isTranslatable()) {
if (!isset($delta_count[$row->entity_id][$row->langcode])) {
$delta_count[$row->entity_id][$row->langcode] = 0;
}
if ($field->getFieldCardinality() == FieldInterface::CARDINALITY_UNLIMITED || $delta_count[$row->entity_id][$row->langcode] < $field->getFieldCardinality()) {
if ($field->getCardinality() == FieldInterface::CARDINALITY_UNLIMITED || $delta_count[$row->entity_id][$row->langcode] < $field->getCardinality()) {
$item = array();
// For each column declared by the field, populate the item from the
// prefixed database column.
@ -987,7 +988,7 @@ class FieldableDatabaseStorageController extends FieldableEntityStorageControlle
$query = $this->database->insert($table_name)->fields($columns);
$revision_query = $this->database->insert($revision_name)->fields($columns);
$langcodes = $field->isFieldTranslatable() ? $translation_langcodes : array($default_langcode);
$langcodes = $field->isTranslatable() ? $translation_langcodes : array($default_langcode);
foreach ($langcodes as $langcode) {
$delta_count = 0;
$items = $entity->getTranslation($langcode)->get($field_name);
@ -1010,7 +1011,7 @@ class FieldableDatabaseStorageController extends FieldableEntityStorageControlle
$query->values($record);
$revision_query->values($record);
if ($field->getFieldCardinality() != FieldInterface::CARDINALITY_UNLIMITED && ++$delta_count == $field->getFieldCardinality()) {
if ($field->getCardinality() != FieldInterface::CARDINALITY_UNLIMITED && ++$delta_count == $field->getCardinality()) {
break;
}
}
@ -1279,12 +1280,12 @@ class FieldableDatabaseStorageController extends FieldableEntityStorageControlle
*/
public static function _fieldSqlSchema(FieldInterface $field, array $schema = NULL) {
if ($field->deleted) {
$description_current = "Data storage for deleted field {$field->uuid()} ({$field->entity_type}, {$field->getFieldName()}).";
$description_revision = "Revision archive storage for deleted field {$field->uuid()} ({$field->entity_type}, {$field->getFieldName()}).";
$description_current = "Data storage for deleted field {$field->uuid()} ({$field->entity_type}, {$field->getName()}).";
$description_revision = "Revision archive storage for deleted field {$field->uuid()} ({$field->entity_type}, {$field->getName()}).";
}
else {
$description_current = "Data storage for {$field->entity_type} field {$field->getFieldName()}.";
$description_revision = "Revision archive storage for {$field->entity_type} field {$field->getFieldName()}.";
$description_current = "Data storage for {$field->entity_type} field {$field->getName()}.";
$description_revision = "Revision archive storage for {$field->entity_type} field {$field->getName()}.";
}
$current = array(
@ -1498,7 +1499,7 @@ class FieldableDatabaseStorageController extends FieldableEntityStorageControlle
* unique among all other fields.
*/
static public function _fieldIndexName(FieldInterface $field, $index) {
return $field->getFieldName() . '_' . $index;
return $field->getName() . '_' . $index;
}
/**
@ -1521,7 +1522,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->getFieldName() . '_' . $column;
return in_array($column, Field::getReservedColumns()) ? $column : $field->getName() . '_' . $column;
}
}

View File

@ -263,7 +263,7 @@ abstract class FieldableEntityStorageControllerBase extends EntityStorageControl
*/
public function onFieldItemsPurge(EntityInterface $entity, FieldInstanceInterface $instance) {
if ($values = $this->readFieldItemsToPurge($entity, $instance)) {
$items = \Drupal::typedData()->create($instance, $values, $instance->getFieldName(), $entity);
$items = \Drupal::typedData()->create($instance, $values, $instance->getName(), $entity);
$items->delete();
}
$this->purgeFieldItems($entity, $instance);

View File

@ -136,7 +136,7 @@ class Tables implements TablesInterface {
// Get the field definitions form a mocked entity.
$values = array();
$field_name = $field->getFieldName();
$field_name = $field->getName();
// If there are bundles, pick one.
if (!empty($entity_info['entity_keys']['bundle'])) {
$values[$entity_info['entity_keys']['bundle']] = reset($field_map[$entity_type][$field_name]['bundles']);
@ -151,7 +151,7 @@ class Tables implements TablesInterface {
// column, i.e. target_id or fid.
// Otherwise, the code executing the relationship will throw an
// exception anyways so no need to do it here.
if (!$column && isset($propertyDefinitions[$relationship_specifier]) && $entity->{$field->getFieldName()}->get('entity') instanceof EntityReference) {
if (!$column && isset($propertyDefinitions[$relationship_specifier]) && $entity->{$field->getName()}->get('entity') instanceof EntityReference) {
$column = current(array_keys($propertyDefinitions));
}
// Prepare the next index prefix.
@ -249,10 +249,10 @@ class Tables implements TablesInterface {
* @throws \Drupal\Core\Entity\Query\QueryException
*/
protected function ensureFieldTable($index_prefix, &$field, $type, $langcode, $base_table, $entity_id_field, $field_id_field) {
$field_name = $field->getFieldName();
$field_name = $field->getName();
if (!isset($this->fieldTables[$index_prefix . $field_name])) {
$table = $this->sqlQuery->getMetaData('age') == EntityStorageControllerInterface::FIELD_LOAD_CURRENT ? FieldableDatabaseStorageController::_fieldTableName($field) : FieldableDatabaseStorageController::_fieldRevisionTableName($field);
if ($field->getFieldCardinality() != 1) {
if ($field->getCardinality() != 1) {
$this->sqlQuery->addMetaData('simple_query', FALSE);
}
$entity_type = $this->sqlQuery->getMetaData('entity_type');

View File

@ -64,13 +64,13 @@ class ConfigFieldItemList extends FieldItemList implements ConfigFieldItemListIn
// Check that the number of values doesn't exceed the field cardinality. For
// form submitted values, this can only happen with 'multiple value'
// widgets.
$cardinality = $this->getFieldDefinition()->getFieldCardinality();
$cardinality = $this->getFieldDefinition()->getCardinality();
if ($cardinality != FieldDefinitionInterface::CARDINALITY_UNLIMITED) {
$constraints[] = \Drupal::typedData()
->getValidationConstraintManager()
->create('Count', array(
'max' => $cardinality,
'maxMessage' => t('%name: this field cannot hold more than @count values.', array('%name' => $this->getFieldDefinition()->getFieldLabel(), '@count' => $cardinality)),
'maxMessage' => t('%name: this field cannot hold more than @count values.', array('%name' => $this->getFieldDefinition()->getLabel(), '@count' => $cardinality)),
));
}
@ -102,7 +102,7 @@ class ConfigFieldItemList extends FieldItemList implements ConfigFieldItemListIn
if (count($violations)) {
// Store reported errors in $form_state.
$field_name = $this->getFieldDefinition()->getFieldName();
$field_name = $this->getFieldDefinition()->getName();
$field_state = field_form_get_state($element['#parents'], $field_name, $form_state);
$field_state['constraint_violations'] = $violations;
field_form_set_state($element['#parents'], $field_name, $form_state, $field_state);
@ -142,7 +142,7 @@ class ConfigFieldItemList extends FieldItemList implements ConfigFieldItemListIn
// Use the widget currently configured for the 'default' form mode, or
// fallback to the default widget for the field type.
$entity_form_display = entity_get_form_display($entity->entityType(), $entity->bundle(), 'default');
$widget = $entity_form_display->getRenderer($this->getFieldDefinition()->getFieldName());
$widget = $entity_form_display->getRenderer($this->getFieldDefinition()->getName());
if (!$widget) {
$widget = \Drupal::service('plugin.manager.field.widget')->getInstance(array('field_definition' => $this->getFieldDefinition()));
}

View File

@ -32,7 +32,7 @@ class FieldDefinition extends ListDefinition implements FieldDefinitionInterface
/**
* {@inheritdoc}
*/
public function getFieldName() {
public function getName() {
return $this->definition['field_name'];
}
@ -45,7 +45,7 @@ class FieldDefinition extends ListDefinition implements FieldDefinitionInterface
* @return static
* The object itself for chaining.
*/
public function setFieldName($name) {
public function setName($name) {
$this->definition['field_name'] = $name;
return $this;
}
@ -53,7 +53,7 @@ class FieldDefinition extends ListDefinition implements FieldDefinitionInterface
/**
* {@inheritdoc}
*/
public function getFieldType() {
public function getType() {
$data_type = $this->getItemDefinition()->getDataType();
// Cut of the leading field_item: prefix from 'field_item:FIELD_TYPE'.
$parts = explode(':', $data_type);
@ -63,7 +63,7 @@ class FieldDefinition extends ListDefinition implements FieldDefinitionInterface
/**
* {@inheritdoc}
*/
public function getFieldSettings() {
public function getSettings() {
return $this->getItemDefinition()->getSettings();
}
@ -76,7 +76,7 @@ class FieldDefinition extends ListDefinition implements FieldDefinitionInterface
* @return static
* The object itself for chaining.
*/
public function setFieldSettings(array $settings) {
public function setSettings(array $settings) {
$this->getItemDefinition()->setSettings($settings);
return $this;
}
@ -84,7 +84,7 @@ class FieldDefinition extends ListDefinition implements FieldDefinitionInterface
/**
* {@inheritdoc}
*/
public function getFieldSetting($setting_name) {
public function getSetting($setting_name) {
return $this->getItemDefinition()->getSetting($setting_name);
}
@ -99,7 +99,7 @@ class FieldDefinition extends ListDefinition implements FieldDefinitionInterface
* @return static
* The object itself for chaining.
*/
public function setFieldSetting($setting_name, $value) {
public function setSetting($setting_name, $value) {
$this->getItemDefinition()->setSetting($setting_name, $value);
return $this;
}
@ -107,14 +107,14 @@ class FieldDefinition extends ListDefinition implements FieldDefinitionInterface
/**
* {@inheritdoc}
*/
public function getFieldPropertyNames() {
public function getPropertyNames() {
return array_keys(\Drupal::typedData()->create($this->getItemDefinition())->getPropertyDefinitions());
}
/**
* {@inheritdoc}
*/
public function isFieldTranslatable() {
public function isTranslatable() {
return !empty($this->definition['translatable']);
}
@ -135,35 +135,7 @@ class FieldDefinition extends ListDefinition implements FieldDefinitionInterface
/**
* {@inheritdoc}
*/
public function getFieldLabel() {
return $this->getLabel();
}
/**
* {@inheritdoc}
*/
public function setFieldLabel($label) {
return $this->setLabel($label);
}
/**
* {@inheritdoc}
*/
public function getFieldDescription() {
return $this->getDescription();
}
/**
* {@inheritdoc}
*/
public function setFieldDescription($description) {
return $this->setDescription($description);
}
/**
* {@inheritdoc}
*/
public function getFieldCardinality() {
public function getCardinality() {
// @todo: Allow to control this.
return isset($this->definition['cardinality']) ? $this->definition['cardinality'] : 1;
}
@ -171,35 +143,15 @@ class FieldDefinition extends ListDefinition implements FieldDefinitionInterface
/**
* {@inheritdoc}
*/
public function isFieldRequired() {
return $this->isRequired();
}
/**
* {@inheritdoc}
*/
public function isFieldMultiple() {
$cardinality = $this->getFieldCardinality();
public function isMultiple() {
$cardinality = $this->getCardinality();
return ($cardinality == static::CARDINALITY_UNLIMITED) || ($cardinality > 1);
}
/**
* Sets whether the field is required.
*
* @param bool $required
* Whether the field is required.
*
* @return static
* The object itself for chaining.
*/
public function setFieldRequired($required) {
return $this->setRequired($required);
}
/**
* {@inheritdoc}
*/
public function isFieldQueryable() {
public function isQueryable() {
return isset($this->definition['queryable']) ? $this->definition['queryable'] : !$this->isComputed();
}
@ -212,7 +164,7 @@ class FieldDefinition extends ListDefinition implements FieldDefinitionInterface
* @return static
* The object itself for chaining.
*/
public function setFieldQueryable($queryable) {
public function setQueryable($queryable) {
$this->definition['queryable'] = $queryable;
return $this;
}
@ -238,15 +190,15 @@ class FieldDefinition extends ListDefinition implements FieldDefinitionInterface
/**
* {@inheritdoc}
*/
public function isFieldConfigurable() {
public function isConfigurable() {
return FALSE;
}
/**
* {@inheritdoc}
*/
public function getFieldDefaultValue(EntityInterface $entity) {
return $this->getFieldSetting('default_value');
public function getDefaultValue(EntityInterface $entity) {
return $this->getSetting('default_value');
}
}

View File

@ -67,7 +67,7 @@ interface FieldDefinitionInterface extends ListDefinitionInterface {
* @return string
* The field name.
*/
public function getFieldName();
public function getName();
/**
* Returns the field type.
@ -77,7 +77,7 @@ interface FieldDefinitionInterface extends ListDefinitionInterface {
*
* @see \Drupal\Core\Field\FieldTypePluginManager
*/
public function getFieldType();
public function getType();
/**
* Returns the field settings.
@ -89,7 +89,7 @@ interface FieldDefinitionInterface extends ListDefinitionInterface {
* @return array
* An array of key/value pairs.
*/
public function getFieldSettings();
public function getSettings();
/**
* Returns the value of a given field setting.
@ -100,7 +100,7 @@ interface FieldDefinitionInterface extends ListDefinitionInterface {
* @return mixed
* The setting value.
*/
public function getFieldSetting($setting_name);
public function getSetting($setting_name);
/**
* Returns the names of the field's subproperties.
@ -116,7 +116,7 @@ interface FieldDefinitionInterface extends ListDefinitionInterface {
* @return array
* The property names.
*/
public function getFieldPropertyNames();
public function getPropertyNames();
/**
* Returns whether the field is translatable.
@ -124,7 +124,7 @@ interface FieldDefinitionInterface extends ListDefinitionInterface {
* @return bool
* TRUE if the field is translatable.
*/
public function isFieldTranslatable();
public function isTranslatable();
/**
* Determines whether the field is configurable via field.module.
@ -132,7 +132,7 @@ interface FieldDefinitionInterface extends ListDefinitionInterface {
* @return bool
* TRUE if the field is configurable.
*/
public function isFieldConfigurable();
public function isConfigurable();
/**
* Determines whether the field is queryable via QueryInterface.
@ -140,7 +140,7 @@ interface FieldDefinitionInterface extends ListDefinitionInterface {
* @return bool
* TRUE if the field is queryable.
*/
public function isFieldQueryable();
public function isQueryable();
/**
* Returns the human-readable label for the field.
@ -148,7 +148,7 @@ interface FieldDefinitionInterface extends ListDefinitionInterface {
* @return string
* The field label.
*/
public function getFieldLabel();
public function getLabel();
/**
* Returns the human-readable description for the field.
@ -160,7 +160,7 @@ interface FieldDefinitionInterface extends ListDefinitionInterface {
* @return string|null
* The field description, or NULL if no description is available.
*/
public function getFieldDescription();
public function getDescription();
/**
* Returns the maximum number of items allowed for the field.
@ -171,7 +171,7 @@ interface FieldDefinitionInterface extends ListDefinitionInterface {
* @return integer
* The field cardinality.
*/
public function getFieldCardinality();
public function getCardinality();
/**
* Returns whether at least one non-empty item is required for this field.
@ -182,7 +182,7 @@ interface FieldDefinitionInterface extends ListDefinitionInterface {
* @return bool
* TRUE if the field is required.
*/
public function isFieldRequired();
public function isRequired();
/**
* Returns whether the field can contain multiple items.
@ -190,7 +190,7 @@ interface FieldDefinitionInterface extends ListDefinitionInterface {
* @return bool
* TRUE if the field can contain multiple items, FALSE otherwise.
*/
public function isFieldMultiple();
public function isMultiple();
/**
* Returns the default value for the field in a newly created entity.
@ -207,6 +207,6 @@ interface FieldDefinitionInterface extends ListDefinitionInterface {
* array.
* - NULL or array() for no default value.
*/
public function getFieldDefaultValue(EntityInterface $entity);
public function getDefaultValue(EntityInterface $entity);
}

View File

@ -65,7 +65,7 @@ abstract class FieldItemBase extends Map implements FieldItemInterface {
* The array of settings.
*/
protected function getFieldSettings() {
return $this->getFieldDefinition()->getFieldSettings();
return $this->getFieldDefinition()->getSettings();
}
/**
@ -78,7 +78,7 @@ abstract class FieldItemBase extends Map implements FieldItemInterface {
* The setting value.
*/
protected function getFieldSetting($setting_name) {
return $this->getFieldDefinition()->getFieldSetting($setting_name);
return $this->getFieldDefinition()->getSetting($setting_name);
}
/**

View File

@ -230,7 +230,7 @@ class FieldItemList extends ItemList implements FieldItemListInterface {
* The default value for the field.
*/
protected function getDefaultValue() {
return $this->getFieldDefinition()->getFieldDefaultValue($this->getEntity());
return $this->getFieldDefinition()->getDefaultValue($this->getEntity());
}
/**

View File

@ -75,17 +75,17 @@ abstract class FormatterBase extends PluginSettingsBase implements FormatterInte
if ($elements) {
$entity = $items->getEntity();
$entity_type = $entity->entityType();
$field_name = $this->fieldDefinition->getFieldName();
$field_name = $this->fieldDefinition->getName();
$info = array(
'#theme' => 'field',
'#title' => $this->fieldDefinition->getFieldLabel(),
'#title' => $this->fieldDefinition->getLabel(),
'#access' => $items->access('view'),
'#label_display' => $this->label,
'#view_mode' => $this->viewMode,
'#language' => $items->getLangcode(),
'#field_name' => $field_name,
'#field_type' => $this->fieldDefinition->getFieldType(),
'#field_translatable' => $this->fieldDefinition->isFieldTranslatable(),
'#field_type' => $this->fieldDefinition->getType(),
'#field_translatable' => $this->fieldDefinition->isTranslatable(),
'#entity_type' => $entity_type,
'#bundle' => $entity->bundle(),
'#object' => $entity,
@ -138,7 +138,7 @@ abstract class FormatterBase extends PluginSettingsBase implements FormatterInte
* The array of settings.
*/
protected function getFieldSettings() {
return $this->fieldDefinition->getFieldSettings();
return $this->fieldDefinition->getSettings();
}
/**
@ -151,7 +151,7 @@ abstract class FormatterBase extends PluginSettingsBase implements FormatterInte
* The setting value.
*/
protected function getFieldSetting($setting_name) {
return $this->fieldDefinition->getFieldSetting($setting_name);
return $this->fieldDefinition->getSetting($setting_name);
}
}

View File

@ -101,7 +101,7 @@ class FormatterPluginManager extends DefaultPluginManager {
public function getInstance(array $options) {
$configuration = $options['configuration'];
$field_definition = $options['field_definition'];
$field_type = $field_definition->getFieldType();
$field_type = $field_definition->getType();
// Fill in default configuration if needed.
if (!isset($options['prepare']) || $options['prepare'] == TRUE) {

View File

@ -51,7 +51,7 @@ abstract class LegacyConfigFieldItem extends ConfigFieldItemBase implements Prep
$item = $this->getValue(TRUE);
// The previous hook was never called on an empty item, but
// ContentEntityBase always creates a FieldItem element for an empty field.
return empty($item) || $callback($item, $this->getFieldDefinition()->getFieldType());
return empty($item) || $callback($item, $this->getFieldDefinition()->getType());
}
/**

View File

@ -40,14 +40,14 @@ class LegacyConfigFieldItemList extends ConfigFieldItemList {
$this->legacyCallback('validate', array(&$legacy_errors));
$langcode = $this->getLangcode();
$field_name = $this->getFieldDefinition()->getFieldName();
$field_name = $this->getFieldDefinition()->getName();
if (isset($legacy_errors[$field_name][$langcode])) {
foreach ($legacy_errors[$field_name][$langcode] as $delta => $item_errors) {
foreach ($item_errors as $item_error) {
// We do not have the information about which column triggered the
// error, so assume the first column...
$property_names = $this->getFieldDefinition()->getFieldPropertyNames();
$property_names = $this->getFieldDefinition()->getPropertyNames();
$property_name = $property_names[0];
$violations->add(new ConstraintViolation($item_error['message'], $item_error['message'], array(), $this, $delta . '.' . $property_name, $this->offsetGet($delta)->get($property_name)->getValue(), NULL, $item_error['error']));
}
@ -102,7 +102,7 @@ class LegacyConfigFieldItemList extends ConfigFieldItemList {
* The name of the hook, e.g. 'presave', 'validate'.
*/
protected function legacyCallback($hook, $args = array()) {
$type_definition = \Drupal::service('plugin.manager.field.field_type')->getDefinition($this->getFieldDefinition()->getFieldType());
$type_definition = \Drupal::service('plugin.manager.field.field_type')->getDefinition($this->getFieldDefinition()->getType());
$module = $type_definition['provider'];
$callback = "{$module}_field_{$hook}";
if (function_exists($callback)) {

View File

@ -51,7 +51,7 @@ abstract class WidgetBase extends PluginSettingsBase implements WidgetInterface
* {@inheritdoc}
*/
public function form(FieldItemListInterface $items, array &$form, array &$form_state, $get_delta = NULL) {
$field_name = $this->fieldDefinition->getFieldName();
$field_name = $this->fieldDefinition->getName();
$parents = $form['#parents'];
// Store field information in $form_state.
@ -74,8 +74,8 @@ abstract class WidgetBase extends PluginSettingsBase implements WidgetInterface
if (isset($get_delta) || $definition['multiple_values']) {
$delta = isset($get_delta) ? $get_delta : 0;
$element = array(
'#title' => check_plain($this->fieldDefinition->getFieldLabel()),
'#description' => field_filter_xss(\Drupal::token()->replace($this->fieldDefinition->getFieldDescription())),
'#title' => check_plain($this->fieldDefinition->getLabel()),
'#description' => field_filter_xss(\Drupal::token()->replace($this->fieldDefinition->getDescription())),
);
$element = $this->formSingleElement($items, $delta, $element, $form, $form_state);
@ -118,7 +118,7 @@ abstract class WidgetBase extends PluginSettingsBase implements WidgetInterface
'#parents' => array_merge($parents, array($field_name . '_wrapper')),
'#attributes' => array(
'class' => array(
'field-type-' . drupal_html_class($this->fieldDefinition->getFieldType()),
'field-type-' . drupal_html_class($this->fieldDefinition->getType()),
'field-name-' . drupal_html_class($field_name),
'field-widget-' . drupal_html_class($this->getPluginId()),
),
@ -140,8 +140,8 @@ abstract class WidgetBase extends PluginSettingsBase implements WidgetInterface
* - table display and drag-n-drop value reordering
*/
protected function formMultipleElements(FieldItemListInterface $items, array &$form, array &$form_state) {
$field_name = $this->fieldDefinition->getFieldName();
$cardinality = $this->fieldDefinition->getFieldCardinality();
$field_name = $this->fieldDefinition->getName();
$cardinality = $this->fieldDefinition->getCardinality();
$parents = $form['#parents'];
// Determine the number of widgets to display.
@ -161,8 +161,8 @@ abstract class WidgetBase extends PluginSettingsBase implements WidgetInterface
$id_prefix = implode('-', array_merge($parents, array($field_name)));
$wrapper_id = drupal_html_id($id_prefix . '-add-more-wrapper');
$title = check_plain($this->fieldDefinition->getFieldLabel());
$description = field_filter_xss(\Drupal::token()->replace($this->fieldDefinition->getFieldDescription()));
$title = check_plain($this->fieldDefinition->getLabel());
$description = field_filter_xss(\Drupal::token()->replace($this->fieldDefinition->getDescription()));
$elements = array();
@ -200,8 +200,8 @@ abstract class WidgetBase extends PluginSettingsBase implements WidgetInterface
'#theme' => 'field_multiple_value_form',
'#field_name' => $field_name,
'#cardinality' => $cardinality,
'#cardinality_multiple' => $this->fieldDefinition->isFieldMultiple(),
'#required' => $this->fieldDefinition->isFieldRequired(),
'#cardinality_multiple' => $this->fieldDefinition->isMultiple(),
'#required' => $this->fieldDefinition->isRequired(),
'#title' => $title,
'#description' => $description,
'#prefix' => '<div id="' . $wrapper_id . '">',
@ -240,11 +240,11 @@ abstract class WidgetBase extends PluginSettingsBase implements WidgetInterface
'#entity_type' => $entity->entityType(),
'#bundle' => $entity->bundle(),
'#entity' => $entity,
'#field_name' => $this->fieldDefinition->getFieldName(),
'#field_name' => $this->fieldDefinition->getName(),
'#language' => $items->getLangcode(),
'#field_parents' => $form['#parents'],
// Only the first widget should be required.
'#required' => $delta == 0 && $this->fieldDefinition->isFieldRequired(),
'#required' => $delta == 0 && $this->fieldDefinition->isRequired(),
'#delta' => $delta,
'#weight' => $delta,
);
@ -270,7 +270,7 @@ abstract class WidgetBase extends PluginSettingsBase implements WidgetInterface
* {@inheritdoc}
*/
public function extractFormValues(FieldItemListInterface $items, array $form, array &$form_state) {
$field_name = $this->fieldDefinition->getFieldName();
$field_name = $this->fieldDefinition->getName();
// Extract the values from $form_state['values'].
$path = array_merge($form['#parents'], array($field_name));
@ -323,7 +323,7 @@ abstract class WidgetBase extends PluginSettingsBase implements WidgetInterface
* {@inheritdoc}
*/
public function flagErrors(FieldItemListInterface $items, array $form, array &$form_state) {
$field_name = $this->fieldDefinition->getFieldName();
$field_name = $this->fieldDefinition->getName();
$field_state = field_form_get_state($form['#parents'], $field_name, $form_state);
@ -426,7 +426,7 @@ abstract class WidgetBase extends PluginSettingsBase implements WidgetInterface
* The field values.
*/
protected function sortItems(FieldItemListInterface $items) {
if ($this->fieldDefinition->isFieldMultiple() && isset($items[0]->_weight)) {
if ($this->fieldDefinition->isMultiple() && isset($items[0]->_weight)) {
$itemValues = $items->getValue(TRUE);
usort($itemValues, function ($a, $b) {
$a_weight = (is_array($a) ? $a['_weight'] : 0);
@ -448,7 +448,7 @@ abstract class WidgetBase extends PluginSettingsBase implements WidgetInterface
* The array of settings.
*/
protected function getFieldSettings() {
return $this->fieldDefinition->getFieldSettings();
return $this->fieldDefinition->getSettings();
}
/**
@ -461,7 +461,7 @@ abstract class WidgetBase extends PluginSettingsBase implements WidgetInterface
* The setting value.
*/
protected function getFieldSetting($setting_name) {
return $this->fieldDefinition->getFieldSetting($setting_name);
return $this->fieldDefinition->getSetting($setting_name);
}
}

View File

@ -87,7 +87,7 @@ class WidgetPluginManager extends DefaultPluginManager {
$configuration = $options['configuration'];
$field_definition = $options['field_definition'];
$field_type = $field_definition->getFieldType();
$field_type = $field_definition->getType();
// Fill in default configuration if needed.
if ($options['prepare']) {

View File

@ -71,7 +71,7 @@ class Item extends ContentEntityBase implements ItemInterface {
$fields['fid'] = FieldDefinition::create('entity_reference')
->setLabel(t('Aggregator feed ID'))
->setDescription(t('The ID of the aggregator feed.'))
->setFieldSetting('target_type', 'aggregator_feed');
->setSetting('target_type', 'aggregator_feed');
$fields['title'] = FieldDefinition::create('string')
->setLabel(t('Title'))

View File

@ -72,7 +72,7 @@ class CustomBlockFieldTest extends CustomBlockTestBase {
));
$this->field->save();
$this->instance = entity_create('field_instance', array(
'field_name' => $this->field->getFieldName(),
'field_name' => $this->field->getName(),
'entity_type' => 'custom_block',
'bundle' => 'link',
'settings' => array(
@ -81,12 +81,12 @@ class CustomBlockFieldTest extends CustomBlockTestBase {
));
$this->instance->save();
entity_get_form_display('custom_block', 'link', 'default')
->setComponent($this->field->getFieldName(), array(
->setComponent($this->field->getName(), array(
'type' => 'link_default',
))
->save();
entity_get_display('custom_block', 'link', 'default')
->setComponent($this->field->getFieldName(), array(
->setComponent($this->field->getName(), array(
'type' => 'link',
'label' => 'hidden',
))
@ -96,8 +96,8 @@ class CustomBlockFieldTest extends CustomBlockTestBase {
$this->drupalGet('block/add/link');
$edit = array(
'info' => $this->randomName(8),
$this->field->getFieldName() . '[0][url]' => 'http://example.com',
$this->field->getFieldName() . '[0][title]' => 'Example.com'
$this->field->getName() . '[0][url]' => 'http://example.com',
$this->field->getName() . '[0][title]' => 'Example.com'
);
$this->drupalPostForm(NULL, $edit, t('Save'));
$block = entity_load('custom_block', 1);

View File

@ -79,7 +79,7 @@ class CustomBlockTypeTest extends CustomBlockTestBase {
$this->createCustomBlockType('other');
$instance = field_info_instance('custom_block', 'body', 'basic');
$this->assertEqual($instance->getFieldLabel(), 'Block body', 'Body field was found.');
$this->assertEqual($instance->getLabel(), 'Block body', 'Body field was found.');
// Verify that title and body fields are displayed.
$this->drupalGet('block/add/basic');

View File

@ -241,8 +241,8 @@ function comment_count_unpublished() {
* Implements hook_ENTITY_TYPE_create() for 'field_instance'.
*/
function comment_field_instance_create(FieldInstanceInterface $instance) {
if ($instance->getFieldType() == 'comment' && !$instance->isSyncing()) {
\Drupal::service('comment.manager')->addBodyField($instance->entity_type, $instance->getFieldName());
if ($instance->getType() == 'comment' && !$instance->isSyncing()) {
\Drupal::service('comment.manager')->addBodyField($instance->entity_type, $instance->getName());
\Drupal::cache()->delete('comment_entity_info');
// Assign default values for the field instance.
$instance->default_value = array(array(
@ -260,7 +260,7 @@ function comment_field_instance_create(FieldInstanceInterface $instance) {
* Implements hook_ENTITY_TYPE_update() for 'field_instance'.
*/
function comment_field_instance_update(FieldInstanceInterface $instance) {
if ($instance->getFieldType() == 'comment') {
if ($instance->getType() == 'comment') {
\Drupal::entityManager()->getViewBuilder($instance->entity_type)->resetCache();
}
}
@ -269,9 +269,9 @@ function comment_field_instance_update(FieldInstanceInterface $instance) {
* Implements hook_ENTITY_TYPE_delete() for 'field_entity'.
*/
function comment_field_entity_delete(FieldInterface $field) {
if ($field->getFieldType() == 'comment') {
if ($field->getType() == 'comment') {
// Delete all fields and displays attached to the comment bundle.
entity_invoke_bundle_hook('delete', 'comment', $field->getFieldName());
entity_invoke_bundle_hook('delete', 'comment', $field->getName());
\Drupal::cache()->delete('comment_entity_info');
}
}
@ -280,11 +280,11 @@ function comment_field_entity_delete(FieldInterface $field) {
* Implements hook_ENTITY_TYPE_delete() for 'field_instance'.
*/
function comment_field_instance_delete(FieldInstanceInterface $instance) {
if ($instance->getFieldType() == 'comment') {
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(
':entity_type' => $instance->entityType(),
':field_id' => $instance->entityType() . '__' . $instance->getFieldName(),
':field_id' => $instance->entityType() . '__' . $instance->getName(),
))->fetchCol();
entity_delete_multiple('comment', $comments);
\Drupal::cache()->delete('comment_entity_info');
@ -368,8 +368,8 @@ function comment_get_recent($number = 10) {
*/
function comment_new_page_count($num_comments, $new_replies, EntityInterface $entity, $field_name = 'comment') {
$instance = \Drupal::service('field.info')->getInstance($entity->entityType(), $entity->bundle(), $field_name);
$mode = $instance->getFieldSetting('default_mode');
$comments_per_page = $instance->getFieldSetting('per_page');
$mode = $instance->getSetting('default_mode');
$comments_per_page = $instance->getSetting('per_page');
$pagenum = NULL;
$flat = $mode == COMMENT_MODE_FLAT ? TRUE : FALSE;
if ($num_comments <= $comments_per_page) {
@ -518,7 +518,7 @@ function comment_entity_view(EntityInterface $entity, EntityDisplay $display, $v
}
// Provide a link to new comment form.
if ($commenting_status == COMMENT_OPEN) {
$comment_form_location = $instance->getFieldSetting('form_location');
$comment_form_location = $instance->getSetting('form_location');
if (user_access('post comments')) {
$links['comment-add'] = array(
'title' => t('Add new comment'),
@ -549,7 +549,7 @@ function comment_entity_view(EntityInterface $entity, EntityDisplay $display, $v
// But we don't want this link if we're building the entity for search
// indexing or constructing a search result excerpt.
if ($commenting_status == COMMENT_OPEN) {
$comment_form_location = $instance->getFieldSetting('form_location');
$comment_form_location = $instance->getSetting('form_location');
if (user_access('post comments')) {
// Show the "post comment" link if the form is on another page, or
// if there are existing comments that the link will skip past.
@ -817,7 +817,7 @@ function comment_view_multiple($comments, $view_mode = 'full', $langcode = NULL)
* Implements hook_form_FORM_ID_alter().
*/
function comment_form_field_ui_field_instance_edit_form_alter(&$form, $form_state) {
if ($form['#field']->getFieldType() == 'comment') {
if ($form['#field']->getType() == 'comment') {
// Collect translation settings.
if (\Drupal::moduleHandler()->moduleExists('content_translation')) {
array_unshift($form['#submit'], 'comment_translation_configuration_element_submit');
@ -862,7 +862,7 @@ function comment_form_field_ui_display_overview_form_alter(&$form, $form_state)
* Implements hook_form_FORM_ID_alter().
*/
function comment_form_field_ui_field_edit_form_alter(&$form, $form_state) {
if ($form['#field']->getFieldType() == 'comment') {
if ($form['#field']->getType() == 'comment') {
// We only support posting one comment at the time so it doesn't make sense
// to let the site builder choose anything else.
$form['field']['cardinality_container']['cardinality']['#options'] = drupal_map_assoc(array(1));
@ -1029,8 +1029,8 @@ function comment_node_update_index(EntityInterface $node, $langcode) {
continue;
}
$instance = \Drupal::service('field.info')->getInstance('node', $node->getType(), $field_name);
$mode = $instance->getFieldSetting('default_mode');
$comments_per_page = $instance->getFieldSetting('per_page');
$mode = $instance->getSetting('default_mode');
$comments_per_page = $instance->getSetting('per_page');
if ($node->get($field_name)->status && $cids = comment_get_thread($node, $field_name, $mode, $comments_per_page)) {
$comments = entity_load_multiple('comment', $cids);
comment_prepare_thread($comments);
@ -1234,7 +1234,7 @@ function comment_get_display_ordinal($cid, $instance) {
$query->condition('c1.status', COMMENT_PUBLISHED);
}
if ($instance->getFieldSetting('default_mode') == COMMENT_MODE_FLAT) {
if ($instance->getSetting('default_mode') == COMMENT_MODE_FLAT) {
// For flat comments, cid is used for ordering comments due to
// unpredictable behavior with timestamp, so we make the same assumption
// here.
@ -1266,7 +1266,7 @@ function comment_get_display_ordinal($cid, $instance) {
*/
function comment_get_display_page($cid, $instance) {
$ordinal = comment_get_display_ordinal($cid, $instance);
$comments_per_page = $instance->getFieldSetting('per_page');
$comments_per_page = $instance->getSetting('per_page');
return floor($ordinal / $comments_per_page);
}
@ -1532,7 +1532,7 @@ function theme_comment_post_forbidden($variables) {
$instance = \Drupal::service('field.info')->getInstance($entity->entityType(), $entity->bundle(), $field_name);
// We cannot use drupal_get_destination() because these links
// sometimes appear on /node and taxonomy listing pages.
if ($instance->getFieldSetting('form_location') == COMMENT_FORM_SEPARATE_PAGE) {
if ($instance->getSetting('form_location') == COMMENT_FORM_SEPARATE_PAGE) {
$destination = array('destination' => 'comment/reply/' . $entity->entityType() . '/' . $entity->id() . '/' . $field_name . '#comment-form');
}
else {

View File

@ -86,7 +86,7 @@ class CommentFormController extends ContentEntityFormController {
$form['#id'] = drupal_html_id('comment_form');
$form['#theme'] = array('comment_form__' . $entity->entityType() . '__' . $entity->bundle() . '__' . $field_name, 'comment_form');
$anonymous_contact = $instance->getFieldSetting('anonymous');
$anonymous_contact = $instance->getSetting('anonymous');
$is_admin = $comment->id() && $this->currentUser->hasPermission('administer comments');
if (!$this->currentUser->isAuthenticated() && $anonymous_contact != COMMENT_ANONYMOUS_MAYNOT_CONTACT) {
@ -206,7 +206,7 @@ class CommentFormController extends ContentEntityFormController {
'#title' => $this->t('Subject'),
'#maxlength' => 64,
'#default_value' => $comment->subject->value,
'#access' => $instance->getFieldSetting('subject'),
'#access' => $instance->getSetting('subject'),
);
// Used for conditional validation of author fields.
@ -233,7 +233,7 @@ class CommentFormController extends ContentEntityFormController {
$comment = $this->entity;
$entity = $this->entityManager->getStorageController($comment->entity_type->value)->load($comment->entity_id->value);
$instance = $this->fieldInfo->getInstance($comment->entity_type->value, $entity->bundle(), $comment->field_name->value);
$preview_mode = $instance->getFieldSetting('preview');
$preview_mode = $instance->getSetting('preview');
// No delete action on the comment form.
unset($element['delete']);

View File

@ -278,7 +278,7 @@ class CommentViewBuilder extends EntityViewBuilder implements EntityViewBuilderI
$commented_entity = $this->entityManager->getStorageController($comment->entity_type->value)->load($comment->entity_id->value);
$instance = $this->fieldInfo->getInstance($commented_entity->entityType(), $commented_entity->bundle(), $comment->field_name->value);
$is_threaded = isset($comment->divs)
&& $instance->getFieldSetting('default_mode') == COMMENT_MODE_THREADED;
&& $instance->getSetting('default_mode') == COMMENT_MODE_THREADED;
// Add indentation div or close open divs as needed.
if ($is_threaded) {

View File

@ -366,12 +366,12 @@ class Comment extends ContentEntityBase implements CommentInterface {
$fields['pid'] = FieldDefinition::create('entity_reference')
->setLabel(t('Parent ID'))
->setDescription(t('The parent comment ID if this is a reply to a comment.'))
->setFieldSetting('target_type', 'comment');
->setSetting('target_type', 'comment');
$fields['entity_id'] = FieldDefinition::create('entity_reference')
->setLabel(t('Entity ID'))
->setDescription(t('The ID of the entity of which this comment is a reply.'))
->setFieldSetting('target_type', 'node')
->setSetting('target_type', 'node')
->setRequired(TRUE);
$fields['langcode'] = FieldDefinition::create('language')
@ -385,7 +385,7 @@ class Comment extends ContentEntityBase implements CommentInterface {
$fields['uid'] = FieldDefinition::create('entity_reference')
->setLabel(t('User ID'))
->setDescription(t('The user ID of the comment author.'))
->setFieldSettings(array(
->setSettings(array(
'target_type' => 'user',
'default_value' => 0,
));
@ -393,7 +393,7 @@ class Comment extends ContentEntityBase implements CommentInterface {
$fields['name'] = FieldDefinition::create('string')
->setLabel(t('Name'))
->setDescription(t("The comment author's name."))
->setFieldSetting('default_value', '');
->setSetting('default_value', '');
$fields['mail'] = FieldDefinition::create('email')
->setLabel(t('Email'))

View File

@ -107,7 +107,7 @@ class CommentDefaultFormatter extends FormatterBase implements ContainerFactoryP
$elements = array();
$output = array();
$field_name = $this->fieldDefinition->getFieldName();
$field_name = $this->fieldDefinition->getName();
$entity = $items->getEntity();
$status = $items->status;

View File

@ -95,7 +95,7 @@ class CommentItem extends ConfigFieldItemBase {
$settings = $this->getFieldSettings();
$entity_type = $this->getEntity()->entityType();
$field_name = $this->getFieldDefinition()->getFieldName();
$field_name = $this->getFieldDefinition()->getName();
$element['comment'] = array(
'#type' => 'details',
@ -164,7 +164,7 @@ class CommentItem extends ConfigFieldItemBase {
public function __get($name) {
if ($name == 'status' && !isset($this->values[$name])) {
// Get default value from field instance when no data saved in entity.
$field_default_values = $this->getFieldDefinition()->getFieldDefaultValue($this->getEntity());
$field_default_values = $this->getFieldDefinition()->getDefaultValue($this->getEntity());
return $field_default_values[0]['status'];
}
else {

View File

@ -31,7 +31,7 @@ class CommentWidget extends WidgetBase {
$entity = $items->getParent();
// Get default value from the field instance.
$field_default_values = $this->fieldDefinition->getFieldDefaultValue($entity);
$field_default_values = $this->fieldDefinition->getDefaultValue($entity);
$status = $items->status;
$element['status'] = array(
@ -57,7 +57,7 @@ class CommentWidget extends WidgetBase {
// If the entity doesn't have any comments, the "hidden" option makes no
// sense, so don't even bother presenting it to the user unless this is the
// default value widget on the field settings form.
if ($element['#field_parents'] != array('default_value_input') && !$entity->get($field->getFieldName())->comment_count) {
if ($element['#field_parents'] != array('default_value_input') && !$entity->get($field->getName())->comment_count) {
$element['status'][COMMENT_HIDDEN]['#access'] = FALSE;
// Also adjust the description of the "closed" option.
$element['status'][COMMENT_CLOSED]['#description'] = t('Users cannot post comments.');

View File

@ -88,8 +88,8 @@ class CommentNonNodeTest extends WebTestBase {
$edit['comment_body[0][value]'] = $comment;
$instance = $this->container->get('field.info')->getInstance('entity_test', 'entity_test', 'comment');
$preview_mode = $instance->getFieldSetting('preview');
$subject_mode = $instance->getFieldSetting('subject');
$preview_mode = $instance->getSetting('preview');
$subject_mode = $instance->getSetting('subject');
// Must get the page before we test for fields.
if ($entity !== NULL) {

View File

@ -146,7 +146,7 @@ class Message extends ContentEntityBase implements MessageInterface {
$fields['category'] = FieldDefinition::create('entity_reference')
->setLabel(t('Category ID'))
->setDescription(t('The ID of the associated category.'))
->setFieldSettings(array('target_type' => 'contact_category'))
->setSettings(array('target_type' => 'contact_category'))
->setRequired(TRUE);
$fields['name'] = FieldDefinition::create('string')
@ -172,7 +172,7 @@ class Message extends ContentEntityBase implements MessageInterface {
$fields['recipient'] = FieldDefinition::create('entity_reference')
->setLabel(t('Recipient ID'))
->setDescription(t('The ID of the recipient user for personal contact messages.'))
->setFieldSettings(array('target_type' => 'user'));
->setSettings(array('target_type' => 'user'));
return $fields;
}

View File

@ -22,7 +22,7 @@ use Drupal\field\Field as FieldService;
function content_translation_field_sync_widget(FieldDefinitionInterface $field) {
$element = array();
$column_groups = $field->getFieldSetting('column_groups');
$column_groups = $field->getSetting('column_groups');
if (!empty($column_groups) && count($column_groups) > 1) {
$options = array();
$default = array();
@ -34,7 +34,7 @@ function content_translation_field_sync_widget(FieldDefinitionInterface $field)
$settings = array('dependent_selectors' => array('instance[settings][translation_sync]' => array('file')));
$translation_sync = $field->getFieldSetting('translation_sync');
$translation_sync = $field->getSetting('translation_sync');
$element = array(
'#type' => 'checkboxes',
'#title' => t('Translatable elements'),
@ -101,10 +101,10 @@ function _content_translation_form_language_content_settings_form_alter(array &$
// translation.
// @todo Remove this special casing as soon as configurable and
// base field definitions are "unified".
if ($definition->isFieldConfigurable() && ($field = FieldService::fieldInfo()->getField($entity_type, $field_name))) {
if ($definition->isConfigurable() && ($field = FieldService::fieldInfo()->getField($entity_type, $field_name))) {
$instance = FieldService::fieldInfo()->getInstance($entity_type, $bundle, $field_name);
$form['settings'][$entity_type][$bundle]['fields'][$field_name] = array(
'#label' => $instance->getFieldLabel(),
'#label' => $instance->getLabel(),
'#type' => 'checkbox',
'#default_value' => $translatable,
);
@ -122,7 +122,7 @@ function _content_translation_form_language_content_settings_form_alter(array &$
// fields support translation. Whether they are actually enabled is
// determined through our settings. As a consequence only fields
// that support translation can be enabled or disabled.
elseif (isset($field_settings[$field_name]) || $definition->isFieldTranslatable()) {
elseif (isset($field_settings[$field_name]) || $definition->isTranslatable()) {
$form['settings'][$entity_type][$bundle]['fields'][$field_name] = array(
'#label' => $definition->getLabel(),
'#type' => 'checkbox',
@ -347,7 +347,7 @@ function _content_translation_update_field_translatability($settings) {
// If translatability changes for at least one field instance we need
// to switch field translatability.
$field = FieldService::fieldInfo()->getField($entity_type, $field_name);
if ($field && $field->isFieldTranslatable() !== $translatable) {
if ($field && $field->isTranslatable() !== $translatable) {
$fields[$field_name] = $translatable;
}
}

View File

@ -630,7 +630,7 @@ function content_translation_form_alter(array &$form, array &$form_state) {
if (!$entity->isNew() && (!isset($translations[$form_langcode]) || count($translations) > 1)) {
foreach ($entity->getPropertyDefinitions() as $property_name => $definition) {
if (isset($form[$property_name])) {
$form[$property_name]['#multilingual'] = $definition->isFieldTranslatable();
$form[$property_name]['#multilingual'] = $definition->isTranslatable();
}
}
}
@ -795,7 +795,7 @@ function content_translation_form_field_ui_field_edit_form_alter(array &$form, a
$form['field']['translatable'] = array(
'#type' => 'checkbox',
'#title' => t('Users may translate this field.'),
'#default_value' => $form['#field']->isFieldTranslatable(),
'#default_value' => $form['#field']->isTranslatable(),
'#weight' => 20,
);
$form['#submit'][] = 'content_translation_form_field_ui_field_edit_form_submit';
@ -810,7 +810,7 @@ function content_translation_form_field_ui_field_edit_form_submit($form, array &
if (!isset($value)) {
$value = array();
}
$value[$instance->getField()->getFieldName()] = $form_state['values']['field']['translatable'];
$value[$instance->getField()->getName()] = $form_state['values']['field']['translatable'];
// Store the same value for all bundles as translatability is tracked per
// field.
foreach (entity_get_bundles($instance->entity_type) as $bundle => $info) {
@ -822,7 +822,7 @@ function content_translation_form_field_ui_field_edit_form_submit($form, array &
* Implements hook_form_FORM_ID_alter() for 'field_ui_field_instance_edit_form'.
*/
function content_translation_form_field_ui_field_instance_edit_form_alter(array &$form, array &$form_state, $form_id) {
if ($form['#field']->isFieldTranslatable()) {
if ($form['#field']->isTranslatable()) {
module_load_include('inc', 'content_translation', 'content_translation.admin');
$element = content_translation_field_sync_widget($form['#field']);
if ($element) {
@ -1008,7 +1008,7 @@ function content_translation_save_settings($settings) {
if (!empty($bundle_settings['columns'])) {
foreach ($bundle_settings['columns'] as $field_name => $column_settings) {
$instance = field_info_instance($entity_type, $field_name, $bundle);
if ($instance->isFieldTranslatable()) {
if ($instance->isTranslatable()) {
$instance->settings['translation_sync'] = $column_settings;
}
// If the field does not have translatable enabled we need to reset

View File

@ -43,7 +43,7 @@ function content_translation_overview(EntityInterface $entity) {
// Determine whether the current entity is translatable.
$translatable = FALSE;
foreach (field_info_instances($entity->entityType(), $entity->bundle()) as $instance) {
if ($instance->isFieldTranslatable()) {
if ($instance->isTranslatable()) {
$translatable = TRUE;
break;
}

View File

@ -60,7 +60,7 @@ class FieldTranslationSynchronizer implements FieldTranslationSynchronizerInterf
// Sync when the field is not empty, when the synchronization translations
// setting is set, and the field is translatable.
$translation_sync = $instance->getFieldSetting('translation_sync');
$translation_sync = $instance->getSetting('translation_sync');
if (!$entity->get($field_name)->isEmpty() && !empty($translation_sync) && field_is_translatable($entity_type, $field)) {
// Retrieve all the untranslatable column groups and merge them into
// single list.
@ -68,7 +68,7 @@ class FieldTranslationSynchronizer implements FieldTranslationSynchronizerInterf
if (!empty($groups)) {
$columns = array();
foreach ($groups as $group) {
$column_groups = $field->getFieldSetting('column_groups');
$column_groups = $field->getSetting('column_groups');
$info = $column_groups[$group];
// A missing 'columns' key indicates we have a single-column group.
$columns = array_merge($columns, isset($info['columns']) ? $info['columns'] : array($group));

View File

@ -92,7 +92,7 @@ class ContentTranslationSettingsTest extends WebTestBase {
$this->assertSettings('comment', 'node__comment_article', TRUE, $edit);
field_info_cache_clear();
$field = field_info_field('comment', 'comment_body');
$this->assertTrue($field->isFieldTranslatable(), 'Comment body is translatable.');
$this->assertTrue($field->isTranslatable(), 'Comment body is translatable.');
// Test that language settings are correctly stored.
$language_configuration = language_get_default_configuration('comment', 'node__comment_article');
@ -132,8 +132,8 @@ class ContentTranslationSettingsTest extends WebTestBase {
$this->assertSettings('node', 'article', TRUE, $edit);
$field = FieldService::fieldInfo()->getField('node', 'body');
$definitions = \Drupal::entityManager()->getFieldDefinitions('node', 'article');
$this->assertEqual($definitions['body']->isFieldTranslatable(), $translatable, 'Field translatability correctly switched.');
$this->assertEqual($field->isFieldTranslatable(), $definitions['body']->isFieldTranslatable(), 'Configurable field translatability correctly switched.');
$this->assertEqual($definitions['body']->isTranslatable(), $translatable, 'Field translatability correctly switched.');
$this->assertEqual($field->isTranslatable(), $definitions['body']->isTranslatable(), 'Configurable field translatability correctly switched.');
// Test that also the Field UI form behaves correctly.
$translatable = !$translatable;
@ -143,8 +143,8 @@ class ContentTranslationSettingsTest extends WebTestBase {
entity_info_cache_clear();
$field = FieldService::fieldInfo()->getField('node', 'body');
$definitions = \Drupal::entityManager()->getFieldDefinitions('node', 'article');
$this->assertEqual($definitions['body']->isFieldTranslatable(), $translatable, 'Field translatability correctly switched.');
$this->assertEqual($field->isFieldTranslatable(), $definitions['body']->isFieldTranslatable(), 'Configurable field translatability correctly switched.');
$this->assertEqual($definitions['body']->isTranslatable(), $translatable, 'Field translatability correctly switched.');
$this->assertEqual($field->isTranslatable(), $definitions['body']->isTranslatable(), 'Configurable field translatability correctly switched.');
}
}

View File

@ -191,11 +191,11 @@ function datetime_default_value($entity, $field, $instance, $langcode) {
$value = '';
$date = '';
if ($instance->getFieldSetting('default_value') == 'now') {
if ($instance->getSetting('default_value') == 'now') {
// A default value should be in the format and timezone used for date
// storage.
$date = new DrupalDateTime('now', DATETIME_STORAGE_TIMEZONE);
$storage_format = $field->getFieldSetting('datetime_type') == 'date' ? DATETIME_DATE_STORAGE_FORMAT: DATETIME_DATETIME_STORAGE_FORMAT;
$storage_format = $field->getSetting('datetime_type') == 'date' ? DATETIME_DATE_STORAGE_FORMAT: DATETIME_DATETIME_STORAGE_FORMAT;
$value = $date->format($storage_format);
}

View File

@ -48,7 +48,7 @@ class DateTimeComputed extends TypedData {
$item = $this->getParent();
$value = $item->{($this->definition->getSetting('date source'))};
$storage_format = $item->getFieldDefinition()->getFieldSetting('datetime_type') == 'date' ? DATETIME_DATE_STORAGE_FORMAT : DATETIME_DATETIME_STORAGE_FORMAT;
$storage_format = $item->getFieldDefinition()->getSetting('datetime_type') == 'date' ? DATETIME_DATE_STORAGE_FORMAT : DATETIME_DATETIME_STORAGE_FORMAT;
try {
$date = DrupalDateTime::createFromFormat($storage_format, $value, DATETIME_STORAGE_TIMEZONE);
if ($date instanceOf DrupalDateTime && !$date->hasErrors()) {

View File

@ -43,7 +43,7 @@ class DateTimeItemTest extends FieldUnitTestBase {
));
$this->field->save();
$this->instance = entity_create('field_instance', array(
'field_name' => $this->field->getFieldName(),
'field_name' => $this->field->getName(),
'entity_type' => 'entity_test',
'bundle' => 'entity_test',
'settings' => array(

View File

@ -177,7 +177,7 @@ class EditFieldForm implements FormInterface, ContainerInjectionInterface {
// @todo Refine automated log messages and abstract them to all entity
// types: http://drupal.org/node/1678002.
if ($entity->entityType() == 'node' && $entity->isNewRevision() && !isset($entity->log)) {
$entity->log = t('Updated the %field-name field through in-place editing.', array('%field-name' => $entity->get($field_name)->getFieldDefinition()->getFieldLabel()));
$entity->log = t('Updated the %field-name field through in-place editing.', array('%field-name' => $entity->get($field_name)->getFieldDefinition()->getLabel()));
}
return $entity;

View File

@ -68,7 +68,7 @@ class MetadataGenerator implements MetadataGeneratorInterface {
* {@inheritdoc}
*/
public function generateField(EntityInterface $entity, FieldDefinitionInterface $field_definition, $langcode, $view_mode) {
$field_name = $field_definition->getFieldName();
$field_name = $field_definition->getName();
// Early-return if user does not have access.
$access = $this->accessChecker->accessEditEntityField($entity, $field_name);
@ -85,7 +85,7 @@ class MetadataGenerator implements MetadataGeneratorInterface {
}
// Gather metadata, allow the editor to add additional metadata of its own.
$label = $field_definition->getFieldLabel();
$label = $field_definition->getLabel();
$editor = $this->editorManager->createInstance($editor_id);
$metadata = array(
'label' => check_plain($label),

View File

@ -28,11 +28,11 @@ class PlainTextEditor extends EditorBase {
*/
function isCompatible(FieldDefinitionInterface $field_definition, array $items) {
// This editor is incompatible with multivalued fields.
if ($field_definition->getFieldCardinality() != 1) {
if ($field_definition->getCardinality() != 1) {
return FALSE;
}
// This editor is incompatible with processed ("rich") text fields.
elseif ($field_definition->getFieldSetting('text_processing')) {
elseif ($field_definition->getSetting('text_processing')) {
return FALSE;
}
else {

View File

@ -26,13 +26,13 @@ class WysiwygEditor extends EditorBase {
*/
function isCompatible(FieldDefinitionInterface $field_definition, array $items) {
// This editor is incompatible with multivalued fields.
if ($field_definition->getFieldCardinality() != 1) {
if ($field_definition->getCardinality() != 1) {
return FALSE;
}
// This editor is compatible with processed ("rich") text fields; but only
// if there is a currently active text format and that text format is the
// 'full_html' text format.
elseif ($field_definition->getFieldSetting('text_processing')) {
elseif ($field_definition->getSetting('text_processing')) {
$format_id = $items[0]['format'];
if (isset($format_id) && $format_id === 'full_html') {
return TRUE;

View File

@ -557,7 +557,7 @@ function _editor_get_processed_text_fields(ContentEntityInterface $entity) {
// Find all configurable fields, because only they could have a
// text_processing setting.
$configurable_fields = array_keys(array_filter($properties, function ($definition) {
return $definition->isFieldConfigurable();
return $definition->isConfigurable();
}));
if (empty($configurable_fields)) {
return array();
@ -567,7 +567,7 @@ function _editor_get_processed_text_fields(ContentEntityInterface $entity) {
return array_filter($configurable_fields, function ($field) use ($entity) {
$settings = Field::fieldInfo()
->getInstance($entity->entityType(), $entity->bundle(), $field)
->getFieldSettings();
->getSettings();
return isset($settings['text_processing']) && $settings['text_processing'] === '1';
});
}

View File

@ -28,13 +28,13 @@ class Editor extends PluginBase implements EditPluginInterface {
*/
function isCompatible(FieldDefinitionInterface $field_definition, array $items) {
// This editor is incompatible with multivalued fields.
if ($field_definition->getFieldCardinality() != 1) {
if ($field_definition->getCardinality() != 1) {
return FALSE;
}
// This editor is compatible with processed ("rich") text fields; but only
// if there is a currently active text format, that text format has an
// associated editor and that editor supports inline editing.
elseif ($field_definition->getFieldSetting('text_processing')) {
elseif ($field_definition->getSetting('text_processing')) {
$format_id = $items[0]['format'];
if (isset($format_id) && $editor = editor_load($format_id)) {
$definition = \Drupal::service('plugin.manager.editor')->getDefinition($editor->editor);

View File

@ -56,7 +56,7 @@ class ConfigurableEmailItem extends EmailItem implements ConfigFieldItemInterfac
'value' => array(
'Length' => array(
'max' => static::EMAIL_MAX_LENGTH,
'maxMessage' => t('%name: the e-mail address can not be longer than @max characters.', array('%name' => $this->getFieldDefinition()->getFieldLabel(), '@max' => static::EMAIL_MAX_LENGTH)),
'maxMessage' => t('%name: the e-mail address can not be longer than @max characters.', array('%name' => $this->getFieldDefinition()->getLabel(), '@max' => static::EMAIL_MAX_LENGTH)),
)
),
));

View File

@ -254,7 +254,6 @@ abstract class EntityDisplayBase extends ConfigEntityBase implements EntityDispl
$max = $this->getHighestWeight();
$options['weight'] = isset($max) ? $max + 1 : 0;
}
// See remark in getComponent().
// @todo Cleanup after https://drupal.org/node/2144919 is fixed.
$extra_fields = field_info_extra_fields($this->targetEntityType, $this->bundle, $this->displayContext);
@ -262,7 +261,7 @@ abstract class EntityDisplayBase extends ConfigEntityBase implements EntityDispl
$options['visible'] = TRUE;
}
elseif ($field_definition = $this->getFieldDefinition($name)) {
$options = $this->pluginManager->prepareConfiguration($field_definition->getFieldType(), $options);
$options = $this->pluginManager->prepareConfiguration($field_definition->getType(), $options);
}
// Clear the persisted plugin, if any.

View File

@ -51,7 +51,7 @@ function entity_reference_field_entity_update(FieldInterface $field) {
return;
}
if ($field->getFieldSetting('target_type') == $field->original->getFieldSetting('target_type')) {
if ($field->getSetting('target_type') == $field->original->getSetting('target_type')) {
// Target type didn't change.
return;
}
@ -61,7 +61,7 @@ function entity_reference_field_entity_update(FieldInterface $field) {
return;
}
$field_name = $field->getFieldName();
$field_name = $field->getName();
foreach ($field->bundles() as $entity_type => $bundles) {
foreach ($bundles as $bundle) {
@ -153,7 +153,7 @@ function entity_reference_options_list(FieldDefinitionInterface $field_definitio
}
// Rebuild the array by changing the bundle key into the bundle label.
$target_type = $field_definition->getFieldSetting('target_type');
$target_type = $field_definition->getSetting('target_type');
$bundles = entity_get_bundles($target_type);
$return = array();

View File

@ -26,7 +26,7 @@ class ConfigurableEntityReferenceItem extends ConfigEntityReferenceItemBase impl
* {@inheritdoc}
*/
public static function schema(FieldInterface $field) {
$target_type = $field->getFieldSetting('target_type');
$target_type = $field->getSetting('target_type');
$target_type_info = \Drupal::entityManager()->getDefinition($target_type);
if (is_subclass_of($target_type_info['class'], '\Drupal\Core\Entity\ContentEntityInterface')) {
@ -137,7 +137,7 @@ class ConfigurableEntityReferenceItem extends ConfigEntityReferenceItemBase impl
'#type' => 'select',
'#title' => t('Reference method'),
'#options' => $handlers_options,
'#default_value' => $instance->getFieldSetting('handler'),
'#default_value' => $instance->getSetting('handler'),
'#required' => TRUE,
'#ajax' => TRUE,
'#limit_validation_errors' => array(),

View File

@ -85,7 +85,7 @@ class EntityReferenceAutocomplete {
if (isset($string)) {
// Get an array of matching entities.
$widget = entity_get_form_display($instance->entity_type, $instance->bundle, 'default')->getComponent($instance->getFieldName());
$widget = entity_get_form_display($instance->entity_type, $instance->bundle, 'default')->getComponent($instance->getName());
$match_operator = !empty($widget['settings']['match_operator']) ? $widget['settings']['match_operator'] : 'CONTAINS';
$entity_labels = $handler->getReferenceableEntities($string, $match_operator, 10);

View File

@ -87,7 +87,7 @@ class EntityReferenceController implements ContainerInjectionInterface {
}
$access_controller = $this->entityManager->getAccessController($entity_type);
if ($instance->getFieldType() != 'entity_reference' || !$access_controller->fieldAccess('edit', $instance)) {
if ($instance->getType() != 'entity_reference' || !$access_controller->fieldAccess('edit', $instance)) {
throw new AccessDeniedHttpException();
}

View File

@ -33,7 +33,7 @@ class ConfigurableEntityReferenceFieldItemList extends ConfigFieldItemList {
}
}
if ($uuids) {
$target_type = $this->getFieldDefinition()->getFieldSetting('target_type');
$target_type = $this->getFieldDefinition()->getSetting('target_type');
$entity_ids = \Drupal::entityQuery($target_type)
->condition('uuid', $uuids, 'IN')
->execute();
@ -80,7 +80,7 @@ class ConfigurableEntityReferenceFieldItemList extends ConfigFieldItemList {
$ids[] = $properties['target_id'];
}
$entities = \Drupal::entityManager()
->getStorageController($this->getFieldDefinition()->getFieldSetting('target_type'))
->getStorageController($this->getFieldDefinition()->getSetting('target_type'))
->loadMultiple($ids);
foreach ($default_value as $delta => $properties) {

View File

@ -76,7 +76,7 @@ abstract class AutocompleteWidgetBase extends WidgetBase {
// Prepare the autocomplete route parameters.
$autocomplete_route_parameters = array(
'type' => $this->getSetting('autocomplete_type'),
'field_name' => $this->fieldDefinition->getFieldName(),
'field_name' => $this->fieldDefinition->getName(),
'entity_type' => $entity->entityType(),
'bundle_name' => $entity->bundle(),
);

View File

@ -54,8 +54,8 @@ class SelectionPluginManager extends DefaultPluginManager {
* Overrides \Drupal\Component\Plugin\PluginManagerBase::getInstance().
*/
public function getInstance(array $options) {
$selection_handler = $options['field_definition']->getFieldSetting('handler');
$target_entity_type = $options['field_definition']->getFieldSetting('target_type');
$selection_handler = $options['field_definition']->getSetting('handler');
$target_entity_type = $options['field_definition']->getSetting('target_type');
// Get all available selection plugins for this entity type.
$selection_handler_groups = $this->getSelectionGroups($target_entity_type);

View File

@ -55,8 +55,8 @@ class SelectionBase implements SelectionInterface {
* {@inheritdoc}
*/
public static function settingsForm(FieldDefinitionInterface $field_definition) {
$target_type = $field_definition->getFieldSetting('target_type');
$selection_handler_settings = $field_definition->getFieldSetting('handler_settings') ?: array();
$target_type = $field_definition->getSetting('target_type');
$selection_handler_settings = $field_definition->getSetting('handler_settings') ?: array();
$entity_info = \Drupal::entityManager()->getDefinition($target_type);
$bundles = entity_get_bundles($target_type);
@ -110,7 +110,7 @@ class SelectionBase implements SelectionInterface {
foreach (field_info_instances($target_type) as $bundle_instances) {
foreach ($bundle_instances as $instance_name => $instance) {
foreach ($instance->getField()->getColumns() as $column_name => $column_info) {
$fields[$instance_name . '.' . $column_name] = t('@label (@column)', array('@label' => $instance->getFieldLabel(), '@column' => $column_name));
$fields[$instance_name . '.' . $column_name] = t('@label (@column)', array('@label' => $instance->getLabel(), '@column' => $column_name));
}
}
@ -159,7 +159,7 @@ class SelectionBase implements SelectionInterface {
* {@inheritdoc}
*/
public function getReferenceableEntities($match = NULL, $match_operator = 'CONTAINS', $limit = 0) {
$target_type = $this->fieldDefinition->getFieldSetting('target_type');
$target_type = $this->fieldDefinition->getSetting('target_type');
$query = $this->buildEntityQuery($match, $match_operator);
if ($limit > 0) {
@ -198,7 +198,7 @@ class SelectionBase implements SelectionInterface {
public function validateReferenceableEntities(array $ids) {
$result = array();
if ($ids) {
$target_type = $this->fieldDefinition->getFieldSetting('target_type');
$target_type = $this->fieldDefinition->getSetting('target_type');
$entity_info = entity_get_info($target_type);
$query = $this->buildEntityQuery();
$result = $query
@ -258,8 +258,8 @@ class SelectionBase implements SelectionInterface {
* it.
*/
public function buildEntityQuery($match = NULL, $match_operator = 'CONTAINS') {
$target_type = $this->fieldDefinition->getFieldSetting('target_type');
$handler_settings = $this->fieldDefinition->getFieldSetting('handler_settings');
$target_type = $this->fieldDefinition->getSetting('target_type');
$handler_settings = $this->fieldDefinition->getSetting('handler_settings');
$entity_info = entity_get_info($target_type);
$query = \Drupal::entityQuery($target_type);
@ -272,7 +272,7 @@ class SelectionBase implements SelectionInterface {
}
// Add entity-access tag.
$query->addTag($this->fieldDefinition->getFieldSetting('target_type') . '_access');
$query->addTag($this->fieldDefinition->getSetting('target_type') . '_access');
// Add the Selection handler for
// entity_reference_query_entity_reference_alter().
@ -281,7 +281,7 @@ class SelectionBase implements SelectionInterface {
$query->addMetaData('entity_reference_selection_handler', $this);
// Add the sort option.
$handler_settings = $this->fieldDefinition->getFieldSetting('handler_settings');
$handler_settings = $this->fieldDefinition->getSetting('handler_settings');
if (!empty($handler_settings['sort'])) {
$sort_settings = $handler_settings['sort'];
if ($sort_settings['field'] != '_none') {

View File

@ -210,7 +210,7 @@ function hook_field_widget_info_alter(array &$info) {
function hook_field_widget_form_alter(&$element, &$form_state, $context) {
// Add a css class to widget form elements for all fields of type mytype.
$field_definition = $context['items']->getFieldDefinition();
if ($field_definition->getFieldType() == 'mytype') {
if ($field_definition->getType() == 'mytype') {
// Be sure not to overwrite existing attributes.
$element['#attributes']['class'][] = 'myclass';
}

View File

@ -96,7 +96,7 @@ function field_invoke_method($method, $target_function, EntityInterface $entity,
$target = call_user_func($target_function, $field_definition);
if (method_exists($target, $method)) {
$items = $entity->get($field_definition->getFieldName());
$items = $entity->get($field_definition->getName());
$items->filterEmptyValues();
$result = $target->$method($items, $a, $b);
@ -159,7 +159,7 @@ function field_invoke_method_multiple($method, $target_function, array $entities
$field_definitions = _field_invoke_get_field_definitions($entity_type, $bundle, $options);
foreach ($field_definitions as $field_definition) {
$field_name = $field_definition->getFieldName();
$field_name = $field_definition->getName();
$group_key = "$bundle:$field_name";
// Let the closure determine the target object on which the method should
@ -259,7 +259,7 @@ function _field_invoke_get_field_definitions($entity_type, $bundle, $options) {
*/
function _field_invoke_widget_target($form_display) {
return function (FieldDefinitionInterface $field_definition) use ($form_display) {
return $form_display->getRenderer($field_definition->getFieldName());
return $form_display->getRenderer($field_definition->getName());
};
}

View File

@ -599,7 +599,7 @@ function field_attach_form_validate(ContentEntityInterface $entity, $form, &$for
$has_violations = FALSE;
foreach ($entity as $field_name => $field) {
$definition = $field->getDefinition();
if ($definition->isFieldConfigurable() && (empty($options['field_name']) || $options['field_name'] == $field_name)) {
if ($definition->isConfigurable() && (empty($options['field_name']) || $options['field_name'] == $field_name)) {
$field_violations = $field->validate();
if (count($field_violations)) {
$has_violations = TRUE;
@ -699,7 +699,7 @@ function field_attach_prepare_view($entity_type, array $entities, array $display
// the entity display.
$target_function = function (FieldDefinitionInterface $field_definition, $bundle) use ($displays) {
if (isset($displays[$bundle])) {
return $displays[$bundle]->getRenderer($field_definition->getFieldName());
return $displays[$bundle]->getRenderer($field_definition->getName());
}
};
$null = NULL;
@ -738,7 +738,7 @@ function field_attach_view(EntityInterface $entity, EntityDisplay $display, $lan
// For each field, call the view() method on the formatter object handed
// by the entity display.
$target_function = function (FieldDefinitionInterface $field_definition) use ($display) {
return $display->getRenderer($field_definition->getFieldName());
return $display->getRenderer($field_definition->getName());
};
$null = NULL;
$output = field_invoke_method('view', $target_function, $entity, $null, $null, $options);
@ -799,10 +799,10 @@ function field_get_items(EntityInterface $entity, $field_name, $langcode = NULL)
* The default value for the field.
*
* @deprecated as of Drupal 8.0. Use
* $instance->getFieldDefaultValue($entity)
* $instance->getDefaultValue($entity)
*/
function field_get_default_value(EntityInterface $entity, $field, $instance, $langcode = NULL) {
return $instance->getFieldDefaultValue($entity);
return $instance->getDefaultValue($entity);
}
/**
@ -900,13 +900,13 @@ function field_language(EntityInterface $entity, $field_name = NULL, $langcode =
if (!isset($field_name)) {
$display_langcodes = array();
foreach ($definitions as $name => $definition) {
if ($definition->isFieldConfigurable()) {
if ($definition->isConfigurable()) {
$display_langcodes[$name] = $translatable ? $langcode : Language::LANGCODE_NOT_SPECIFIED;
}
}
return $display_langcodes;
}
elseif ($definitions[$field_name]->isFieldConfigurable()) {
elseif ($definitions[$field_name]->isConfigurable()) {
return $translatable ? $langcode : Language::LANGCODE_NOT_SPECIFIED;
}
}

View File

@ -225,7 +225,7 @@ function field_entity_bundle_rename($entity_type, $bundle_old, $bundle_new) {
$instances = field_read_instances();
foreach ($instances as $instance) {
if ($instance->entity_type == $entity_type && $instance->bundle == $bundle_old) {
$id_new = $instance->entity_type . '.' . $bundle_new . '.' . $instance->getFieldName();
$id_new = $instance->entity_type . '.' . $bundle_new . '.' . $instance->getName();
$instance->id = $id_new;
$instance->bundle = $bundle_new;
$instance->allowBundleRename();
@ -437,7 +437,7 @@ function field_view_field(ContentEntityInterface $entity, $field_name, $display_
// hook_field_attach_display_alter() needs to receive the 'prepared'
// $display_options, so we cannot let preparation happen internally.
$formatter_manager = Drupal::service('plugin.manager.field.formatter');
$display_options = $formatter_manager->prepareConfiguration($field_definition->getFieldType(), $display_options);
$display_options = $formatter_manager->prepareConfiguration($field_definition->getType(), $display_options);
$formatter = $formatter_manager->getInstance(array(
'field_definition' => $field_definition,
'view_mode' => $view_mode,

View File

@ -88,7 +88,7 @@ function field_available_languages($entity_type, FieldInterface $field) {
$drupal_static_fast['field_langcodes'] = &drupal_static(__FUNCTION__);
}
$field_langcodes = &$drupal_static_fast['field_langcodes'];
$field_name = $field->getFieldName();
$field_name = $field->getName();
if (!isset($field_langcodes[$entity_type][$field_name])) {
// If the field has language support enabled we retrieve an (alterable) list
@ -167,7 +167,7 @@ function field_content_languages() {
* TRUE if the field can be translated.
*/
function field_is_translatable($entity_type, FieldInterface $field) {
return $field->isFieldTranslatable() && field_has_translation_handler($entity_type);
return $field->isTranslatable() && field_has_translation_handler($entity_type);
}
/**

View File

@ -171,7 +171,7 @@ function field_purge_instance($instance) {
function field_purge_field($field) {
$instances = field_read_instances(array('field_id' => $field->uuid()), array('include_deleted' => 1));
if (count($instances) > 0) {
throw new FieldException(t('Attempt to purge a field @field_name that still has instances.', array('@field_name' => $field->getFieldName())));
throw new FieldException(t('Attempt to purge a field @field_name that still has instances.', array('@field_name' => $field->getName())));
}
$state = \Drupal::state();

View File

@ -90,7 +90,7 @@ function field_views_field_label($entity_type, $field_name) {
foreach ($instances as $bundle => $bundle_instances) {
if (isset($bundle_instances[$field_name])) {
$instance = $bundle_instances[$field_name];
$label = $instance->getFieldLabel();
$label = $instance->getLabel();
$label_counter[$label] = isset($label_counter[$label]) ? ++$label_counter[$label] : 1;
$all_labels[$label] = TRUE;
}
@ -117,7 +117,7 @@ function field_views_field_default_views_data(FieldInterface $field) {
$data = array();
// Check the field type is available.
if (!\Drupal::service('plugin.manager.field.field_type')->getDefinition($field->getFieldType())) {
if (!\Drupal::service('plugin.manager.field.field_type')->getDefinition($field->getType())) {
return $data;
}
// Check the field has instances.
@ -125,7 +125,7 @@ function field_views_field_default_views_data(FieldInterface $field) {
return $data;
}
$field_name = $field->getFieldName();
$field_name = $field->getName();
$field_columns = $field->getColumns();
// Grab information about the entity type tables.
@ -375,7 +375,7 @@ function field_views_field_default_views_data(FieldInterface $field) {
}
// Expose additional delta column for multiple value fields.
if ($field->isFieldMultiple()) {
if ($field->isMultiple()) {
$title_delta = t('@label (!name:delta)', array('@label' => $label, '!name' => $field_name));
$title_short_delta = t('@label:delta', array('@label' => $label));
@ -417,7 +417,7 @@ function field_views_field_default_views_data(FieldInterface $field) {
}
// Expose additional language column for translatable fields.
if ($field->isFieldTranslatable()) {
if ($field->isTranslatable()) {
$title_language = t('@label (!name:language)', array('@label' => $label, '!name' => $field_name));
$title_short_language = t('@label:language', array('@label' => $label));
@ -474,7 +474,7 @@ function list_field_views_data($field) {
$data[$table_name][$field_name]['filter']['id'] = 'field_list';
}
if (isset($field_data['argument']) && $field_name != 'delta') {
if ($field->getFieldType() == 'list_text') {
if ($field->getType() == 'list_text') {
$data[$table_name][$field_name]['argument']['id'] = 'field_list_string';
}
else {

View File

@ -500,21 +500,21 @@ class Field extends ConfigEntityBase implements FieldInterface {
/**
* {@inheritdoc}
*/
public function getFieldName() {
public function getName() {
return $this->name;
}
/**
* {@inheritdoc}
*/
public function getFieldType() {
public function getType() {
return $this->type;
}
/**
* {@inheritdoc}
*/
public function getFieldSettings() {
public function getSettings() {
// @todo field_info_field_types() calls _field_info_collate_types() which
// maintains its own static cache. However, do some CPU and memory
// profiling to see if it's worth statically caching $field_type_info, or
@ -528,12 +528,12 @@ class Field extends ConfigEntityBase implements FieldInterface {
/**
* {@inheritdoc}
*/
public function getFieldSetting($setting_name) {
// @todo See getFieldSettings() about potentially statically caching this.
public function getSetting($setting_name) {
// @todo See getSettings() about potentially statically caching this.
$field_type_info = \Drupal::service('plugin.manager.field.field_type')->getDefinition($this->type);
// We assume here that consecutive array_key_exists() is more efficient than
// calling getFieldSettings() when all we need is a single setting.
// calling getSettings() when all we need is a single setting.
if (array_key_exists($setting_name, $this->settings)) {
return $this->settings[$setting_name];
}
@ -551,7 +551,7 @@ class Field extends ConfigEntityBase implements FieldInterface {
/**
* {@inheritdoc}
*/
public function getFieldPropertyNames() {
public function getPropertyNames() {
$schema = $this->getSchema();
return array_keys($schema['columns']);
}
@ -559,7 +559,7 @@ class Field extends ConfigEntityBase implements FieldInterface {
/**
* {@inheritdoc}
*/
public function isFieldTranslatable() {
public function isTranslatable() {
return $this->translatable;
}
@ -580,55 +580,55 @@ class Field extends ConfigEntityBase implements FieldInterface {
/**
* {@inheritdoc}
*/
public function getFieldLabel() {
public function getLabel() {
return $this->label();
}
/**
* {@inheritdoc}
*/
public function getFieldDescription() {
public function getDescription() {
return NULL;
}
/**
* {@inheritdoc}
*/
public function getFieldCardinality() {
public function getCardinality() {
return $this->cardinality;
}
/**
* {@inheritdoc}
*/
public function isFieldRequired() {
public function isRequired() {
return FALSE;
}
/**
* {@inheritdoc}
*/
public function isFieldMultiple() {
$cardinality = $this->getFieldCardinality();
public function isMultiple() {
$cardinality = $this->getCardinality();
return ($cardinality == static::CARDINALITY_UNLIMITED) || ($cardinality > 1);
}
/**
* {@inheritdoc}
*/
public function getFieldDefaultValue(EntityInterface $entity) { }
public function getDefaultValue(EntityInterface $entity) { }
/**
* {@inheritdoc}
*/
public function isFieldConfigurable() {
public function isConfigurable() {
return TRUE;
}
/**
* {@inheritdoc}
*/
public function isFieldQueryable() {
public function isQueryable() {
return TRUE;
}
@ -704,20 +704,6 @@ class Field extends ConfigEntityBase implements FieldInterface {
return 'list';
}
/**
* {@inheritdoc}
*/
public function getLabel() {
return $this->label();
}
/**
* {@inheritdoc}
*/
public function getDescription() {
return $this->getFieldDescription();
}
/**
* {@inheritdoc}
*/
@ -739,47 +725,16 @@ class Field extends ConfigEntityBase implements FieldInterface {
return FALSE;
}
/**
* {@inheritdoc}
*/
public function isRequired() {
return $this->isFieldRequired();
}
/**
* {@inheritdoc}
*/
public function getClass() {
// Derive list class from the field type.
$type_definition = \Drupal::service('plugin.manager.field.field_type')
->getDefinition($this->getFieldType());
->getDefinition($this->getType());
return $type_definition['list_class'];
}
/**
* {@inheritdoc}
*/
public function getSettings() {
// This should actually return the settings for field item list, which are
// not the field settings. However, there is no harm in returning field
// settings here, so we do that to avoid confusion for now.
// @todo: Unify with getFieldSettings() or remove once typed data moved
// to the adapter approach.
return $this->getFieldSettings();
}
/**
* {@inheritdoc}
*/
public function getSetting($setting_name) {
// This should actually return the settings for field item list, which are
// not the field settings. However, there is no harm in returning field
// settings here, so we do that to avoid confusion for now.
// @todo: Unify with getFieldSettings() or remove once typed data moved
// to the adapter approach.
return $this->getFieldSetting($setting_name);
}
/**
* {@inheritdoc}
*/
@ -800,7 +755,7 @@ class Field extends ConfigEntityBase implements FieldInterface {
public function getItemDefinition() {
if (!isset($this->itemDefinition)) {
$this->itemDefinition = DataDefinition::create('field_item:' . $this->type)
->setSettings($this->getFieldSettings());
->setSettings($this->getSettings());
}
return $this->itemDefinition;
}

View File

@ -454,40 +454,40 @@ class FieldInstance extends ConfigEntityBase implements FieldInstanceInterface {
/**
* {@inheritdoc}
*/
public function getFieldName() {
public function getName() {
return $this->field->name;
}
/**
* {@inheritdoc}
*/
public function getFieldType() {
public function getType() {
return $this->field->type;
}
/**
* {@inheritdoc}
*/
public function getFieldSettings() {
return $this->settings + $this->field->getFieldSettings();
public function getSettings() {
return $this->settings + $this->field->getSettings();
}
/**
* {@inheritdoc}
*/
public function getFieldSetting($setting_name) {
public function getSetting($setting_name) {
if (array_key_exists($setting_name, $this->settings)) {
return $this->settings[$setting_name];
}
else {
return $this->field->getFieldSetting($setting_name);
return $this->field->getSetting($setting_name);
}
}
/**
* {@inheritdoc}
*/
public function getFieldPropertyNames() {
public function getPropertyNames() {
$schema = $this->field->getSchema();
return array_keys($schema['columns']);
}
@ -495,7 +495,7 @@ class FieldInstance extends ConfigEntityBase implements FieldInstanceInterface {
/**
* {@inheritdoc}
*/
public function isFieldTranslatable() {
public function isTranslatable() {
return $this->field->translatable;
}
@ -522,42 +522,42 @@ class FieldInstance extends ConfigEntityBase implements FieldInstanceInterface {
/**
* {@inheritdoc}
*/
public function getFieldLabel() {
public function getLabel() {
return $this->label();
}
/**
* {@inheritdoc}
*/
public function getFieldDescription() {
public function getDescription() {
return $this->description;
}
/**
* {@inheritdoc}
*/
public function getFieldCardinality() {
public function getCardinality() {
return $this->field->cardinality;
}
/**
* {@inheritdoc}
*/
public function isFieldRequired() {
public function isRequired() {
return $this->required;
}
/**
* {@inheritdoc}
*/
public function isFieldMultiple() {
return $this->field->isFieldMultiple();
public function isMultiple() {
return $this->field->isMultiple();
}
/**
* {@inheritdoc}
*/
public function getFieldDefaultValue(EntityInterface $entity) {
public function getDefaultValue(EntityInterface $entity) {
if (!empty($this->default_value_function)) {
$function = $this->default_value_function;
return $function($entity, $this->getField(), $this, $entity->language()->id);
@ -570,14 +570,14 @@ class FieldInstance extends ConfigEntityBase implements FieldInstanceInterface {
/**
* {@inheritdoc}
*/
public function isFieldConfigurable() {
public function isConfigurable() {
return TRUE;
}
/**
* {@inheritdoc}
*/
public function isFieldQueryable() {
public function isQueryable() {
return TRUE;
}
@ -613,20 +613,6 @@ class FieldInstance extends ConfigEntityBase implements FieldInstanceInterface {
return 'list';
}
/**
* {@inheritdoc}
*/
public function getLabel() {
return $this->label();
}
/**
* {@inheritdoc}
*/
public function getDescription() {
return $this->getFieldDescription();
}
/**
* {@inheritdoc}
*/
@ -648,14 +634,6 @@ class FieldInstance extends ConfigEntityBase implements FieldInstanceInterface {
return FALSE;
}
/**
* {@inheritdoc}
*/
public function isRequired() {
// Only field instances can be required.
return $this->isFieldRequired();
}
/**
* {@inheritdoc}
*/
@ -663,20 +641,6 @@ class FieldInstance extends ConfigEntityBase implements FieldInstanceInterface {
return $this->field->getClass();
}
/**
* {@inheritdoc}
*/
public function getSettings() {
return $this->getFieldSettings();
}
/**
* {@inheritdoc}
*/
public function getSetting($setting_name) {
return $this->getFieldSetting($setting_name);
}
/**
* {@inheritdoc}
*/
@ -697,7 +661,7 @@ class FieldInstance extends ConfigEntityBase implements FieldInstanceInterface {
public function getItemDefinition() {
if (!isset($this->itemDefinition)) {
$this->itemDefinition = DataDefinition::create('field_item:' . $this->field->type)
->setSettings($this->getFieldSettings());
->setSettings($this->getSettings());
}
return $this->itemDefinition;
}

View File

@ -242,7 +242,7 @@ class FieldInfo {
// Fill the name/ID map.
foreach ($this->fieldsById as $field) {
if (!$field->deleted) {
$this->fieldIdsByName[$field->entity_type][$field->getFieldName()] = $field->uuid();
$this->fieldIdsByName[$field->entity_type][$field->getName()] = $field->uuid();
}
}
@ -279,7 +279,7 @@ class FieldInfo {
foreach (field_read_instances() as $instance) {
$instance = $this->prepareInstance($instance);
$this->bundleInstances[$instance->entity_type][$instance->bundle][$instance->getFieldName()] = $instance;
$this->bundleInstances[$instance->entity_type][$instance->bundle][$instance->getName()] = $instance;
}
// Store in persistent cache.
@ -366,7 +366,7 @@ class FieldInfo {
// Store in the static cache.
$this->fieldsById[$field->uuid()] = $field;
if (!$field->deleted) {
$this->fieldIdsByName[$field->entity_type][$field->getFieldName()] = $field->uuid();
$this->fieldIdsByName[$field->entity_type][$field->getName()] = $field->uuid();
}
return $field;
@ -410,7 +410,7 @@ class FieldInfo {
if (!isset($this->fieldsById[$field->uuid()])) {
$this->fieldsById[$field->uuid()] = $field;
if (!$field->deleted) {
$this->fieldIdsByName[$field->entity_type][$field->getFieldName()] = $field->uuid();
$this->fieldIdsByName[$field->entity_type][$field->getName()] = $field->uuid();
}
}
}
@ -458,7 +458,7 @@ class FieldInfo {
$field = $this->prepareField($field);
$this->fieldsById[$field->uuid()] = $field;
$this->fieldIdsByName[$field->entity_type][$field->getFieldName()] = $field->uuid();
$this->fieldIdsByName[$field->entity_type][$field->getName()] = $field->uuid();
}
$fields[] = $this->fieldsById[$field->uuid()];
@ -468,7 +468,7 @@ class FieldInfo {
$loaded_instances = entity_load_multiple('field_instance', array_values($config_ids));
foreach ($loaded_instances as $instance) {
$instance = $this->prepareInstance($instance);
$instances[$instance->getFieldName()] = $instance;
$instances[$instance->getName()] = $instance;
}
}
}
@ -560,7 +560,7 @@ class FieldInfo {
*/
public function prepareField(FieldInterface $field) {
// Make sure all expected field settings are present.
$field->settings += $this->fieldTypeManager->getDefaultSettings($field->getFieldType());
$field->settings += $this->fieldTypeManager->getDefaultSettings($field->getType());
return $field;
}
@ -576,7 +576,7 @@ class FieldInfo {
*/
public function prepareInstance(FieldInstanceInterface $instance) {
// Make sure all expected instance settings are present.
$instance->settings += $this->fieldTypeManager->getDefaultInstanceSettings($instance->getFieldType());
$instance->settings += $this->fieldTypeManager->getDefaultInstanceSettings($instance->getType());
return $instance;
}

View File

@ -143,8 +143,8 @@ class Field extends FieldPluginBase {
$this->multiple = FALSE;
$this->limit_values = FALSE;
$cardinality = $this->field_info->getFieldCardinality();
if ($this->field_info->isFieldMultiple()) {
$cardinality = $this->field_info->getCardinality();
if ($this->field_info->isMultiple()) {
$this->multiple = TRUE;
// If "Display all values in the same row" is FALSE, then we always limit
@ -325,7 +325,7 @@ class Field extends FieldPluginBase {
// defineOptions runs before init/construct, so no $this->field_info
$field = field_info_field($this->definition['entity_type'], $this->definition['field_name']);
$field_type = \Drupal::service('plugin.manager.field.field_type')->getDefinition($field->getFieldType());
$field_type = \Drupal::service('plugin.manager.field.field_type')->getDefinition($field->getType());
$column_names = array_keys($field->getColumns());
$default_column = '';
// Try to determine a sensible default.
@ -361,7 +361,7 @@ class Field extends FieldPluginBase {
// If we know the exact number of allowed values, then that can be
// the default. Otherwise, default to 'all'.
$options['delta_limit'] = array(
'default' => ($field->getFieldCardinality() > 1) ? $field->getFieldCardinality() : 'all',
'default' => ($field->getCardinality() > 1) ? $field->getCardinality() : 'all',
);
$options['delta_offset'] = array(
'default' => 0,
@ -397,7 +397,7 @@ class Field extends FieldPluginBase {
parent::buildOptionsForm($form, $form_state);
$field = $this->field_info;
$formatters = $this->formatterPluginManager->getOptions($field->getFieldType());
$formatters = $this->formatterPluginManager->getOptions($field->getType());
$column_names = array_keys($field->getColumns());
// If this is a multiple value field, add its options.
@ -496,14 +496,14 @@ class Field extends FieldPluginBase {
// translating prefix and suffix separately.
list($prefix, $suffix) = explode('@count', t('Display @count value(s)'));
if ($field->getFieldCardinality() == FieldDefinitionInterface::CARDINALITY_UNLIMITED) {
if ($field->getCardinality() == FieldDefinitionInterface::CARDINALITY_UNLIMITED) {
$type = 'textfield';
$options = NULL;
$size = 5;
}
else {
$type = 'select';
$options = drupal_map_assoc(range(1, $field->getFieldCardinality()));
$options = drupal_map_assoc(range(1, $field->getCardinality()));
$size = 1;
}
$form['multi_type'] = array(

View File

@ -143,7 +143,7 @@ class BulkDeleteTest extends FieldUnitTestBase {
for ($i = 0; $i < 10; $i++) {
$entity = entity_create($this->entity_type, array('type' => $bundle));
foreach ($this->fields as $field) {
$entity->{$field->getFieldName()}->setValue($this->_generateTestFieldValues($field->getFieldCardinality()));
$entity->{$field->getName()}->setValue($this->_generateTestFieldValues($field->getCardinality()));
}
$entity->save();
}

View File

@ -44,8 +44,8 @@ class CrudTest extends FieldUnitTestBase {
$field = entity_create('field_entity', $field_definition);
$field->save();
$mem = field_test_memorize();
$this->assertIdentical($mem['field_test_field_entity_create'][0][0]->getFieldName(), $field_definition['name'], 'hook_entity_create() called with correct arguments.');
$this->assertIdentical($mem['field_test_field_entity_create'][0][0]->getFieldType(), $field_definition['type'], 'hook_entity_create() called with correct arguments.');
$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.');
// Read the configuration. Check against raw configuration data rather than
// the loaded ConfigEntity, to be sure we check that the defaults are
@ -349,13 +349,13 @@ class CrudTest extends FieldUnitTestBase {
// Save an entity with data for the field
$entity = entity_create('entity_test', array());
$values[0]['value'] = mt_rand(1, 127);
$entity->{$field->getFieldName()}->value = $values[0]['value'];
$entity->{$field->getName()}->value = $values[0]['value'];
$entity = $this->entitySaveReload($entity);
// Verify the field is present on load
$this->assertIdentical(count($entity->{$field->getFieldName()}), count($values), "Data in previously deleted field saves and loads correctly");
$this->assertIdentical(count($entity->{$field->getName()}), count($values), "Data in previously deleted field saves and loads correctly");
foreach ($values as $delta => $value) {
$this->assertEqual($entity->{$field->getFieldName()}[$delta]->value, $values[$delta]['value'], "Data in previously deleted field saves and loads correctly");
$this->assertEqual($entity->{$field->getName()}[$delta]->value, $values[$delta]['value'], "Data in previously deleted field saves and loads correctly");
}
}

View File

@ -51,9 +51,9 @@ class FieldAttachOtherTest extends FieldUnitTestBase {
$entity_init = entity_create($entity_type, array());
// Populate values to be displayed.
$values = $this->_generateTestFieldValues($this->field->getFieldCardinality());
$values = $this->_generateTestFieldValues($this->field->getCardinality());
$entity_init->{$this->field_name}->setValue($values);
$values_2 = $this->_generateTestFieldValues($this->field_2->getFieldCardinality());
$values_2 = $this->_generateTestFieldValues($this->field_2->getCardinality());
$entity_init->{$this->field_name_2}->setValue($values_2);
// Simple formatter, label displayed.
@ -69,7 +69,7 @@ class FieldAttachOtherTest extends FieldUnitTestBase {
'test_formatter_setting' => $formatter_setting,
),
);
$display->setComponent($this->field->getFieldName(), $display_options);
$display->setComponent($this->field->getName(), $display_options);
$formatter_setting_2 = $this->randomName();
$display_options_2 = array(
@ -79,19 +79,19 @@ class FieldAttachOtherTest extends FieldUnitTestBase {
'test_formatter_setting' => $formatter_setting_2,
),
);
$display->setComponent($this->field_2->getFieldName(), $display_options_2);
$display->setComponent($this->field_2->getName(), $display_options_2);
// View all fields.
field_attach_prepare_view($entity_type, array($entity->id() => $entity), $displays);
$content = field_attach_view($entity, $display);
$output = drupal_render($content);
$this->content = $output;
$this->assertRaw($this->instance->getFieldLabel(), "First field's label is displayed.");
$this->assertRaw($this->instance->getLabel(), "First field's label is displayed.");
foreach ($values as $delta => $value) {
$this->content = $output;
$this->assertRaw("$formatter_setting|{$value['value']}", "Value $delta is displayed, formatter settings are applied.");
}
$this->assertRaw($this->instance_2->getFieldLabel(), "Second field's label is displayed.");
$this->assertRaw($this->instance_2->getLabel(), "Second field's label is displayed.");
foreach ($values_2 as $delta => $value) {
$this->content = $output;
$this->assertRaw("$formatter_setting_2|{$value['value']}", "Value $delta is displayed, formatter settings are applied.");
@ -100,21 +100,21 @@ class FieldAttachOtherTest extends FieldUnitTestBase {
// Label hidden.
$entity = clone($entity_init);
$display_options['label'] = 'hidden';
$display->setComponent($this->field->getFieldName(), $display_options);
$display->setComponent($this->field->getName(), $display_options);
field_attach_prepare_view($entity_type, array($entity->id() => $entity), $displays);
$entity->content = field_attach_view($entity, $display);
$output = drupal_render($entity->content);
$this->content = $output;
$this->assertNoRaw($this->instance->getFieldLabel(), "Hidden label: label is not displayed.");
$this->assertNoRaw($this->instance->getLabel(), "Hidden label: label is not displayed.");
// Field hidden.
$entity = clone($entity_init);
$display->removeComponent($this->field->getFieldName());
$display->removeComponent($this->field->getName());
field_attach_prepare_view($entity_type, array($entity->id() => $entity), $displays);
$entity->content = field_attach_view($entity, $display);
$output = drupal_render($entity->content);
$this->content = $output;
$this->assertNoRaw($this->instance->getFieldLabel(), "Hidden field: label is not displayed.");
$this->assertNoRaw($this->instance->getLabel(), "Hidden field: label is not displayed.");
foreach ($values as $delta => $value) {
$this->assertNoRaw("$formatter_setting|{$value['value']}", "Hidden field: value $delta is not displayed.");
}
@ -122,7 +122,7 @@ class FieldAttachOtherTest extends FieldUnitTestBase {
// Multiple formatter.
$entity = clone($entity_init);
$formatter_setting = $this->randomName();
$display->setComponent($this->field->getFieldName(), array(
$display->setComponent($this->field->getName(), array(
'label' => 'above',
'type' => 'field_test_multiple',
'settings' => array(
@ -142,7 +142,7 @@ class FieldAttachOtherTest extends FieldUnitTestBase {
// Test a formatter that uses hook_field_formatter_prepare_view().
$entity = clone($entity_init);
$formatter_setting = $this->randomName();
$display->setComponent($this->field->getFieldName(), array(
$display->setComponent($this->field->getName(), array(
'label' => 'above',
'type' => 'field_test_with_prepare_view',
'settings' => array(
@ -182,7 +182,7 @@ class FieldAttachOtherTest extends FieldUnitTestBase {
// Set the instance to be hidden.
$display = entity_get_display('entity_test', 'entity_test', 'full')
->removeComponent($this->field->getFieldName());
->removeComponent($this->field->getName());
// Set up a second instance on another bundle, with a formatter that uses
// hook_field_formatter_prepare_view().
@ -194,7 +194,7 @@ class FieldAttachOtherTest extends FieldUnitTestBase {
$this->instance2->save();
$display_2 = entity_get_display('entity_test', 'test_bundle_2', 'full')
->setComponent($this->field->getFieldName(), array(
->setComponent($this->field->getName(), array(
'type' => 'field_test_with_prepare_view',
'settings' => array(
'test_formatter_setting_additional' => $formatter_setting,
@ -205,11 +205,11 @@ class FieldAttachOtherTest extends FieldUnitTestBase {
// Create one entity in each bundle.
$entity1_init = entity_create('entity_test', array('id' => 1, 'type' => 'entity_test'));
$values1 = $this->_generateTestFieldValues($this->field->getFieldCardinality());
$values1 = $this->_generateTestFieldValues($this->field->getCardinality());
$entity1_init->{$this->field_name}->setValue($values1);
$entity2_init = entity_create('entity_test', array('id' => 2, 'type' => 'test_bundle_2'));
$values2 = $this->_generateTestFieldValues($this->field->getFieldCardinality());
$values2 = $this->_generateTestFieldValues($this->field->getCardinality());
$entity2_init->{$this->field_name}->setValue($values2);
// Run prepare_view, and check that the entities come out as expected.
@ -236,7 +236,7 @@ class FieldAttachOtherTest extends FieldUnitTestBase {
// Initialize random values and a test entity.
$entity_init = entity_create('entity_test', array('type' => $this->instance->bundle));
$langcode = Language::LANGCODE_NOT_SPECIFIED;
$values = $this->_generateTestFieldValues($this->field->getFieldCardinality());
$values = $this->_generateTestFieldValues($this->field->getCardinality());
// Non-cacheable entity type.
$entity_type = 'entity_test';
@ -280,7 +280,7 @@ class FieldAttachOtherTest extends FieldUnitTestBase {
$this->assertEqual($cache->data[$langcode][$this->field_name_2], $values, 'Cached: correct cache entry on load');
// Update with different values, and check that the cache entry is wiped.
$values = $this->_generateTestFieldValues($this->field_2->getFieldCardinality());
$values = $this->_generateTestFieldValues($this->field_2->getCardinality());
$entity = entity_create($entity_type, array(
'type' => $entity_type,
'id' => $entity->id(),
@ -300,7 +300,7 @@ class FieldAttachOtherTest extends FieldUnitTestBase {
'type' => $entity_type,
'id' => $entity->id(),
));
$values = $this->_generateTestFieldValues($this->field_2->getFieldCardinality());
$values = $this->_generateTestFieldValues($this->field_2->getCardinality());
$entity->{$this->field_name_2} = $values;
$entity->setNewRevision();
$entity->save();
@ -335,13 +335,13 @@ class FieldAttachOtherTest extends FieldUnitTestBase {
$form_state['form_display'] = entity_get_form_display($entity_type, $this->instance->bundle, 'default');
field_attach_form($entity, $form, $form_state);
$this->assertEqual($form[$this->field_name]['widget']['#title'], $this->instance->getFieldLabel(), "First field's form title is {$this->instance->getFieldLabel()}");
$this->assertEqual($form[$this->field_name_2]['widget']['#title'], $this->instance_2->getFieldLabel(), "Second field's form title is {$this->instance_2->getFieldLabel()}");
for ($delta = 0; $delta < $this->field->getFieldCardinality(); $delta++) {
$this->assertEqual($form[$this->field_name]['widget']['#title'], $this->instance->getLabel(), "First field's form title is {$this->instance->getLabel()}");
$this->assertEqual($form[$this->field_name_2]['widget']['#title'], $this->instance_2->getLabel(), "Second field's form title is {$this->instance_2->getLabel()}");
for ($delta = 0; $delta < $this->field->getCardinality(); $delta++) {
// field_test_widget uses 'textfield'
$this->assertEqual($form[$this->field_name]['widget'][$delta]['value']['#type'], 'textfield', "First field's form delta $delta widget is textfield");
}
for ($delta = 0; $delta < $this->field_2->getFieldCardinality(); $delta++) {
for ($delta = 0; $delta < $this->field_2->getCardinality(); $delta++) {
// field_test_widget uses 'textfield'
$this->assertEqual($form[$this->field_name_2]['widget'][$delta]['value']['#type'], 'textfield', "Second field's form delta $delta widget is textfield");
}
@ -354,8 +354,8 @@ class FieldAttachOtherTest extends FieldUnitTestBase {
field_attach_form($entity, $form, $form_state, NULL, $options);
$this->assertFalse(isset($form[$this->field_name]), 'The first field does not exist in the form');
$this->assertEqual($form[$this->field_name_2]['widget']['#title'], $this->instance_2->getFieldLabel(), "Second field's form title is {$this->instance_2->getFieldLabel()}");
for ($delta = 0; $delta < $this->field_2->getFieldCardinality(); $delta++) {
$this->assertEqual($form[$this->field_name_2]['widget']['#title'], $this->instance_2->getLabel(), "Second field's form title is {$this->instance_2->getLabel()}");
for ($delta = 0; $delta < $this->field_2->getCardinality(); $delta++) {
// field_test_widget uses 'textfield'
$this->assertEqual($form[$this->field_name_2]['widget'][$delta]['value']['#type'], 'textfield', "Second field's form delta $delta widget is textfield");
}
@ -380,11 +380,11 @@ class FieldAttachOtherTest extends FieldUnitTestBase {
// First field.
$values = array();
$weights = array();
for ($delta = 0; $delta < $this->field->getFieldCardinality(); $delta++) {
for ($delta = 0; $delta < $this->field->getCardinality(); $delta++) {
$values[$delta]['value'] = mt_rand(1, 127);
// Assign random weight.
do {
$weight = mt_rand(0, $this->field->getFieldCardinality());
$weight = mt_rand(0, $this->field->getCardinality());
} while (in_array($weight, $weights));
$weights[$delta] = $weight;
$values[$delta]['_weight'] = $weight;
@ -394,11 +394,11 @@ class FieldAttachOtherTest extends FieldUnitTestBase {
// Second field.
$values_2 = array();
$weights_2 = array();
for ($delta = 0; $delta < $this->field_2->getFieldCardinality(); $delta++) {
for ($delta = 0; $delta < $this->field_2->getCardinality(); $delta++) {
$values_2[$delta]['value'] = mt_rand(1, 127);
// Assign random weight.
do {
$weight = mt_rand(0, $this->field_2->getFieldCardinality());
$weight = mt_rand(0, $this->field_2->getCardinality());
} while (in_array($weight, $weights_2));
$weights_2[$delta] = $weight;
$values_2[$delta]['_weight'] = $weight;

View File

@ -48,7 +48,7 @@ class FieldAttachStorageTest extends FieldUnitTestBase {
function testFieldAttachSaveLoad() {
$entity_type = 'entity_test_rev';
$this->createFieldWithInstance('', $entity_type);
$cardinality = $this->field->getFieldCardinality();
$cardinality = $this->field->getCardinality();
// Configure the instance so that we test
// \Drupal\field_test\Plugin\Field\FieldType\TestItem::getCacheData().
@ -248,7 +248,7 @@ class FieldAttachStorageTest extends FieldUnitTestBase {
function testFieldAttachDelete() {
$entity_type = 'entity_test_rev';
$this->createFieldWithInstance('', $entity_type);
$cardinality = $this->field->getFieldCardinality();
$cardinality = $this->field->getCardinality();
$entity = entity_create($entity_type, array('type' => $this->instance->bundle));
$vids = array();
@ -306,7 +306,7 @@ class FieldAttachStorageTest extends FieldUnitTestBase {
function testEntityCreateRenameBundle() {
$entity_type = 'entity_test_rev';
$this->createFieldWithInstance('', $entity_type);
$cardinality = $this->field->getFieldCardinality();
$cardinality = $this->field->getCardinality();
// Create a new bundle.
$new_bundle = 'test_bundle_' . drupal_strtolower($this->randomName());
@ -376,7 +376,7 @@ class FieldAttachStorageTest extends FieldUnitTestBase {
// Save an entity with data for both fields
$entity = entity_create($entity_type, array('type' => $this->instance->bundle));
$values = $this->_generateTestFieldValues($this->field->getFieldCardinality());
$values = $this->_generateTestFieldValues($this->field->getCardinality());
$entity->{$this->field_name} = $values;
$entity->{$field_name} = $this->_generateTestFieldValues(1);
$entity = $this->entitySaveReload($entity);

View File

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

View File

@ -49,18 +49,18 @@ class FieldInfoTest extends FieldUnitTestBase {
$field->save();
$fields = field_info_fields();
$this->assertEqual(count($fields), count($core_fields) + 1, 'One new field exists');
$this->assertEqual($fields[$field->uuid]->getFieldName(), $field->getFieldName(), 'info fields contains field name');
$this->assertEqual($fields[$field->uuid]->getFieldType(), $field->getFieldType(), 'info fields contains field type');
$this->assertEqual($fields[$field->uuid]->getName(), $field->getName(), 'info fields contains field name');
$this->assertEqual($fields[$field->uuid]->getType(), $field->getType(), 'info fields contains field type');
$this->assertEqual($fields[$field->uuid]->module, 'field_test', 'info fields contains field module');
$settings = array('test_field_setting' => 'dummy test string');
foreach ($settings as $key => $val) {
$this->assertEqual($fields[$field->uuid]->getFieldSetting($key), $val, format_string('Field setting %key has correct default value %value', array('%key' => $key, '%value' => $val)));
$this->assertEqual($fields[$field->uuid]->getSetting($key), $val, format_string('Field setting %key has correct default value %value', array('%key' => $key, '%value' => $val)));
}
$this->assertEqual($fields[$field->uuid]->getFieldCardinality(), 1, 'info fields contains cardinality 1');
$this->assertEqual($fields[$field->uuid]->getCardinality(), 1, 'info fields contains cardinality 1');
// Create an instance, verify that it shows up
$instance_definition = array(
'field_name' => $field->getFieldName(),
'field_name' => $field->getName(),
'entity_type' => 'entity_test',
'bundle' => 'entity_test',
'label' => $this->randomName(),
@ -75,7 +75,7 @@ class FieldInfoTest extends FieldUnitTestBase {
$this->assertEqual(count($instances), 1, format_string('One instance shows up in info when attached to a bundle on a @label.', array(
'@label' => $info['label']
)));
$this->assertTrue($instance_definition < $instances[$instance->getFieldName()], 'Instance appears in info correctly');
$this->assertTrue($instance_definition < $instances[$instance->getName()], 'Instance appears in info correctly');
// Test a valid entity type but an invalid bundle.
$instances = field_info_instances('entity_test', 'invalid_bundle');

View File

@ -51,7 +51,7 @@ class FieldInstanceCrudTest extends FieldUnitTestBase {
$this->field = entity_create('field_entity', $this->field_definition);
$this->field->save();
$this->instance_definition = array(
'field_name' => $this->field->getFieldName(),
'field_name' => $this->field->getName(),
'entity_type' => 'entity_test',
'bundle' => 'entity_test',
);
@ -115,7 +115,7 @@ class FieldInstanceCrudTest extends FieldUnitTestBase {
// Read the instance back.
$instance = field_read_instance('entity_test', $this->instance_definition['field_name'], $this->instance_definition['bundle']);
$this->assertTrue($this->instance_definition['field_name'] == $instance->getFieldName(), 'The field was properly read.');
$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.');
}
@ -128,16 +128,16 @@ class FieldInstanceCrudTest extends FieldUnitTestBase {
// Check that basic changes are saved.
$instance = field_read_instance('entity_test', $this->instance_definition['field_name'], $this->instance_definition['bundle']);
$instance->required = !$instance->isFieldRequired();
$instance->required = !$instance->isRequired();
$instance->label = $this->randomName();
$instance->description = $this->randomName();
$instance->settings['test_instance_setting'] = $this->randomName();
$instance->save();
$instance_new = field_read_instance('entity_test', $this->instance_definition['field_name'], $this->instance_definition['bundle']);
$this->assertEqual($instance->isFieldRequired(), $instance_new->isFieldRequired(), '"required" change is saved');
$this->assertEqual($instance->getFieldLabel(), $instance_new->getFieldLabel(), '"label" change is saved');
$this->assertEqual($instance->getFieldDescription(), $instance_new->getFieldDescription(), '"description" change is saved');
$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');
// TODO: test failures.
}

View File

@ -54,14 +54,14 @@ class FieldValidationTest extends FieldUnitTestBase {
// Check that the expected constraint violations are reported.
$this->assertEqual(count($violations), 1);
$this->assertEqual($violations[0]->getPropertyPath(), '');
$this->assertEqual($violations[0]->getMessage(), t('%name: this field cannot hold more than @count values.', array('%name' => $this->instance->getFieldLabel(), '@count' => $cardinality)));
$this->assertEqual($violations[0]->getMessage(), t('%name: this field cannot hold more than @count values.', array('%name' => $this->instance->getLabel(), '@count' => $cardinality)));
}
/**
* Tests that constraints defined by the field type are validated.
*/
function testFieldConstraints() {
$cardinality = $this->field->getFieldCardinality();
$cardinality = $this->field->getCardinality();
$entity = $this->entity;
// The test is only valid if the field cardinality is greater than 2.
@ -76,7 +76,7 @@ class FieldValidationTest extends FieldUnitTestBase {
}
else {
$value = -1;
$expected_violations[$delta . '.value'][] = t('%name does not accept the value -1.', array('%name' => $this->instance->getFieldLabel()));
$expected_violations[$delta . '.value'][] = t('%name does not accept the value -1.', array('%name' => $this->instance->getLabel()));
}
$entity->{$this->field_name}->offsetGet($delta)->set('value', $value);
}

View File

@ -615,7 +615,7 @@ class FormTest extends FieldTestBase {
$this->instance->default_value = NULL;
$this->instance->save();
entity_get_form_display($entity_type, $this->instance->bundle, 'default')
->setComponent($this->instance->getFieldName(), array(
->setComponent($this->instance->getName(), array(
'type' => 'test_field_widget',
))
->save();
@ -635,7 +635,7 @@ class FormTest extends FieldTestBase {
// Set the field back to hidden.
entity_get_form_display($entity_type, $this->instance->bundle, 'default')
->removeComponent($this->instance->getFieldName())
->removeComponent($this->instance->getName())
->save();
// Create a new revision.

View File

@ -164,7 +164,7 @@ class TranslationTest extends FieldUnitTestBase {
$available_langcodes = array_keys(language_list());
$entity->langcode->value = reset($available_langcodes);
foreach ($available_langcodes as $langcode) {
$field_translations[$langcode] = $this->_generateTestFieldValues($this->field->getFieldCardinality());
$field_translations[$langcode] = $this->_generateTestFieldValues($this->field->getCardinality());
$entity->getTranslation($langcode)->{$this->field_name}->setValue($field_translations[$langcode]);
}
@ -201,7 +201,7 @@ class TranslationTest extends FieldUnitTestBase {
$values = array('type' => $instance->bundle, 'langcode' => $translation_langcodes[0]);
$entity = entity_create($entity_type, $values);
foreach ($translation_langcodes as $langcode) {
$values[$this->field_name][$langcode] = $this->_generateTestFieldValues($this->field->getFieldCardinality());
$values[$this->field_name][$langcode] = $this->_generateTestFieldValues($this->field->getCardinality());
$entity->getTranslation($langcode, FALSE)->{$this->field_name}->setValue($values[$this->field_name][$langcode]);
}
@ -219,7 +219,7 @@ class TranslationTest extends FieldUnitTestBase {
$values = array('type' => $instance->bundle, 'langcode' => $translation_langcodes[0]);
$entity = entity_create($entity_type, $values);
foreach ($translation_langcodes as $langcode) {
$values[$this->field_name][$langcode] = $this->_generateTestFieldValues($this->field->getFieldCardinality());
$values[$this->field_name][$langcode] = $this->_generateTestFieldValues($this->field->getCardinality());
$entity->getTranslation($langcode)->{$this->field_name}->setValue($values[$this->field_name][$langcode]);
$entity->getTranslation($langcode)->{$field_name_default}->setValue($empty_items);
$values[$field_name_default][$langcode] = $empty_items;

View File

@ -106,7 +106,7 @@ class TranslationWebTest extends FieldTestBase {
$available_langcodes = array_flip(field_available_languages($this->entity_type, $this->field));
unset($available_langcodes[Language::LANGCODE_NOT_SPECIFIED]);
unset($available_langcodes[Language::LANGCODE_NOT_APPLICABLE]);
$field_name = $this->field->getFieldName();
$field_name = $this->field->getName();
// Store the field translations.
ksort($available_langcodes);
@ -135,7 +135,7 @@ class TranslationWebTest extends FieldTestBase {
* by the passed arguments were correctly stored.
*/
private function checkTranslationRevisions($id, $revision_id, $available_langcodes) {
$field_name = $this->field->getFieldName();
$field_name = $this->field->getName();
$entity = entity_revision_load($this->entity_type, $revision_id);
foreach ($available_langcodes as $langcode => $value) {
$passed = $entity->getTranslation($langcode)->{$field_name}->value == $value + 1;

View File

@ -75,7 +75,7 @@ abstract class FieldTestBase extends ViewTestBase {
function setUpInstances($bundle = 'page') {
foreach ($this->fields as $key => $field) {
$instance = array(
'field_name' => $field->getFieldName(),
'field_name' => $field->getName(),
'entity_type' => 'node',
'bundle' => 'page',
);

View File

@ -73,13 +73,13 @@ class HandlerFieldFieldTest extends FieldTestBase {
for ($key = 0; $key < 3; $key++) {
$field = $this->fields[$key];
$edit[$field->getFieldName()][0]['value'] = $this->randomName(8);
$edit[$field->getName()][0]['value'] = $this->randomName(8);
}
for ($j = 0; $j < 5; $j++) {
$edit[$this->fields[3]->getFieldName()][$j]['value'] = $this->randomName(8);
$edit[$this->fields[3]->getName()][$j]['value'] = $this->randomName(8);
}
// Set this field to be empty.
$edit[$this->fields[4]->getFieldName()] = array(array('value' => NULL));
$edit[$this->fields[4]->getName()] = array(array('value' => NULL));
$this->nodes[$i] = $this->drupalCreateNode($edit);
}
@ -96,7 +96,7 @@ class HandlerFieldFieldTest extends FieldTestBase {
protected function prepareView(ViewExecutable $view) {
$view->initDisplay();
foreach ($this->fields as $field) {
$field_name = $field->getFieldName();
$field_name = $field->getName();
$view->display_handler->options['fields'][$field_name]['id'] = $field_name;
$view->display_handler->options['fields'][$field_name]['table'] = 'node__' . $field_name;
$view->display_handler->options['fields'][$field_name]['field'] = $field_name;
@ -117,7 +117,7 @@ class HandlerFieldFieldTest extends FieldTestBase {
// Tests that the rendered fields match the actual value of the fields.
for ($i = 0; $i < 3; $i++) {
for ($key = 0; $key < 2; $key++) {
$field_name = $this->fields[$key]->getFieldName();
$field_name = $this->fields[$key]->getName();
$rendered_field = $view->style_plugin->getField($i, $field_name);
$expected_field = $this->nodes[$i]->$field_name->value;
$this->assertEqual($rendered_field, $expected_field);
@ -131,8 +131,8 @@ class HandlerFieldFieldTest extends FieldTestBase {
public function _testFormatterSimpleFieldRender() {
$view = views_get_view('test_view_fieldapi');
$this->prepareView($view);
$view->displayHandlers->get('default')->options['fields'][$this->fields[0]->getFieldName()]['type'] = 'text_trimmed';
$view->displayHandlers->get('default')->options['fields'][$this->fields[0]->getFieldName()]['settings'] = array(
$view->displayHandlers->get('default')->options['fields'][$this->fields[0]->getName()]['type'] = 'text_trimmed';
$view->displayHandlers->get('default')->options['fields'][$this->fields[0]->getName()]['settings'] = array(
'trim_length' => 3,
);
$this->executeView($view);
@ -140,14 +140,14 @@ class HandlerFieldFieldTest extends FieldTestBase {
// Make sure that the formatter works as expected.
// @TODO: actually there should be a specific formatter.
for ($i = 0; $i < 2; $i++) {
$rendered_field = $view->style_plugin->getField($i, $this->fields[0]->getFieldName());
$rendered_field = $view->style_plugin->getField($i, $this->fields[0]->getName());
$this->assertEqual(strlen($rendered_field), 3);
}
}
public function _testMultipleFieldRender() {
$view = views_get_view('test_view_fieldapi');
$field_name = $this->fields[3]->getFieldName();
$field_name = $this->fields[3]->getName();
// Test delta limit.
$this->prepareView($view);
@ -167,8 +167,7 @@ class HandlerFieldFieldTest extends FieldTestBase {
}
// Test that an empty field is rendered without error.
$view->style_plugin->getField(4, $this->fields[4]->getFieldName());
$view->style_plugin->getField(4, $this->fields[4]->getName());
$view->destroy();
// Test delta limit + offset

View File

@ -22,7 +22,7 @@ function field_test_field_widget_info_alter(&$info) {
* Implements hook_field_update_forbid().
*/
function field_test_field_update_forbid($field, $prior_field) {
if ($field->getFieldType() == 'test_field' && $field->getFieldSetting('unchangeable') != $prior_field->getFieldSetting('unchangeable')) {
if ($field->getType() == 'test_field' && $field->getSetting('unchangeable') != $prior_field->getSetting('unchangeable')) {
throw new FieldException("field_test 'unchangeable' setting cannot be changed'");
}
}
@ -38,13 +38,13 @@ function field_test_default_value(EntityInterface $entity, $field, $instance) {
* Implements hook_entity_field_access().
*/
function field_test_entity_field_access($operation, FieldDefinitionInterface $field_definition, AccountInterface $account, FieldItemListInterface $items = NULL) {
if ($field_definition->getFieldName() == "field_no_{$operation}_access") {
if ($field_definition->getName() == "field_no_{$operation}_access") {
return FALSE;
}
// Only grant view access to test_view_field fields when the user has
// 'view test_view_field content' permission.
if ($field_definition->getFieldName() == 'test_view_field' && $operation == 'view' && !$account->hasPermission('view test_view_field content')) {
if ($field_definition->getName() == 'test_view_field' && $operation == 'view' && !$account->hasPermission('view test_view_field content')) {
return FALSE;
}

View File

@ -142,7 +142,7 @@ function field_test_field_attach_view_alter(&$output, $context) {
*/
function field_test_field_widget_form_alter(&$element, &$form_state, $context) {
$field_definition = $context['items']->getFieldDefinition();
switch ($field_definition->getFieldName()) {
switch ($field_definition->getName()) {
case 'alter_test_text':
drupal_set_message('Field size: ' . $context['widget']->getSetting('size'));
break;

View File

@ -56,13 +56,13 @@ class ShapeItem extends ConfigFieldItemBase {
public static function schema(FieldInterface $field) {
$foreign_keys = array();
// The 'foreign keys' key is not always used in tests.
if ($field->getFieldSetting('foreign_key_name')) {
if ($field->getSetting('foreign_key_name')) {
$foreign_keys['foreign keys'] = array(
// This is a dummy foreign key definition, references a table that
// doesn't exist, but that's not a problem.
$field->getFieldSetting('foreign_key_name') => array(
'table' => $field->getFieldSetting('foreign_key_name'),
'columns' => array($field->getFieldSetting('foreign_key_name') => 'id'),
$field->getSetting('foreign_key_name') => array(
'table' => $field->getSetting('foreign_key_name'),
'columns' => array($field->getSetting('foreign_key_name') => 'id'),
),
);
}

View File

@ -137,7 +137,7 @@ class TestItem extends ConfigFieldItemBase implements PrepareCacheInterface {
'value' => array(
'TestField' => array(
'value' => -1,
'message' => t('%name does not accept the value @value.', array('%name' => $this->getFieldDefinition()->getFieldLabel(), '@value' => -1)),
'message' => t('%name does not accept the value @value.', array('%name' => $this->getFieldDefinition()->getLabel(), '@value' => -1)),
)
),
));

View File

@ -57,7 +57,7 @@ class DisplayOverview extends DisplayOverviewBase {
$label = array(
'label' => array(
'#type' => 'select',
'#title' => $this->t('Label display for @title', array('@title' => $instance->getFieldLabel())),
'#title' => $this->t('Label display for @title', array('@title' => $instance->getLabel())),
'#title_display' => 'invisible',
'#options' => $this->getFieldLabelOptions(),
'#default_value' => $display_options ? $display_options['label'] : 'above',
@ -68,7 +68,7 @@ class DisplayOverview extends DisplayOverviewBase {
$field_row = array_slice($field_row, 0, $label_position, TRUE) + $label + array_slice($field_row, $label_position, count($field_row) - 1, TRUE);
// Update the (invisible) title of the 'plugin' column.
$field_row['plugin']['#title'] = $this->t('Formatter for @title', array('@title' => $instance->getFieldLabel()));
$field_row['plugin']['#title'] = $this->t('Formatter for @title', array('@title' => $instance->getLabel()));
if (!empty($field_row['plugin']['settings_edit_form'])) {
$plugin_type_info = $entity_display->getRenderer($field_id)->getPluginDefinition();
$field_row['plugin']['settings_edit_form']['label']['#markup'] = $this->t('Format settings:') . ' <span class="plugin-name">' . $plugin_type_info['label'] . '</span>';

View File

@ -221,7 +221,7 @@ abstract class DisplayOverviewBase extends OverviewBase {
*/
protected function buildFieldRow($field_id, FieldInstanceInterface $instance, EntityDisplayBaseInterface $entity_display, array $form, array &$form_state) {
$display_options = $entity_display->getComponent($field_id);
$label = $instance->getFieldLabel();
$label = $instance->getLabel();
$field_row = array(
'#attributes' => array('class' => array('draggable', 'tabledrag-leaf')),
@ -229,7 +229,7 @@ abstract class DisplayOverviewBase extends OverviewBase {
'#region_callback' => array($this, 'getRowRegion'),
'#js_settings' => array(
'rowHandler' => 'field',
'defaultPlugin' => $this->getDefaultPlugin($instance->getFieldType()),
'defaultPlugin' => $this->getDefaultPlugin($instance->getType()),
),
'human_name' => array(
'#markup' => check_plain($label),
@ -266,7 +266,7 @@ abstract class DisplayOverviewBase extends OverviewBase {
'#type' => 'select',
'#title' => $this->t('Plugin for @title', array('@title' => $label)),
'#title_display' => 'invisible',
'#options' => $this->getPluginOptions($instance->getFieldType()),
'#options' => $this->getPluginOptions($instance->getType()),
'#default_value' => $display_options ? $display_options['type'] : 'hidden',
'#parents' => array('fields', $field_id, 'type'),
'#attributes' => array('class' => array('field-plugin-type')),

View File

@ -125,14 +125,14 @@ class FieldOverview extends OverviewBase {
'id' => drupal_html_class($name),
),
'label' => array(
'#markup' => check_plain($instance->getFieldLabel()),
'#markup' => check_plain($instance->getLabel()),
),
'field_name' => array(
'#markup' => $instance->getFieldName(),
'#markup' => $instance->getName(),
),
'type' => array(
'#type' => 'link',
'#title' => $field_types[$field->getFieldType()]['label'],
'#title' => $field_types[$field->getType()]['label'],
'#href' => $admin_field_path . '/field',
'#options' => array('attributes' => array('title' => $this->t('Edit field settings.'))),
),
@ -423,7 +423,7 @@ class FieldOverview extends OverviewBase {
$form_state['fields_added']['_add_new_field'] = $values['field_name'];
}
catch (\Exception $e) {
drupal_set_message($this->t('There was a problem creating field %label: !message', array('%label' => $instance->getFieldLabel(), '!message' => $e->getMessage())), 'error');
drupal_set_message($this->t('There was a problem creating field %label: !message', array('%label' => $instance->getLabel(), '!message' => $e->getMessage())), 'error');
}
}
@ -466,7 +466,7 @@ class FieldOverview extends OverviewBase {
$form_state['fields_added']['_add_existing_field'] = $instance['field_name'];
}
catch (\Exception $e) {
drupal_set_message($this->t('There was a problem creating field instance %label: @message.', array('%label' => $instance->getFieldLabel(), '@message' => $e->getMessage())), 'error');
drupal_set_message($this->t('There was a problem creating field instance %label: @message.', array('%label' => $instance->getLabel(), '@message' => $e->getMessage())), 'error');
}
}
}
@ -515,14 +515,14 @@ class FieldOverview extends OverviewBase {
// Do not show:
// - locked fields,
// - fields that should not be added via user interface.
$field_type = $instance->getFieldType();
$field_type = $instance->getType();
$field = $instance->getField();
if (empty($field->locked) && empty($field_types[$field_type]['no_ui'])) {
$options[$instance->getFieldName()] = array(
$options[$instance->getName()] = array(
'type' => $field_type,
'type_label' => $field_types[$field_type]['label'],
'field' => $instance->getFieldName(),
'label' => $instance->getFieldLabel(),
'field' => $instance->getName(),
'label' => $instance->getLabel(),
);
}
}

View File

@ -46,7 +46,7 @@ class FieldDeleteForm extends EntityConfirmFormBase {
* {@inheritdoc}
*/
public function getQuestion() {
return $this->t('Are you sure you want to delete the field %field?', array('%field' => $this->entity->getFieldLabel()));
return $this->t('Are you sure you want to delete the field %field?', array('%field' => $this->entity->getLabel()));
}
/**

View File

@ -107,7 +107,7 @@ class FieldEditForm extends FormBase {
}
// Build the configurable field values.
$cardinality = $field->getFieldCardinality();
$cardinality = $field->getCardinality();
$form['field']['cardinality_container'] = array(
// We can't use the container element because it doesn't support the title
// or description properties.
@ -143,8 +143,8 @@ class FieldEditForm extends FormBase {
);
// Build the non-configurable field values.
$form['field']['field_name'] = array('#type' => 'value', '#value' => $field->getFieldName());
$form['field']['type'] = array('#type' => 'value', '#value' => $field->getFieldType());
$form['field']['field_name'] = array('#type' => 'value', '#value' => $field->getName());
$form['field']['type'] = array('#type' => 'value', '#value' => $field->getType());
$form['field']['module'] = array('#type' => 'value', '#value' => $field->module);
// Add settings provided by the field module. The field module is
@ -157,7 +157,7 @@ class FieldEditForm extends FormBase {
// FieldItem.
$ids = (object) array('entity_type' => $this->instance->entity_type, 'bundle' => $this->instance->bundle, 'entity_id' => NULL);
$entity = _field_create_entity_from_ids($ids);
$form['field']['settings'] += $entity->get($field->getFieldName())->offsetGet(0)->settingsForm($form, $form_state, $field->hasData());
$form['field']['settings'] += $entity->get($field->getName())->offsetGet(0)->settingsForm($form, $form_state, $field->hasData());
$form['actions'] = array('#type' => 'actions');
$form['actions']['submit'] = array('#type' => 'submit', '#value' => $this->t('Save field settings'));

View File

@ -71,7 +71,7 @@ class FieldInstanceEditForm extends FormBase {
$bundles = entity_get_bundles();
$form_title = $this->t('%instance settings for %bundle', array(
'%instance' => $this->instance->getFieldLabel(),
'%instance' => $this->instance->getLabel(),
'%bundle' => $bundles[$entity_type][$bundle]['label'],
));
$form['#title'] = $form_title;
@ -80,11 +80,11 @@ class FieldInstanceEditForm extends FormBase {
// Create an arbitrary entity object (used by the 'default value' widget).
$ids = (object) array('entity_type' => $this->instance->entity_type, 'bundle' => $this->instance->bundle, 'entity_id' => NULL);
$form['#entity'] = _field_create_entity_from_ids($ids);
$items = $form['#entity']->get($this->instance->getFieldName());
$items = $form['#entity']->get($this->instance->getName());
if (!empty($field->locked)) {
$form['locked'] = array(
'#markup' => $this->t('The field %field is locked and cannot be edited.', array('%field' => $this->instance->getFieldLabel())),
'#markup' => $this->t('The field %field is locked and cannot be edited.', array('%field' => $this->instance->getLabel())),
);
return $form;
}
@ -97,7 +97,7 @@ class FieldInstanceEditForm extends FormBase {
// Build the non-configurable instance values.
$form['instance']['field_name'] = array(
'#type' => 'value',
'#value' => $this->instance->getFieldName(),
'#value' => $this->instance->getName(),
);
$form['instance']['entity_type'] = array(
'#type' => 'value',
@ -112,7 +112,7 @@ class FieldInstanceEditForm extends FormBase {
$form['instance']['label'] = array(
'#type' => 'textfield',
'#title' => $this->t('Label'),
'#default_value' => $this->instance->getFieldLabel() ?: $field->getFieldName(),
'#default_value' => $this->instance->getLabel() ?: $field->getName(),
'#required' => TRUE,
'#weight' => -20,
);
@ -120,7 +120,7 @@ class FieldInstanceEditForm extends FormBase {
$form['instance']['description'] = array(
'#type' => 'textarea',
'#title' => $this->t('Help text'),
'#default_value' => $this->instance->getFieldDescription(),
'#default_value' => $this->instance->getDescription(),
'#rows' => 5,
'#description' => $this->t('Instructions to present to the user below this field on the editing form.<br />Allowed HTML tags: @tags', array('@tags' => _field_filter_xss_display_allowed_tags())) . '<br />' . $this->t('This field supports tokens.'),
'#weight' => -10,
@ -129,7 +129,7 @@ class FieldInstanceEditForm extends FormBase {
$form['instance']['required'] = array(
'#type' => 'checkbox',
'#title' => $this->t('Required field'),
'#default_value' => $this->instance->isFieldRequired(),
'#default_value' => $this->instance->isRequired(),
'#weight' => -5,
);
@ -165,7 +165,7 @@ class FieldInstanceEditForm extends FormBase {
*/
public function validateForm(array &$form, array &$form_state) {
if (isset($form['instance']['default_value'])) {
$items = $form['#entity']->get($this->instance->getFieldName());
$items = $form['#entity']->get($this->instance->getName());
$items->defaultValuesFormValidate($form['instance']['default_value'], $form, $form_state);
}
}
@ -177,7 +177,7 @@ class FieldInstanceEditForm extends FormBase {
// Handle the default value.
$default_value = array();
if (isset($form['instance']['default_value'])) {
$items = $form['#entity']->get($this->instance->getFieldName());
$items = $form['#entity']->get($this->instance->getName());
$default_value = $items->defaultValuesFormSubmit($form['instance']['default_value'], $form, $form_state);
}
$this->instance->default_value = $default_value;
@ -188,7 +188,7 @@ class FieldInstanceEditForm extends FormBase {
}
$this->instance->save();
drupal_set_message($this->t('Saved %label configuration.', array('%label' => $this->instance->getFieldLabel())));
drupal_set_message($this->t('Saved %label configuration.', array('%label' => $this->instance->getLabel())));
if ($next_destination = FieldUI::getNextDestination($this->getRequest())) {
$form_state['redirect'] = $next_destination;

View File

@ -53,7 +53,7 @@ class FormDisplayOverview extends DisplayOverviewBase {
$field_row = parent::buildFieldRow($field_id, $instance, $entity_display, $form, $form_state);
// Update the (invisible) title of the 'plugin' column.
$field_row['plugin']['#title'] = $this->t('Formatter for @title', array('@title' => $instance->getFieldLabel()));
$field_row['plugin']['#title'] = $this->t('Formatter for @title', array('@title' => $instance->getLabel()));
if (!empty($field_row['plugin']['settings_edit_form']) && ($plugin = $entity_display->getRenderer($field_id))) {
$plugin_type_info = $plugin->getPluginDefinition();
$field_row['plugin']['settings_edit_form']['label']['#markup'] = $this->t('Widget settings:') . ' <span class="plugin-name">' . $plugin_type_info['label'] . '</span>';

View File

@ -239,11 +239,11 @@ class ManageFieldsTest extends FieldUiTestBase {
field_info_cache_clear();
// Assert field settings.
$field = field_info_field($entity_type, $field_name);
$this->assertTrue($field->getFieldSetting('test_field_setting') == $string, 'Field settings were found.');
$this->assertTrue($field->getSetting('test_field_setting') == $string, 'Field settings were found.');
// Assert instance settings.
$instance = field_info_instance($entity_type, $field_name, $bundle);
$this->assertTrue($instance->getFieldSetting('test_instance_setting') == $string, 'Field instance settings were found.');
$this->assertTrue($instance->getSetting('test_instance_setting') == $string, 'Field instance settings were found.');
}
/**

View File

@ -61,7 +61,7 @@ function file_field_widget_multiple_count_validate($element, &$form_state, $form
$current = count(element_children(NestedArray::getValue($form, $parents))) - 1;
$field = field_info_field($entity_type, $field_name);
$cardinality = $field->getFieldCardinality();
$cardinality = $field->getCardinality();
$uploaded = count($values['fids']);
$count = $uploaded + $current;
if ($count > $cardinality) {

View File

@ -1881,7 +1881,7 @@ function file_get_file_references(File $file, $field = NULL, $age = EntityStorag
// This contains the possible field names.
$instances = field_info_instances($entity_type, $bundle);
foreach ($instances as $field_name => $instance) {
$field_type = $instance->getFieldType();
$field_type = $instance->getType();
// If this is the first time this field type is seen, check
// whether it references files.
if (!isset($field_columns[$field_type])) {
@ -1921,7 +1921,7 @@ function file_get_file_references(File $file, $field = NULL, $age = EntityStorag
foreach ($return as $field_name => $data) {
foreach (array_keys($data) as $entity_type) {
$current_field = field_info_field($entity_type, $field_name);
if (($field_type && $current_field->getFieldType() != $field_type) || ($field && $field->uuid() != $current_field->uuid())) {
if (($field_type && $current_field->getType() != $field_type) || ($field && $field->uuid() != $current_field->uuid())) {
unset($return[$field_name][$entity_type]);
}
}

View File

@ -469,12 +469,12 @@ function file_field_views_data(FieldInterface $field) {
$data = field_views_field_default_views_data($field);
foreach ($data as $table_name => $table_data) {
// Add the relationship only on the fid field.
$data[$table_name][$field->getFieldName() . '_target_id']['relationship'] = array(
$data[$table_name][$field->getName() . '_target_id']['relationship'] = array(
'id' => 'standard',
'base' => 'file_managed',
'entity type' => 'file',
'base field' => 'target_id',
'label' => t('file from !field_name', array('!field_name' => $field->getFieldName())),
'label' => t('file from !field_name', array('!field_name' => $field->getName())),
);
}
@ -489,7 +489,7 @@ function file_field_views_data(FieldInterface $field) {
function file_field_views_data_views_data_alter(array &$data, FieldInterface $field) {
$entity_type = $field->entity_type;
$entity_info = entity_get_info($entity_type);
$field_name = $field->getFieldName();
$field_name = $field->getName();
$pseudo_field_name = 'reverse_' . $field_name . '_' . $entity_type;
list($label) = field_views_field_label($entity_type, $field_name);

View File

@ -233,7 +233,7 @@ class File extends ContentEntityBase implements FileInterface {
$fields['uid'] = FieldDefinition::create('entity_reference')
->setLabel(t('User ID'))
->setDescription(t('The user ID of the file.'))
->setFieldSetting('target_type', 'user');
->setSetting('target_type', 'user');
$fields['filename'] = FieldDefinition::create('string')
->setLabel(t('Filename'))

View File

@ -53,7 +53,7 @@ class FileFieldItemList extends ConfigFieldItemList {
}
// Get the file IDs attached to the field before this update.
$field_name = $this->getFieldDefinition()->getFieldName();
$field_name = $this->getFieldDefinition()->getName();
$original_fids = array();
$original_items = $entity->original->getTranslation($this->getLangcode())->$field_name;
foreach ($original_items as $item) {

View File

@ -61,7 +61,7 @@ class FileWidget extends WidgetBase {
* Special handling for draggable multiple widgets and 'add more' button.
*/
protected function formMultipleElements(FieldItemListInterface $items, array &$form, array &$form_state) {
$field_name = $this->fieldDefinition->getFieldName();
$field_name = $this->fieldDefinition->getName();
$parents = $form['#parents'];
// Load the items for form rebuilds from the field state as they might not be
@ -73,7 +73,7 @@ class FileWidget extends WidgetBase {
}
// Determine the number of widgets to display.
$cardinality = $this->fieldDefinition->getFieldCardinality();
$cardinality = $this->fieldDefinition->getCardinality();
switch ($cardinality) {
case FieldDefinitionInterface::CARDINALITY_UNLIMITED:
$max = count($items);
@ -86,8 +86,8 @@ class FileWidget extends WidgetBase {
break;
}
$title = check_plain($this->fieldDefinition->getFieldLabel());
$description = field_filter_xss($this->fieldDefinition->getFieldDescription());
$title = check_plain($this->fieldDefinition->getLabel());
$description = field_filter_xss($this->fieldDefinition->getDescription());
$elements = array();
@ -183,7 +183,7 @@ class FileWidget extends WidgetBase {
'description_field' => NULL,
);
$cardinality = $this->fieldDefinition->getFieldCardinality();
$cardinality = $this->fieldDefinition->getCardinality();
$defaults = array(
'fids' => array(),
'display' => (bool) $field_settings['display_default'],

View File

@ -161,7 +161,7 @@ abstract class FileFieldTestBase extends WebTestBase {
// Attach a file to the node.
$field = field_info_field('node', $field_name);
$name = 'files[' . $field_name . '_0]';
if ($field->getFieldCardinality() != 1) {
if ($field->getCardinality() != 1) {
$name .= '[]';
}
$edit[$name] = drupal_realpath($file->getFileUri());

View File

@ -40,7 +40,7 @@ class FileFieldValidateTest extends FileFieldTestBase {
$edit = array();
$edit['title[0][value]'] = $this->randomName();
$this->drupalPostForm('node/add/' . $type_name, $edit, t('Save and publish'));
$this->assertRaw(t('!title field is required.', array('!title' => $instance->getFieldLabel())), 'Node save failed when required file field was empty.');
$this->assertRaw(t('!title field is required.', array('!title' => $instance->getLabel())), 'Node save failed when required file field was empty.');
// Create a new node with the uploaded file.
$nid = $this->uploadNodeFile($test_file, $field_name, $type_name);
@ -60,7 +60,7 @@ class FileFieldValidateTest extends FileFieldTestBase {
$edit = array();
$edit['title[0][value]'] = $this->randomName();
$this->drupalPostForm('node/add/' . $type_name, $edit, t('Save and publish'));
$this->assertRaw(t('!title field is required.', array('!title' => $instance->getFieldLabel())), 'Node save failed when required multiple value file field was empty.');
$this->assertRaw(t('!title field is required.', array('!title' => $instance->getLabel())), 'Node save failed when required multiple value file field was empty.');
// Create a new node with the uploaded file into the multivalue field.
$nid = $this->uploadNodeFile($test_file, $field_name, $type_name);

View File

@ -75,7 +75,7 @@ function file_module_test_form_submit($form, &$form_state) {
* Implements hook_file_download_access().
*/
function file_module_test_file_download_access(FieldInterface $field, EntityInterface $entity, File $file) {
$instance = field_info_instance($entity->entityType(), $field->getFieldName(), $entity->bundle());
$instance = field_info_instance($entity->entityType(), $field->getName(), $entity->bundle());
// Allow the file to be downloaded only if the given arguments are correct.
// If any are wrong, $instance will be NULL.
if (empty($instance)) {

View File

@ -65,7 +65,7 @@ class EntityReferenceItemNormalizer extends FieldItemNormalizer implements UuidR
protected function constructValue($data, $context) {
$field_item = $context['target_instance'];
$field_definition = $field_item->getFieldDefinition();
$target_type = $field_definition->getFieldSetting('target_type');
$target_type = $field_definition->getSetting('target_type');
if ($id = $this->entityResolver->resolve($this, $data, $target_type)) {
return array('target_id' => $id);
}

View File

@ -58,7 +58,7 @@ class FieldItemNormalizer extends NormalizerBase {
$langcode = $data['lang'];
unset($data['lang']);
$field_definition = $field_item->getFieldDefinition();
if ($field_definition->isFieldTranslatable()) {
if ($field_definition->isTranslatable()) {
$field_item = $this->createTranslatedInstance($field_item, $langcode);
}
}

View File

@ -37,7 +37,7 @@ class FieldNormalizer extends NormalizerBase {
// If this field is not translatable, it can simply be normalized without
// separating it into different translations.
if (!$field_definition->isFieldTranslatable()) {
if (!$field_definition->isTranslatable()) {
$normalized_field_items = $this->normalizeFieldItems($field, $format, $context);
}
// Otherwise, the languages have to be extracted from the entity and passed

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