You are here

public static function Utility::checkBundleHasExtraFieldsThanEntity in Menu Item Extras 8.2

Checks if bundle and entity fields are different.

Parameters

string $entity_type: Entity type for checking.

string $bundle: Bundle for checking.

Return value

bool Returns TRUE if bundle has other fields than entity.

4 calls to Utility::checkBundleHasExtraFieldsThanEntity()
MenuItemExtrasViewModeSelectorSelect::checkFromWidgetMenuHasExtraFields in src/Plugin/Field/FieldWidget/MenuItemExtrasViewModeSelectorSelect.php
Checks that menu has extra fields.
menu_item_extras_preprocess_block in ./menu_item_extras.module
Implements hook_preprocess_block().
menu_item_extras_preprocess_menu in ./menu_item_extras.module
Implements hook_preprocess_menu().
menu_item_extras_theme_suggestions_menu_alter in ./menu_item_extras.module
Implements hook_theme_suggestions_HOOK_alter().

File

src/Utility/Utility.php, line 23

Class

Utility
Utility functions specific to menu_item_extras.

Namespace

Drupal\menu_item_extras\Utility

Code

public static function checkBundleHasExtraFieldsThanEntity($entity_type, $bundle) {
  $entity_manager = \Drupal::service('entity_field.manager');
  $bundle_fields = array_keys($entity_manager
    ->getFieldDefinitions($entity_type, $bundle));
  $entity_type_fields = array_keys($entity_manager
    ->getBaseFieldDefinitions($entity_type));
  if ($bundle_fields !== $entity_type_fields) {
    return TRUE;
  }
  return FALSE;
}