Commit 840e20ae authored by alexpott's avatar alexpott

Issue #2097691 by plopesc, amateescu: Move FIELD_CARDINALITY_UNLIMITED...

Issue #2097691 by plopesc, amateescu: Move FIELD_CARDINALITY_UNLIMITED constant to FieldDefinitionInterface.
parent 5fd14ba7
......@@ -871,7 +871,7 @@ protected function doLoadFieldItems($entities, $age) {
$delta_count[$row->entity_id][$row->langcode] = 0;
}
if ($field->getFieldCardinality() == FIELD_CARDINALITY_UNLIMITED || $delta_count[$row->entity_id][$row->langcode] < $field->getFieldCardinality()) {
if ($field->getFieldCardinality() == FieldInterface::CARDINALITY_UNLIMITED || $delta_count[$row->entity_id][$row->langcode] < $field->getFieldCardinality()) {
$item = array();
// For each column declared by the field, populate the item from the
// prefixed database column.
......@@ -953,7 +953,7 @@ protected function doSaveFieldItems(EntityInterface $entity, $update) {
$query->values($record);
$revision_query->values($record);
if ($field->getFieldCardinality() != FIELD_CARDINALITY_UNLIMITED && ++$delta_count == $field->getFieldCardinality()) {
if ($field->getFieldCardinality() != FieldInterface::CARDINALITY_UNLIMITED && ++$delta_count == $field->getFieldCardinality()) {
break;
}
}
......
......@@ -61,7 +61,7 @@ public function getConstraints() {
// form submitted values, this can only happen with 'multiple value'
// widgets.
$cardinality = $this->getFieldDefinition()->getFieldCardinality();
if ($cardinality != FIELD_CARDINALITY_UNLIMITED) {
if ($cardinality != FieldDefinitionInterface::CARDINALITY_UNLIMITED) {
$constraints[] = \Drupal::typedData()
->getValidationConstraintManager()
->create('Count', array(
......
......@@ -188,6 +188,14 @@ public function isFieldRequired() {
return !empty($this->definition['required']);
}
/**
* {@inheritdoc}
*/
public function isFieldMultiple() {
$cardinality = $this->getFieldCardinality();
return ($cardinality == static::CARDINALITY_UNLIMITED) || ($cardinality > 1);
}
/**
* Sets whether the field is required.
*
......
......@@ -53,6 +53,11 @@
*/
interface FieldDefinitionInterface {
/**
* Value indicating a field accepts an unlimited number of values.
*/
const CARDINALITY_UNLIMITED = -1;
/**
* Returns the machine name of the field.
*
......@@ -151,7 +156,8 @@ public function getFieldDescription();
/**
* Returns the maximum number of items allowed for the field.
*
* Possible values are positive integers or FIELD_CARDINALITY_UNLIMITED.
* Possible values are positive integers or
* FieldDefinitionInterface::CARDINALITY_UNLIMITED.
*
* @return integer
* The field cardinality.
......@@ -169,6 +175,14 @@ public function getFieldCardinality();
*/
public function isFieldRequired();
/**
* Returns whether the field can contain multiple items.
*
* @return bool
* TRUE if the field can contain multiple items, FALSE otherwise.
*/
public function isFieldMultiple();
/**
* Returns the default value for the field in a newly created entity.
*
......
......@@ -146,7 +146,7 @@ protected function formMultipleElements(FieldItemListInterface $items, array &$f
// Determine the number of widgets to display.
switch ($cardinality) {
case FIELD_CARDINALITY_UNLIMITED:
case FieldDefinitionInterface::CARDINALITY_UNLIMITED:
$field_state = field_form_get_state($parents, $field_name, $form_state);
$max = $field_state['items_count'];
$is_multiple = TRUE;
......@@ -200,6 +200,7 @@ protected function formMultipleElements(FieldItemListInterface $items, array &$f
'#theme' => 'field_multiple_value_form',
'#field_name' => $field_name,
'#cardinality' => $cardinality,
'#cardinality_multiple' => $this->fieldDefinition->isFieldMultiple(),
'#required' => $this->fieldDefinition->isFieldRequired(),
'#title' => $title,
'#description' => $description,
......@@ -209,7 +210,7 @@ protected function formMultipleElements(FieldItemListInterface $items, array &$f
);
// Add 'add more' button, if not working with a programmed form.
if ($cardinality == FIELD_CARDINALITY_UNLIMITED && empty($form_state['programmed'])) {
if ($cardinality == FieldDefinitionInterface::CARDINALITY_UNLIMITED && empty($form_state['programmed'])) {
$elements['add_more'] = array(
'#type' => 'submit',
'#name' => strtr($id_prefix, '-', '_') . '_add_more',
......@@ -404,9 +405,7 @@ public function massageFormValues(array $values, array $form, array &$form_state
* The field values.
*/
protected function sortItems(FieldItemListInterface $items) {
$cardinality = $this->fieldDefinition->getFieldCardinality();
$is_multiple = ($cardinality == FIELD_CARDINALITY_UNLIMITED) || ($cardinality > 1);
if ($is_multiple && isset($items[0]->_weight)) {
if ($this->fieldDefinition->isFieldMultiple() && isset($items[0]->_weight)) {
$itemValues = $items->getValue(TRUE);
usort($itemValues, function ($a, $b) {
$a_weight = (is_array($a) ? $a['_weight'] : 0);
......
......@@ -7,6 +7,7 @@
namespace Drupal\edit\Tests;
use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Language\Language;
use Drupal\simpletest\WebTestBase;
......@@ -83,7 +84,7 @@ function setUp() {
'entity_type' => 'node',
'type' => 'taxonomy_term_reference',
// Set cardinality to unlimited for tagging.
'cardinality' => FIELD_CARDINALITY_UNLIMITED,
'cardinality' => FieldDefinitionInterface::CARDINALITY_UNLIMITED,
'settings' => array(
'allowed_values' => array(
array(
......
......@@ -7,6 +7,7 @@
namespace Drupal\entity_reference\Tests;
use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Language\Language;
use Drupal\simpletest\WebTestBase;
......@@ -44,7 +45,7 @@ function setUp() {
'target_type' => 'node',
),
'type' => 'entity_reference',
'cardinality' => FIELD_CARDINALITY_UNLIMITED,
'cardinality' => FieldDefinitionInterface::CARDINALITY_UNLIMITED,
))->save();
entity_create('field_instance', array(
......
......@@ -497,6 +497,8 @@ function field_read_instances($conditions = array(), $include_additional = array
* // Only for 'single' widgets:
* '#theme' => 'field_multiple_value_form',
* '#cardinality' => The field cardinality,
* '#cardinality_multiple => TRUE if the field can contain multiple items,
* FALSE otherwise.
* // One sub-array per copy of the widget, keyed by delta.
* 0 => array(
* '#entity_type' => The name of the entity type,
......
......@@ -6,6 +6,7 @@
*/
use Drupal\Component\Utility\NestedArray;
use Drupal\Core\Field\FieldDefinitionInterface;
/**
* Returns HTML for an individual form element.
......@@ -24,7 +25,7 @@ function theme_field_multiple_value_form($variables) {
$element = $variables['element'];
$output = '';
if ($element['#cardinality'] > 1 || $element['#cardinality'] == FIELD_CARDINALITY_UNLIMITED) {
if ($element['#cardinality_multiple']) {
$form_required_marker = array('#theme' => 'form_required_marker');
$required = !empty($element['#required']) ? drupal_render($form_required_marker) : '';
$table_id = drupal_html_id($element['#field_name'] . '_values');
......@@ -173,7 +174,7 @@ function field_add_more_js($form, $form_state) {
$element = NestedArray::getValue($form, array_slice($button['#array_parents'], 0, -1));
// Ensure the widget allows adding additional items.
if ($element['#cardinality'] != FIELD_CARDINALITY_UNLIMITED) {
if ($element['#cardinality'] != FieldDefinitionInterface::CARDINALITY_UNLIMITED) {
return;
}
......
......@@ -75,11 +75,6 @@
* multilingual support for the Field API.
*/
/**
* Value for field API indicating a field accepts an unlimited number of values.
*/
const FIELD_CARDINALITY_UNLIMITED = -1;
/**
* Implements hook_help().
*/
......
......@@ -377,7 +377,7 @@ function field_views_field_default_views_data(FieldInterface $field) {
}
// Expose additional delta column for multiple value fields.
if ($field->getFieldCardinality() > 1 || $field->getFieldCardinality() == FIELD_CARDINALITY_UNLIMITED) {
if ($field->isFieldMultiple()) {
$title_delta = t('@label (!name:delta)', array('@label' => $label, '!name' => $field_name));
$title_short_delta = t('@label:delta', array('@label' => $label));
......
......@@ -120,7 +120,8 @@ class Field extends ConfigEntityBase implements FieldInterface {
* The field cardinality.
*
* The maximum number of values the field can hold. Possible values are
* positive integers or FIELD_CARDINALITY_UNLIMITED. Defaults to 1.
* positive integers or FieldDefinitionInterface::CARDINALITY_UNLIMITED.
* Defaults to 1.
*
* @var integer
*/
......@@ -597,6 +598,14 @@ public function isFieldRequired() {
return FALSE;
}
/**
* {@inheritdoc}
*/
public function isFieldMultiple() {
$cardinality = $this->getFieldCardinality();
return ($cardinality == static::CARDINALITY_UNLIMITED) || ($cardinality > 1);
}
/**
* {@inheritdoc}
*/
......
......@@ -584,6 +584,13 @@ public function isFieldRequired() {
return $this->required;
}
/**
* {@inheritdoc}
*/
public function isFieldMultiple() {
return $this->field->isFieldMultiple();
}
/**
* {@inheritdoc}
*/
......
......@@ -11,6 +11,7 @@
use Drupal\Core\Entity\EntityManager;
use Drupal\Core\Entity\EntityStorageControllerInterface;
use Drupal\Core\Entity\FieldableDatabaseStorageController;
use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Field\FormatterPluginManager;
use Drupal\Core\Language\Language;
use Drupal\Core\Language\LanguageManager;
......@@ -141,7 +142,7 @@ public function init(ViewExecutable $view, DisplayPluginBase $display, array &$o
$this->limit_values = FALSE;
$cardinality = $field->getFieldCardinality();
if ($cardinality > 1 || $cardinality == FIELD_CARDINALITY_UNLIMITED) {
if ($field->isFieldMultiple()) {
$this->multiple = TRUE;
// If "Display all values in the same row" is FALSE, then we always limit
......@@ -500,7 +501,7 @@ function multiple_options_form(&$form, &$form_state) {
// translating prefix and suffix separately.
list($prefix, $suffix) = explode('@count', t('Display @count value(s)'));
if ($field->getFieldCardinality() == FIELD_CARDINALITY_UNLIMITED) {
if ($field->getFieldCardinality() == FieldDefinitionInterface::CARDINALITY_UNLIMITED) {
$type = 'textfield';
$options = NULL;
$size = 5;
......
......@@ -7,6 +7,8 @@
namespace Drupal\field\Tests;
use Drupal\Core\Field\FieldDefinitionInterface;
class FormTest extends FieldTestBase {
/**
......@@ -73,7 +75,7 @@ function setUp() {
'name' => 'field_unlimited',
'entity_type' => 'entity_test',
'type' => 'test_field',
'cardinality' => FIELD_CARDINALITY_UNLIMITED,
'cardinality' => FieldDefinitionInterface::CARDINALITY_UNLIMITED,
);
$this->instance = array(
......
......@@ -7,6 +7,8 @@
namespace Drupal\field\Tests;
use Drupal\Core\Field\FieldDefinitionInterface;
class NestedFormTest extends FieldTestBase {
/**
......@@ -39,7 +41,7 @@ public function setUp() {
'name' => 'field_unlimited',
'entity_type' => 'entity_test',
'type' => 'test_field',
'cardinality' => FIELD_CARDINALITY_UNLIMITED,
'cardinality' => FieldDefinitionInterface::CARDINALITY_UNLIMITED,
);
$this->instance = array(
......
......@@ -7,6 +7,7 @@
namespace Drupal\field\Tests\Views;
use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Language\Language;
use Drupal\views\ViewExecutable;
......@@ -51,7 +52,7 @@ protected function setUp() {
'name' => 'field_name_3',
'entity_type' => 'node',
'type' => 'text',
'cardinality' => FIELD_CARDINALITY_UNLIMITED,
'cardinality' => FieldDefinitionInterface::CARDINALITY_UNLIMITED,
));
$field->save();
// Setup a field that will have no value.
......@@ -59,7 +60,7 @@ protected function setUp() {
'name' => 'field_name_4',
'entity_type' => 'node',
'type' => 'text',
'cardinality' => FIELD_CARDINALITY_UNLIMITED,
'cardinality' => FieldDefinitionInterface::CARDINALITY_UNLIMITED,
));
$field->save();
......
......@@ -123,13 +123,13 @@ public function buildForm(array $form, array &$form_state, FieldInstanceInterfac
'#title_display' => 'invisible',
'#options' => array(
'number' => $this->t('Limited'),
FIELD_CARDINALITY_UNLIMITED => $this->t('Unlimited'),
FieldInstanceInterface::CARDINALITY_UNLIMITED => $this->t('Unlimited'),
),
'#default_value' => ($cardinality == FIELD_CARDINALITY_UNLIMITED) ? FIELD_CARDINALITY_UNLIMITED : 'number',
'#default_value' => ($cardinality == FieldInstanceInterface::CARDINALITY_UNLIMITED) ? FieldInstanceInterface::CARDINALITY_UNLIMITED : 'number',
);
$form['field']['cardinality_container']['cardinality_number'] = array(
'#type' => 'number',
'#default_value' => $cardinality != FIELD_CARDINALITY_UNLIMITED ? $cardinality : 1,
'#default_value' => $cardinality != FieldInstanceInterface::CARDINALITY_UNLIMITED ? $cardinality : 1,
'#min' => 1,
'#title' => $this->t('Limit'),
'#title_display' => 'invisible',
......
......@@ -7,6 +7,7 @@
namespace Drupal\field_ui\Tests;
use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Language\Language;
use Drupal\Component\Utility\String;
......@@ -201,12 +202,12 @@ function cardinalitySettings() {
// Set to unlimited.
$edit = array(
'field[cardinality]' => FIELD_CARDINALITY_UNLIMITED,
'field[cardinality]' => FieldDefinitionInterface::CARDINALITY_UNLIMITED,
);
$this->drupalPostForm($field_edit_path, $edit, t('Save field settings'));
$this->assertText('Updated field Body field settings.');
$this->drupalGet($field_edit_path);
$this->assertFieldByXPath("//select[@name='field[cardinality]']", FIELD_CARDINALITY_UNLIMITED);
$this->assertFieldByXPath("//select[@name='field[cardinality]']", FieldDefinitionInterface::CARDINALITY_UNLIMITED);
$this->assertFieldByXPath("//input[@name='field[cardinality_number]']", 1);
}
......
......@@ -7,6 +7,7 @@
namespace Drupal\file\Plugin\Field\FieldWidget;
use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Field\WidgetBase;
use Drupal\Core\Field\FieldItemListInterface;
......@@ -74,7 +75,7 @@ protected function formMultipleElements(FieldItemListInterface $items, array &$f
// Determine the number of widgets to display.
$cardinality = $this->fieldDefinition->getFieldCardinality();
switch ($cardinality) {
case FIELD_CARDINALITY_UNLIMITED:
case FieldDefinitionInterface::CARDINALITY_UNLIMITED:
$max = count($items);
$is_multiple = TRUE;
break;
......@@ -121,7 +122,7 @@ protected function formMultipleElements(FieldItemListInterface $items, array &$f
}
$empty_single_allowed = ($cardinality == 1 && $delta == 0);
$empty_multiple_allowed = ($cardinality == FIELD_CARDINALITY_UNLIMITED || $delta < $cardinality) && empty($form_state['programmed']);
$empty_multiple_allowed = ($cardinality == FieldDefinitionInterface::CARDINALITY_UNLIMITED || $delta < $cardinality) && empty($form_state['programmed']);
// Add one more empty row for new uploads except when this is a programmed
// multiple form as it is not necessary.
......
......@@ -7,6 +7,7 @@
namespace Drupal\file\Tests;
use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\field\Field;
/**
......@@ -52,7 +53,7 @@ function testRequired() {
// Try again with a multiple value field.
$field->delete();
$this->createFileField($field_name, 'node', $type_name, array('cardinality' => FIELD_CARDINALITY_UNLIMITED), array('required' => '1'));
$this->createFileField($field_name, 'node', $type_name, array('cardinality' => FieldDefinitionInterface::CARDINALITY_UNLIMITED), array('required' => '1'));
// Try to post a new node without uploading a file in the multivalue field.
$edit = array('title' => $this->randomName());
......
......@@ -7,6 +7,7 @@
namespace Drupal\file\Tests;
use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Field\FieldItemInterface;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\field\Tests\FieldUnitTestBase;
......@@ -48,7 +49,7 @@ public function setUp() {
'name' => 'file_test',
'entity_type' => 'entity_test',
'type' => 'file',
'cardinality' => FIELD_CARDINALITY_UNLIMITED,
'cardinality' => FieldDefinitionInterface::CARDINALITY_UNLIMITED,
))->save();
entity_create('field_instance', array(
'entity_type' => 'entity_test',
......
......@@ -7,6 +7,7 @@
namespace Drupal\image\Tests;
use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Field\FieldItemInterface;
use Drupal\field\Tests\FieldUnitTestBase;
......@@ -52,7 +53,7 @@ public function setUp() {
'name' => 'image_test',
'entity_type' => 'entity_test',
'type' => 'image',
'cardinality' => FIELD_CARDINALITY_UNLIMITED,
'cardinality' => FieldDefinitionInterface::CARDINALITY_UNLIMITED,
))->save();
entity_create('field_instance', array(
'entity_type' => 'entity_test',
......
......@@ -58,8 +58,7 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen
// Prepare some properties for the child methods to build the actual form
// element.
$this->required = $element['#required'];
$cardinality = $this->fieldDefinition->getFieldCardinality();
$this->multiple = ($cardinality == FIELD_CARDINALITY_UNLIMITED) || ($cardinality > 1);
$this->multiple = $this->fieldDefinition->isFieldMultiple();
$this->has_value = isset($items[0]->{$this->column});
// Add our custom validator.
......
......@@ -7,6 +7,7 @@
namespace Drupal\rdf\Tests\Field;
use Drupal\rdf\Tests\Field\FieldRdfaTestBase;
use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Language\Language;
/**
......@@ -62,7 +63,7 @@ public function setUp() {
'name' => $this->fieldName,
'entity_type' => 'entity_test',
'type' => 'taxonomy_term_reference',
'cardinality' => FIELD_CARDINALITY_UNLIMITED,
'cardinality' => FieldDefinitionInterface::CARDINALITY_UNLIMITED,
'settings' => array(
'allowed_values' => array(
array(
......
......@@ -7,6 +7,7 @@
namespace Drupal\rdf\Tests;
use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\taxonomy\Tests\TaxonomyTestBase;
/**
......@@ -158,7 +159,7 @@ protected function createTaxonomyTermReferenceField($field_name, $vocabulary) {
'name' => $field_name,
'entity_type' => 'node',
'type' => 'taxonomy_term_reference',
'cardinality' => FIELD_CARDINALITY_UNLIMITED,
'cardinality' => FieldDefinitionInterface::CARDINALITY_UNLIMITED,
'settings' => array(
'allowed_values' => array(
array(
......
......@@ -7,6 +7,8 @@
namespace Drupal\system\Tests\Ajax;
use Drupal\Core\Field\FieldDefinitionInterface;
/**
* Tests Ajax-enabled forms functionality with multiple instances of the form.
*/
......@@ -38,7 +40,7 @@ function setUp() {
'name' => $field_name,
'entity_type' => 'node',
'type' => 'text',
'cardinality' => FIELD_CARDINALITY_UNLIMITED,
'cardinality' => FieldDefinitionInterface::CARDINALITY_UNLIMITED,
))->save();
entity_create('field_instance', array(
'field_name' => $field_name,
......
......@@ -7,6 +7,7 @@
namespace Drupal\system\Tests\Form;
use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\simpletest\WebTestBase;
/**
......@@ -75,7 +76,7 @@ function testPreserveFormActionAfterAJAX() {
'name' => $field_name,
'entity_type' => 'node',
'type' => 'text',
'cardinality' => FIELD_CARDINALITY_UNLIMITED,
'cardinality' => FieldDefinitionInterface::CARDINALITY_UNLIMITED,
);
entity_create('field_entity', $field)->save();
$instance = array(
......
......@@ -7,6 +7,8 @@
namespace Drupal\taxonomy\Tests;
use Drupal\Core\Field\FieldDefinitionInterface;
/**
* Tests the rendering of term reference fields in RSS feeds.
*/
......@@ -39,7 +41,7 @@ function setUp() {
'name' => $this->field_name,
'entity_type' => 'node',
'type' => 'taxonomy_term_reference',
'cardinality' => FIELD_CARDINALITY_UNLIMITED,
'cardinality' => FieldDefinitionInterface::CARDINALITY_UNLIMITED,
'settings' => array(
'allowed_values' => array(
array(
......
......@@ -7,9 +7,10 @@
namespace Drupal\taxonomy\Tests;
use Drupal\Core\Language\Language;
use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Field\FieldItemInterface;
use Drupal\Core\Language\Language;
use Drupal\field\Tests\FieldUnitTestBase;
/**
......@@ -48,7 +49,7 @@ public function setUp() {
'name' => 'field_test_taxonomy',
'entity_type' => 'entity_test',
'type' => 'taxonomy_term_reference',
'cardinality' => FIELD_CARDINALITY_UNLIMITED,
'cardinality' => FieldDefinitionInterface::CARDINALITY_UNLIMITED,
'settings' => array(
'allowed_values' => array(
array(
......
......@@ -7,6 +7,8 @@
namespace Drupal\taxonomy\Tests;
use Drupal\Core\Field\FieldDefinitionInterface;
/**
* Tests a taxonomy term reference field that allows multiple vocabularies.
*/
......@@ -44,7 +46,7 @@ function setUp() {
'name' => $this->field_name,
'entity_type' => 'entity_test',
'type' => 'taxonomy_term_reference',
'cardinality' => FIELD_CARDINALITY_UNLIMITED,
'cardinality' => FieldDefinitionInterface::CARDINALITY_UNLIMITED,
'settings' => array(
'allowed_values' => array(
array(
......
......@@ -7,6 +7,8 @@
namespace Drupal\taxonomy\Tests;
use Drupal\Core\Field\FieldDefinitionInterface;
/**
* Tests the hook implementations that maintain the taxonomy index.
*/
......@@ -35,7 +37,7 @@ function setUp() {
'name' => $this->field_name_1,
'entity_type' => 'node',
'type' => 'taxonomy_term_reference',
'cardinality' => FIELD_CARDINALITY_UNLIMITED,
'cardinality' => FieldDefinitionInterface::CARDINALITY_UNLIMITED,
'settings' => array(
'allowed_values' => array(
array(
......@@ -66,7 +68,7 @@ function setUp() {
'name' => $this->field_name_2,
'entity_type' => 'node',
'type' => 'taxonomy_term_reference',
'cardinality' => FIELD_CARDINALITY_UNLIMITED,
'cardinality' => FieldDefinitionInterface::CARDINALITY_UNLIMITED,
'settings' => array(
'allowed_values' => array(
array(
......
......@@ -7,6 +7,8 @@
namespace Drupal\taxonomy\Tests;
use Drupal\Core\Field\FieldDefinitionInterface;
/**
* Tests for taxonomy term functions.
*/
......@@ -31,7 +33,7 @@ function setUp() {
'name' => $field_name,
'entity_type' => 'node',
'type' => 'taxonomy_term_reference',
'cardinality' => FIELD_CARDINALITY_UNLIMITED,
'cardinality' => FieldDefinitionInterface::CARDINALITY_UNLIMITED,
'settings' => array(
'allowed_values' => array(
array(
......
......@@ -7,6 +7,7 @@
namespace Drupal\taxonomy\Tests;
use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Language\Language;
/**
......@@ -32,7 +33,7 @@ function setUp() {
'name' => $this->field_name,
'entity_type' => 'node',
'type' => 'taxonomy_term_reference',
'cardinality' => FIELD_CARDINALITY_UNLIMITED,
'cardinality' => FieldDefinitionInterface::CARDINALITY_UNLIMITED,
'settings' => array(
'allowed_values' => array(
array(
......
......@@ -7,6 +7,7 @@
namespace Drupal\taxonomy\Tests\Views;
use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Language\Language;
use Drupal\views\Tests\ViewTestBase;
use Drupal\views\Tests\ViewTestData;
......@@ -82,7 +83,7 @@ protected function mockStandardInstall() {
'entity_type' => 'node',
'type' => 'taxonomy_term_reference',
// Set cardinality to unlimited for tagging.
'cardinality' => FIELD_CARDINALITY_UNLIMITED,
'cardinality' => FieldDefinitionInterface::CARDINALITY_UNLIMITED,
'settings' => array(
'allowed_values' => array(
array(
......
......@@ -7,6 +7,7 @@
namespace Drupal\user\Tests;
use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Language\Language;
use Drupal\simpletest\WebTestBase;
......@@ -251,7 +252,7 @@ function testRegistrationWithUserFields() {
$this->assertEqual($new_user->test_user_field->value, $value, 'The field value was correclty saved.');
// Check that the 'add more' button works.
$field->cardinality = FIELD_CARDINALITY_UNLIMITED;
$field->cardinality = FieldDefinitionInterface::CARDINALITY_UNLIMITED;
$field->save();
foreach (array('js', 'nojs') as $js) {
$this->drupalGet('user/register');
......
......@@ -7,6 +7,8 @@
namespace Drupal\views\Tests\Wizard;
use Drupal\Core\Field\FieldDefinitionInterface;
/**
* Tests the ability of the views wizard to create views filtered by taxonomy.
*/
......@@ -57,7 +59,7 @@ function setUp() {
'name' => 'field_views_testing_tags',
'entity_type' => 'node',
'type' => 'taxonomy_term_reference',