function FieldConfig::loadByName

Same name and namespace in other branches
  1. 8.9.x core/modules/field/src/Entity/FieldConfig.php \Drupal\field\Entity\FieldConfig::loadByName()
  2. 10 core/modules/field/src/Entity/FieldConfig.php \Drupal\field\Entity\FieldConfig::loadByName()
  3. 11.x core/modules/field/src/Entity/FieldConfig.php \Drupal\field\Entity\FieldConfig::loadByName()

Loads a field config entity based on the entity type and field name.

Parameters

string $entity_type_id: ID of the entity type.

string $bundle: Bundle name.

string $field_name: Name of the field.

Return value

Drupal\field\FieldConfigInterface|null The field config entity if one exists for the provided field name, otherwise NULL.

64 calls to FieldConfig::loadByName()
block_content_add_body_field in core/modules/block_content/block_content.module
Adds the default body field to a custom block type.
BulkDeleteTest::testDeleteField in core/modules/field/tests/src/Kernel/BulkDeleteTest.php
Tests deleting fields.
BulkDeleteTest::testPurgeField in core/modules/field/tests/src/Kernel/BulkDeleteTest.php
Tests purging fields.
BulkDeleteTest::testPurgeFieldStorage in core/modules/field/tests/src/Kernel/BulkDeleteTest.php
Tests purging field storages.
BulkDeleteTest::testPurgeWithDeletedAndActiveField in core/modules/field/tests/src/Kernel/BulkDeleteTest.php
Tests that recreating a field with the name as a deleted field works.

... See full list

File

core/modules/field/src/Entity/FieldConfig.php, line 376

Class

FieldConfig
Defines the Field entity.

Namespace

Drupal\field\Entity

Code

public static function loadByName($entity_type_id, $bundle, $field_name) {
    return \Drupal::entityTypeManager()->getStorage('field_config')
        ->load($entity_type_id . '.' . $bundle . '.' . $field_name);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.