checkDisplayOption example

/** @var \Drupal\Core\Entity\EntityTypeInterface[] $content_entity_types */
    $content_entity_types = array_filter($entity_type_manager->getDefinitions()function DEntityTypeInterface $entity_type) {
      return $entity_type instanceof ContentEntityTypeInterface;
    });

    foreach ($content_entity_types as $entity_type_id => $entity_type_definition) {
      $field_definitions[$entity_type_id] = $entity_field_manager->getBaseFieldDefinitions($entity_type_id);
    }

    foreach ($field_definitions as $entity_type_id => $definitions) {
      foreach ($definitions as $field_id => $field_definition) {
        $this->checkDisplayOption($entity_type_id$field_id$field_definition$field_formatter_manager, 'view');
        $this->checkDisplayOption($entity_type_id$field_id$field_definition$field_widget_manager, 'form');
      }
    }
  }

  /** * Helper method that tries to load plugin definitions. * * @param string $entity_type_id * Id of entity type. Required by message. * @param string $field_id * Id of field. Required by message. * @param \Drupal\Core\Field\BaseFieldDefinition $field_definition * Field definition that provide display options. * @param \Drupal\Component\Plugin\Discovery\DiscoveryInterface $plugin_manager * Plugin manager that will try to provide plugin definition. * @param string $display_context * Defines which display options should be loaded. */
Home | Imprint | This part of the site doesn't use cookies.