diff --git a/core/lib/Drupal/Core/Entity/EntityManager.php b/core/lib/Drupal/Core/Entity/EntityManager.php index 47fc211..64a5ffd 100644 --- a/core/lib/Drupal/Core/Entity/EntityManager.php +++ b/core/lib/Drupal/Core/Entity/EntityManager.php @@ -447,10 +447,9 @@ public function getAdminRouteInfo($entity_type, $bundle) { * (optional) The entity bundle for which to get field definitions. If NULL * is passed, no bundle-specific fields are included. Defaults to NULL. * - * @return array + * @return \Drupal\Core\Entity\Field\FieldDefinitionInterface[] * An array of entity field definitions, keyed by field name. * - * @see \Drupal\Core\Entity\Field\FieldDefinitionInterface * @see \Drupal\Core\TypedData\TypedDataManager::create() * @see \Drupal\Core\Entity\EntityManager::getFieldDefinitionsByConstraints() */ @@ -503,7 +502,7 @@ public function getFieldDefinitions($entity_type, $bundle = NULL) { if ($definition instanceof FieldDefinition) { $definition->setFieldName($field_name); } - // Ensure ids and langcode fields are never made translatable. + // Ensure ID and langcode fields are never made translatable. if (isset($untranslatable_fields[$field_name]) && $definition->isFieldTranslatable()) { throw new \LogicException(format_string('The @field field cannot be translatable.', array('@field' => $definition->getFieldLabel()))); } diff --git a/core/lib/Drupal/Core/Entity/Field/FieldDefinition.php b/core/lib/Drupal/Core/Entity/Field/FieldDefinition.php index b2cf431..0c40c42 100644 --- a/core/lib/Drupal/Core/Entity/Field/FieldDefinition.php +++ b/core/lib/Drupal/Core/Entity/Field/FieldDefinition.php @@ -20,6 +20,7 @@ class FieldDefinition extends ListDefinition implements FieldDefinitionInterface * Creates a new entity field definition. * * @return \Drupal\Core\Entity\Field\FieldDefinition + * A new FieldDefinition object. */ public static function create() { $class = get_called_class(); @@ -52,18 +53,10 @@ public function setFieldName($name) { * {@inheritdoc} */ public function getFieldType() { - // We have to support 'field_item:FIELD_TYPE' data types as well as - // 'FIELD_TYPE_field' for field types that are not yet implemented as field - // type plugin. $data_type = $this->getItemDefinition()->getDataType(); - if (strpos($data_type, ':') !== FALSE) { - // Cut of the leading field_item: prefix from 'field_item:FIELD_TYPE'. - $parts = explode(':', $data_type); - return $parts[1]; - } - else { - return str_replace('_field', '', $data_type); - } + // Cut of the leading field_item: prefix from 'field_item:FIELD_TYPE'. + $parts = explode(':', $data_type); + return $parts[1]; } /** @@ -76,14 +69,7 @@ public function getFieldType() { * The object itself for chaining. */ public function setFieldType($type) { - // Determine the right data type to use. - if (\Drupal::typedData()->getDefinition('field_item:' . $type)) { - $this->getItemDefinition()->setDataType('field_item:' . $type); - } - else { - // Data type has not been converted to a field type plugin yet. - $this->getItemDefinition()->setDataType($type . '_field'); - } + $this->getItemDefinition()->setDataType('field_item:' . $type); return $this; } @@ -207,7 +193,7 @@ public function isFieldRequired() { /** * Sets whether the field is required. * - * @param boolean $required + * @param bool $required * Whether the field is required. * * @return \Drupal\Core\Entity\Field\FieldDefinition @@ -227,14 +213,15 @@ public function isFieldQueryable() { /** * Sets whether the field is queryable. * - * @param boolean $queryable + * @param bool $queryable * Whether the field is queryable. * * @return \Drupal\Core\Entity\Field\FieldDefinition * The object itself for chaining. */ public function setFieldQueryable($queryable) { - return $this->setRequired($queryable); + $this->definition['queryable'] = $queryable; + return $this; } /** @@ -272,7 +259,7 @@ public function getFieldDefaultValue(EntityInterface $entity) { /** * Allows creating field definition objects from old style definition arrays. * - * @todo: Remove once no old-style definition arrays need to be supported. + * @todo: Remove once https://drupal.org/node/2112239 is in. */ public static function createFromOldStyleDefinition(array $definition) { unset($definition['list']); diff --git a/core/lib/Drupal/Core/Entity/Field/FieldDefinitionInterface.php b/core/lib/Drupal/Core/Entity/Field/FieldDefinitionInterface.php index c339576..e7ed42b 100644 --- a/core/lib/Drupal/Core/Entity/Field/FieldDefinitionInterface.php +++ b/core/lib/Drupal/Core/Entity/Field/FieldDefinitionInterface.php @@ -126,6 +126,7 @@ public function isFieldTranslatable(); * Determines whether the field is configurable via field.module. * * @return bool + * TRUE if the field is configurable. */ public function isFieldConfigurable(); @@ -133,6 +134,7 @@ public function isFieldConfigurable(); * Determines whether the field is queryable via QueryInterface. * * @return bool + * TRUE if the field is queryable.. */ public function isFieldQueryable(); diff --git a/core/lib/Drupal/Core/Entity/Plugin/DataType/FieldItemList.php b/core/lib/Drupal/Core/Entity/Plugin/DataType/FieldItemList.php index 5e6d7dc..128c5ae 100644 --- a/core/lib/Drupal/Core/Entity/Plugin/DataType/FieldItemList.php +++ b/core/lib/Drupal/Core/Entity/Plugin/DataType/FieldItemList.php @@ -24,7 +24,6 @@ * @DataType( * id = "field_item_list", * label = @Translation("Entity field"), - * class = "\Drupal\Core\Entity\Field\Field" * ) */ class FieldItemList extends ItemList implements FieldItemListInterface { diff --git a/core/lib/Drupal/Core/TypedData/DataDefinition.php b/core/lib/Drupal/Core/TypedData/DataDefinition.php index fb3b0a5..7bf7ea8 100644 --- a/core/lib/Drupal/Core/TypedData/DataDefinition.php +++ b/core/lib/Drupal/Core/TypedData/DataDefinition.php @@ -23,6 +23,7 @@ class DataDefinition implements DataDefinitionInterface, \ArrayAccess { * Creates a new data definition. * * @return \Drupal\Core\TypedData\DataDefinition + * A new DataDefinition object. */ public static function create() { $class = get_called_class(); @@ -123,7 +124,7 @@ public function isReadOnly() { /** * Sets whether the data is read-only. * - * @param boolean $read-only + * @param bool $read-only * Whether the data is read-only. * * @return \Drupal\Core\TypedData\DataDefinition @@ -144,7 +145,7 @@ public function isComputed() { /** * Sets whether the data is computed. * - * @param boolean $computed + * @param bool $computed * Whether the data is computed. * * @return \Drupal\Core\TypedData\DataDefinition @@ -165,7 +166,7 @@ public function isRequired() { /** * Sets whether the data is required. * - * @param boolean $required + * @param bool $required * Whether the data is required. * * @return \Drupal\Core\TypedData\DataDefinition diff --git a/core/lib/Drupal/Core/TypedData/DataDefinitionInterface.php b/core/lib/Drupal/Core/TypedData/DataDefinitionInterface.php index d891a56..eb5dd67 100644 --- a/core/lib/Drupal/Core/TypedData/DataDefinitionInterface.php +++ b/core/lib/Drupal/Core/TypedData/DataDefinitionInterface.php @@ -48,7 +48,7 @@ public function getDescription(); * This is equivalent to checking whether the data definition implements the * \Drupal\Core\TypedData\ListDefinitionInterface interface. * - * @return boolean + * @return bool * Whether the data is multi-valued. */ public function isList(); @@ -56,7 +56,7 @@ public function isList(); /** * Determines whether the data is read-only. * - * @return boolean + * @return bool * Whether the data is read-only. */ public function isReadOnly(); @@ -66,7 +66,7 @@ public function isReadOnly(); * * For example, data could be computed depending on some other values. * - * @return boolean + * @return bool * Whether the data value is computed. */ public function isComputed(); @@ -76,7 +76,7 @@ public function isComputed(); * * For required data a non-NULL value is mandatory. * - * @return boolean + * @return bool * Whether a data value is required. */ public function isRequired(); diff --git a/core/lib/Drupal/Core/TypedData/TypedDataManager.php b/core/lib/Drupal/Core/TypedData/TypedDataManager.php index 0850e37..a8b8561 100644 --- a/core/lib/Drupal/Core/TypedData/TypedDataManager.php +++ b/core/lib/Drupal/Core/TypedData/TypedDataManager.php @@ -94,6 +94,7 @@ public function createInstance($data_type, array $configuration) { * @param \Drupal\Core\TypedData\DataDefinitionInterface $definition * The data definition of the typed data object. For backwards-compatibility * an array representation of the data definition may be passed also. + * @todo: Need to remove array support in https://drupal.org/node/2112239. * @param mixed $value * (optional) The data value. If set, it has to match one of the supported * data type format as documented for the data type classes. diff --git a/core/modules/content_translation/content_translation.module b/core/modules/content_translation/content_translation.module index 2d19740..e62911d 100644 --- a/core/modules/content_translation/content_translation.module +++ b/core/modules/content_translation/content_translation.module @@ -147,7 +147,7 @@ function content_translation_entity_field_info_alter(&$info, $entity_type) { if (isset($info[$key][$name])) { $translatable = (bool) $translatable; // @todo: Remove array check after all base fields have been - // converted to object. + // converted to object in https://drupal.org/node/2112239 if (is_array($info[$key][$name])) { $info[$key][$name]['translatable'] = $translatable; } diff --git a/core/tests/Drupal/Tests/Core/Entity/FieldDefinitionTest.php b/core/tests/Drupal/Tests/Core/Entity/FieldDefinitionTest.php index 73a2ed9..23f5a64 100644 --- a/core/tests/Drupal/Tests/Core/Entity/FieldDefinitionTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/FieldDefinitionTest.php @@ -26,34 +26,6 @@ public static function getInfo() { } /** - * {@inheritdoc} - */ - protected function setUp() { - parent::setUp(); - - // Prepare a container with a mock typed data object, that returns no - // type definitions. - // @todo: Remove this once all field types are converted and getFieldType() - // does not need the manager any more. - $typed_data = $this->getMockBuilder('Drupal\Core\TypedData\TypedDataManager') - ->disableOriginalConstructor() - ->getMock(); - - $typed_data - ->expects($this->any()) - ->method('getDefinition') - ->will($this->returnValue(NULL)); - - $container = $this->getMock('Drupal\Core\DependencyInjection\Container'); - $container - ->expects($this->any()) - ->method('get') - ->will($this->returnValue($typed_data)); - - \Drupal::setContainer($container); - } - - /** * Tests field name methods. */ public function testFieldName() {