You are here

public function MenuLinkContentService::cleanupFields in Menu Item Extras 8.2

Cleanups all field that added by entity bundle.

Parameters

\Drupal\Core\Entity\ContentEntityInterface $entity: Entity for manipulating.

Overrides MenuLinkContentServiceInterface::cleanupFields

File

src/Service/MenuLinkContentService.php, line 204

Class

MenuLinkContentService
Class MenuLinkContentHelper.

Namespace

Drupal\menu_item_extras\Service

Code

public function cleanupFields(ContentEntityInterface $entity) {
  foreach ($entity
    ->getFieldDefinitions() as $field_name => $field_def) {
    if (!$field_def instanceof BaseFieldDefinition) {
      $entity
        ->set($field_name, NULL);
    }
  }
}