diff --git a/core/lib/Drupal/Core/Entity/Query/Sql/Tables.php b/core/lib/Drupal/Core/Entity/Query/Sql/Tables.php index 80ad70a..cb4a5ef 100644 --- a/core/lib/Drupal/Core/Entity/Query/Sql/Tables.php +++ b/core/lib/Drupal/Core/Entity/Query/Sql/Tables.php @@ -13,7 +13,6 @@ use Drupal\Core\Entity\Plugin\DataType\EntityReference; use Drupal\Core\Entity\Query\QueryException; use Drupal\field\Entity\Field; -use Drupal\field\Field as FieldInfo; /** * Adds tables and fields to the SQL entity query. @@ -58,7 +57,7 @@ public function __construct(SelectInterface $sql_query) { public function addField($field, $type, $langcode) { $entity_type = $this->sqlQuery->getMetaData('entity_type'); $entity_manager = \Drupal::entityManager(); - $field_info = FieldInfo::fieldInfo(); + $field_info = \Drupal::service('field.info'); $age = $this->sqlQuery->getMetaData('age'); // This variable ensures grouping works correctly. For example: // ->condition('tags', 2, '>') diff --git a/core/modules/content_translation/lib/Drupal/content_translation/Form/TranslatableForm.php b/core/modules/content_translation/lib/Drupal/content_translation/Form/TranslatableForm.php index 6ab01af..10b7782 100644 --- a/core/modules/content_translation/lib/Drupal/content_translation/Form/TranslatableForm.php +++ b/core/modules/content_translation/lib/Drupal/content_translation/Form/TranslatableForm.php @@ -9,7 +9,6 @@ use Drupal\Core\Form\ConfirmFormBase; use Drupal\field\Entity\Field; -use Drupal\field\Field as FieldInfo; /** * Provides a confirm form for changing translatable status on translation @@ -81,7 +80,7 @@ public function getCancelRoute() { */ public function buildForm(array $form, array &$form_state, $entity_type = NULL, $field_name = NULL) { $this->fieldName = $field_name; - $this->fieldInfo = FieldInfo::fieldInfo()->getField($entity_type, $field_name); + $this->fieldInfo = \Drupal::service('field.info')->getField($entity_type, $field_name); return parent::buildForm($form, $form_state); } diff --git a/core/modules/editor/editor.module b/core/modules/editor/editor.module index e843c2d..f751b42 100644 --- a/core/modules/editor/editor.module +++ b/core/modules/editor/editor.module @@ -9,7 +9,6 @@ use Drupal\editor\Entity\Editor; use Drupal\Component\Utility\NestedArray; use Drupal\Core\Entity\EntityInterface; -use Drupal\field\Field; /** * Implements hook_help(). @@ -541,7 +540,7 @@ function _editor_get_processed_text_fields(EntityInterface $entity) { // Only return fields that have text processing enabled. return array_filter($configurable_fields, function ($field) use ($entity) { - $settings = Field::fieldInfo() + $settings = \Drupal::service('field.info') ->getInstance($entity->entityType(), $entity->bundle(), $field) ->getFieldSettings(); return isset($settings['text_processing']) && $settings['text_processing'] === '1'; diff --git a/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceFieldTest.php b/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceFieldTest.php index 4119240..cb0c96c 100644 --- a/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceFieldTest.php +++ b/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceFieldTest.php @@ -8,7 +8,6 @@ namespace Drupal\entity_reference\Tests; use Drupal\system\Tests\Entity\EntityUnitTestBase; -use Drupal\field\Field; /** * Tests for the entity reference field. @@ -89,8 +88,8 @@ public function setUp() { array('target_bundles' => array($this->bundle)) ); - $this->field = Field::fieldInfo()->getField($this->entityType, $this->fieldName); - $instances = Field::fieldInfo()->getBundleInstances($this->entityType, $this->bundle); + $this->field = $this->container->get('field.info')->getField($this->entityType, $this->fieldName); + $instances = $this->container->get('field.info')->getBundleInstances($this->entityType, $this->bundle); $this->instance = $instances[$this->fieldName]; } diff --git a/core/modules/field/field.deprecated.inc b/core/modules/field/field.deprecated.inc index fad6339..3b85038 100644 --- a/core/modules/field/field.deprecated.inc +++ b/core/modules/field/field.deprecated.inc @@ -7,11 +7,7 @@ use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityNG; -use Drupal\Core\Entity\Field\PrepareCacheInterface; -use Drupal\Core\Language\Language; use Drupal\entity\Entity\EntityDisplay; -use Drupal\field\Field; - /** * Returns information about field types. @@ -183,10 +179,10 @@ function field_info_formatter_settings($type) { * @endcode * * @deprecated as of Drupal 8.0. Use - * Field::fieldInfo()->getFieldMap(). + * \Drupal::service('field.info')->getFieldMap(). */ function field_info_field_map() { - return Field::fieldInfo()->getFieldMap(); + return \Drupal::service('field.info')->getFieldMap(); } /** @@ -209,10 +205,10 @@ function field_info_field_map() { * @see field_info_field_by_id() * @deprecated as of Drupal 8.0. Use - * Field::fieldInfo()->getField($field_name). + * \Drupal::service('field.info')->getField($field_name). */ function field_info_field($entity_type, $field_name) { - return Field::fieldInfo()->getField($entity_type, $field_name); + return \Drupal::service('field.info')->getField($entity_type, $field_name); } /** @@ -230,10 +226,10 @@ function field_info_field($entity_type, $field_name) { * @see field_info_field() * * @deprecated as of Drupal 8.0. Use - * Field::fieldInfo()->getFieldById($field_id). + * \Drupal::service('field.info')->getFieldById($field_id). */ function field_info_field_by_id($field_id) { - return Field::fieldInfo()->getFieldById($field_id); + return \Drupal::service('field.info')->getFieldById($field_id); } /** @@ -255,10 +251,10 @@ function field_info_field_by_id($field_id) { * @see field_info_field_by_id() * * @deprecated as of Drupal 8.0. Use - * Field::fieldInfo()->getFields(). + * \Drupal::service('field.info')->getFields(). */ function field_info_field_by_ids() { - return Field::fieldInfo()->getFields(); + return \Drupal::service('field.info')->getFields(); } /** @@ -287,12 +283,12 @@ function field_info_field_by_ids() { * return all instances for that bundle. * * @deprecated as of Drupal 8.0. Use - * Field::fieldInfo()->getInstances(), - * Field::fieldInfo()->getInstances($entity_type) or - * Field::fieldInfo()->getBundleInstances($entity_type, $bundle_name). + * \Drupal::service('field.info')->getInstances(), + * \Drupal::service('field.info')->getInstances($entity_type) or + * \Drupal::service('field.info')->getBundleInstances($entity_type, $bundle_name). */ function field_info_instances($entity_type = NULL, $bundle_name = NULL) { - $cache = Field::fieldInfo(); + $cache = \Drupal::service('field.info'); if (!isset($entity_type)) { return $cache->getInstances(); @@ -324,10 +320,10 @@ function field_info_instances($entity_type = NULL, $bundle_name = NULL) { * NULL if the instance does not exist. * * @deprecated as of Drupal 8.0. Use - * Field::fieldInfo()->getInstance($entity_type, $bundle_name, $field_name). + * \Drupal::service('field.info')->getInstance($entity_type, $bundle_name, $field_name). */ function field_info_instance($entity_type, $field_name, $bundle_name) { - return Field::fieldInfo()->getInstance($entity_type, $bundle_name, $field_name); + return \Drupal::service('field.info')->getInstance($entity_type, $bundle_name, $field_name); } /** diff --git a/core/modules/field/field.info.inc b/core/modules/field/field.info.inc index 79345a8..237794f 100644 --- a/core/modules/field/field.info.inc +++ b/core/modules/field/field.info.inc @@ -5,10 +5,6 @@ * Field Info API, providing information about available fields and field types. */ -use Drupal\Core\Cache\CacheBackendInterface; -use Drupal\Core\Language\Language; -use Drupal\field\Field; - /** * @defgroup field_info Field Info API * @{ @@ -41,7 +37,7 @@ function field_info_cache_clear() { \Drupal::typedData()->clearCachedDefinitions(); \Drupal::service('plugin.manager.entity.field.field_type')->clearCachedDefinitions(); - Field::fieldInfo()->flush(); + \Drupal::service('field.info')->flush(); } /** @@ -85,7 +81,7 @@ function field_behaviors_widget($op, $instance) { */ function field_info_fields() { // Filter out deleted fields. - return array_filter(Field::fieldInfo()->getFields(), function ($field) { + return array_filter(\Drupal::service('field.info')->getFields(), function ($field) { return !$field->deleted; }); } @@ -144,7 +140,7 @@ function field_info_fields() { * The array of pseudo-field elements in the bundle. */ function field_info_extra_fields($entity_type, $bundle, $context) { - $info = Field::fieldInfo()->getBundleExtraFields($entity_type, $bundle); + $info = \Drupal::service('field.info')->getBundleExtraFields($entity_type, $bundle); return isset($info[$context]) ? $info[$context] : array(); } diff --git a/core/modules/field/lib/Drupal/field/Field.php b/core/modules/field/lib/Drupal/field/Field.php deleted file mode 100644 index f70d6dc..0000000 --- a/core/modules/field/lib/Drupal/field/Field.php +++ /dev/null @@ -1,25 +0,0 @@ -instance)) { $entity = $this->getEntity(); - $instances = FieldAPI::fieldInfo()->getBundleInstances($entity->entityType(), $entity->bundle()); + $instances = \Drupal::service('field.info')->getBundleInstances($entity->entityType(), $entity->bundle()); $this->instance = $instances[$this->getName()]; } return $this->instance; diff --git a/core/modules/field/lib/Drupal/field/Tests/FieldImportCreateTest.php b/core/modules/field/lib/Drupal/field/Tests/FieldImportCreateTest.php index b6697e7..fabb641 100644 --- a/core/modules/field/lib/Drupal/field/Tests/FieldImportCreateTest.php +++ b/core/modules/field/lib/Drupal/field/Tests/FieldImportCreateTest.php @@ -7,8 +7,6 @@ namespace Drupal\field\Tests; -use Drupal\field\Field; - /** * Tests creating fields and instances as part of config import. */ @@ -61,7 +59,7 @@ function testImportCreateDefault() { $this->assertTrue($instance->bundle, 'test_bundle_2', 'The second field instance was created on bundle test_bundle_2.'); // Tests field info contains the right data. - $instances = Field::fieldInfo()->getInstances('entity_test'); + $instances = $this->container->get('field.info')->getInstances('entity_test'); $this->assertEqual(count($instances['entity_test']), 2); $this->assertTrue(isset($instances['entity_test']['field_test_import'])); $this->assertTrue(isset($instances['entity_test']['field_test_import_2'])); diff --git a/core/modules/forum/forum.module b/core/modules/forum/forum.module index 0fe30f6..db80d8e 100644 --- a/core/modules/forum/forum.module +++ b/core/modules/forum/forum.module @@ -6,7 +6,6 @@ */ use Drupal\Core\Entity\EntityInterface; -use Drupal\field\Field; use Drupal\node\NodeInterface; /** @@ -156,7 +155,7 @@ function forum_menu_local_tasks(&$data, $router_item, $root_path) { $vid = \Drupal::config('forum.settings')->get('vocabulary'); $links = array(); // Loop through all bundles for forum taxonomy vocabulary field. - $field = Field::fieldInfo()->getField('node', 'taxonomy_forums'); + $field = \Drupal::service('field.info')->getField('node', 'taxonomy_forums'); foreach ($field['bundles'] as $type) { if (node_access('create', $type)) { $links[$type] = array(