field_ui_entity_operation(EntityInterface $entity)
Implements hook_entity_operation().
File
- core/modules/field_ui/field_ui.module, line 140
- Allows administrators to attach custom fields to fieldable types.
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | function field_ui_entity_operation(EntityInterface $entity ) { $operations = array (); $info = $entity ->getEntityType(); // Add manage fields and display links if this entity type is the bundle // of another and that type has field UI enabled. if (( $bundle_of = $info ->getBundleOf()) && \Drupal::entityManager()->getDefinition( $bundle_of )->get( 'field_ui_base_route' )) { $account = \Drupal::currentUser(); if ( $account ->hasPermission( 'administer ' . $bundle_of . ' fields' )) { $operations [ 'manage-fields' ] = array ( 'title' => t( 'Manage fields' ), 'weight' => 15, 'url' => Url::fromRoute( "entity.{$bundle_of}.field_ui_fields" , array ( $entity ->getEntityTypeId() => $entity ->id(), )), ); } if ( $account ->hasPermission( 'administer ' . $bundle_of . ' form display' )) { $operations [ 'manage-form-display' ] = array ( 'title' => t( 'Manage form display' ), 'weight' => 20, 'url' => Url::fromRoute( "entity.entity_form_display.{$bundle_of}.default" , array ( $entity ->getEntityTypeId() => $entity ->id(), )), ); } if ( $account ->hasPermission( 'administer ' . $bundle_of . ' display' )) { $operations [ 'manage-display' ] = array ( 'title' => t( 'Manage display' ), 'weight' => 25, 'url' => Url::fromRoute( "entity.entity_view_display.{$bundle_of}.default" , array ( $entity ->getEntityTypeId() => $entity ->id(), )), ); } } return $operations ; } |
Please login to continue.