You are here

public function UpdateHelper::checkBodyFieldStorage in Menu Item Extras 8.2

Creates or load field storage.

Parameters

string $field_name: Field name.

string $entity_type: Entity type id.

string $type: Field type id.

Return value

\Drupal\Core\Entity\EntityInterface|static Entity of field storage

File

src/Service/UpdateHelper.php, line 31

Class

UpdateHelper
Class MenuLinkContentUpdateHelper.

Namespace

Drupal\menu_item_extras\Service

Code

public function checkBodyFieldStorage($field_name, $entity_type, $type) {

  // Add or remove the body field, as needed.
  $field_storage = FieldStorageConfig::loadByName($entity_type, $field_name);
  if (empty($field_storage)) {
    $field_storage = FieldStorageConfig::create([
      'field_name' => $field_name,
      'entity_type' => $entity_type,
      'type' => $type,
    ]);
    $field_storage
      ->save();
  }
  return $field_storage;
}