Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OEL-2820: FieldFormatters. #254

Open
wants to merge 5 commits into
base: 1.x
Choose a base branch
from
Open

Conversation

julien-
Copy link
Contributor

@julien- julien- commented Feb 12, 2024

The initial target was to render a FeaturedMedia field using Image style.
Now you can select the setting and it will output, as waited by our Patterns, in the format of array [src, alt]

image

Additional needs come, and now it can also provide a File in the FileValueObject format

classDiagram

    class FeaturedMediaFormatterBase:::add {
        EntityRepositoryInterface $entityRepository

        defaultSettings() array
        settingsForm(array $form, FormStateInterface $form_state)
       settingsSummary() array
    }
    

    class FeaturedMediaImageFormatter:::add {

      function viewElements(FieldItemListInterface $items, $langcode) array
    }
    FeaturedMediaFormatterBase --|> FeaturedMediaImageFormatter

    class FeaturedMediaImageValueObjectFormatter:::add {

      function viewElements(FieldItemListInterface $items, $langcode = NULL) array ['src','alt']
      function needsEntityLoad(EntityReferenceItem $item)

    }
    FeaturedMediaFormatterBase --|> FeaturedMediaImageValueObjectFormatter 

    class ImageFormatterBase:::existing_drupal {
    }
    class EntityReferenceImageValueObjectFormatter:::add {
      FileUrlGeneratorInterface $fileUrlGenerator
      EntityTypeManagerInterface $entityTypeManager
      LanguageManagerInterface $languageManager

      function defaultSettings() array
      function settingsForm(array $form, FormStateInterface $form_state) array
      function settingsSummary() array
      function view(FieldItemListInterface $items, $langcode = NULL) array
      function viewElements(FieldItemListInterface $items, $langcode = NULL) array ['src','alt']
    }
    ImageFormatterBase --|> EntityReferenceImageValueObjectFormatter

class FileFormatterBase:::existing_drupal {
    }
    class FileValueObjectFormatter:::add {
    
      function viewElements(FieldItemListInterface $items, $langcode) array
    }
    FileFormatterBase --|> FileValueObjectFormatter

    classDef add fill:lightgreen
    classDef existing_drupal fill:dodgerblue
Loading

@julien- julien- force-pushed the OEL-2820 branch 3 times, most recently from 4ff9aa8 to 6b47a98 Compare February 12, 2024 10:49
@julien- julien- changed the title OEL-2820: Fomatters. OEL-2820: FieldFomatters. Feb 13, 2024
@julien- julien- changed the title OEL-2820: FieldFomatters. OEL-2820: FieldFormatters. Feb 13, 2024
@julien- julien- force-pushed the OEL-2820 branch 3 times, most recently from e5512b0 to c51f887 Compare February 24, 2024 00:59
@julien- julien- force-pushed the OEL-2820 branch 2 times, most recently from e361da6 to 950475d Compare October 4, 2024 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant