Skip to content
Snippets Groups Projects
Verified Commit 7f69b30b authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3420997 by sorlov, quietone, DanielVeza, smustgrave, alexpott,...

Issue #3420997 by sorlov, quietone, DanielVeza, smustgrave, alexpott, mstrelan: Convert MediaSource plugin discovery to attributes

(cherry picked from commit 7201d4bf)
parent 26a5b7e6
Branches
Tags
25 merge requests!11958Issue #3490507 by alexpott, smustgrave: Fix bogus mocking in...,!11769Issue #3517987: Add option to contextual filters to encode slashes in query parameter.,!11185Issue #3477324 by andypost, alexpott: Fix usage of str_getcsv() and fgetcsv() for PHP 8.4,!10602Issue #3438769 by vinmayiswamy, antonnavi, michelle, amateescu: Sub workspace does not clear,!10301Issue #3469309 by mstrelan, smustgrave, moshe weitzman: Use one-time login...,!10187Issue #3487488 by dakwamine: ExtensionMimeTypeGuesser::guessMimeType must support file names with "0" (zero) like foo.0.zip,!9944Issue #3483353: Consider making the createCopy config action optionally fail...,!9929Issue #3445469 by pooja_sharma, smustgrave: Add additional test coverage for...,!9787Resolve issue 3479427 - bootstrap barrio issue under Windows,!9742Issue #3463908 by catch, quietone: Split OptionsFieldUiTest into two,!9526Issue #3458177 by mondrake, catch, quietone, godotislate, longwave, larowlan,...,!8738Issue #3424162 by camilledavis, dineshkumarbollu, smustgrave: Claro...,!8704Make greek characters available in ckeditor5,!8597Draft: Issue #3442259 by catch, quietone, dww: Reduce time of Migrate Upgrade tests...,!8533Issue #3446962 by kim.pepper: Remove incorrectly added...,!8517Issue #3443748 by NexusNovaz, smustgrave: Testcase creates false positive,!8325Update file Sort.php,!8095Expose document root on install,!7930Resolve #3427374 "Taxonomytid viewsargumentdefault plugin",!7627Issue #3439440 by nicxvan, Binoli Lalani, longwave: Remove country support from DateFormatter,!7445Issue #3440169: When using drupalGet(), provide an associative array for $headers,!7384Add constraints to system.advisories,!6502Draft: Resolve #2938524 "Plach testing issue",!38582585169-10.1.x,!3226Issue #2987537: Custom menu link entity type should not declare "bundle" entity key
Pipeline #139609 passed with warnings
Pipeline: drupal

#139612

    Showing
    with 271 additions and 91 deletions
    <?php
    declare(strict_types=1);
    namespace Drupal\media\Attribute;
    use Drupal\Component\Plugin\Attribute\Plugin;
    use Drupal\Core\StringTranslation\TranslatableMarkup;
    /**
    * Defines a MediaSource attribute.
    *
    * Media sources are responsible for implementing all the logic for dealing
    * with a particular type of media. They provide various universal and
    * type-specific metadata about media of the type they handle.
    *
    * Plugin namespace: Plugin\media\Source
    *
    * For a working example, see \Drupal\media\Plugin\media\Source\File.
    *
    * @see \Drupal\media\MediaSourceInterface
    * @see \Drupal\media\MediaSourceBase
    * @see \Drupal\media\MediaSourceManager
    * @see hook_media_source_info_alter()
    * @see plugin_api
    */
    #[\Attribute(\Attribute::TARGET_CLASS)]
    class MediaSource extends Plugin {
    /**
    * Constructs a new MediaSource attribute.
    *
    * @param string $id
    * The attribute class ID.
    * @param \Drupal\Core\StringTranslation\TranslatableMarkup $label
    * The human-readable name of the media source.
    * @param \Drupal\Core\StringTranslation\TranslatableMarkup|null $description
    * (optional) A brief description of the media source.
    * @param string[] $allowed_field_types
    * (optional) The field types that can be used as a source field for this
    * media source.
    * @param class-string[] $forms
    * (optional) The classes used to define media source-specific forms. An
    * array of form class names, keyed by ID. The ID represents the operation
    * the form is used for, for example, 'media_library_add'.
    * @param string $default_thumbnail_filename
    * (optional) A filename for the default thumbnail.
    * The thumbnails are placed in the directory defined by the config setting
    * 'media.settings.icon_base_uri'. When using custom icons, make sure the
    * module provides a hook_install() implementation to copy the custom icons
    * to this directory. The media_install() function provides a clear example
    * of how to do this.
    * @param string $thumbnail_uri_metadata_attribute
    * (optional) The metadata attribute name to provide the thumbnail URI.
    * @param string $thumbnail_width_metadata_attribute
    * (optional) The metadata attribute name to provide the thumbnail width.
    * @param string $thumbnail_height_metadata_attribute
    * (optional) The metadata attribute name to provide the thumbnail height.
    * @param string|null $thumbnail_alt_metadata_attribute
    * (optional) The metadata attribute name to provide the thumbnail alt.
    * "Thumbnail" will be used if the attribute name is not provided.
    * @param string|null $thumbnail_title_metadata_attribute
    * (optional) The metadata attribute name to provide the thumbnail title.
    * The name of the media item will be used if the attribute name is not
    * provided.
    * @param string $default_name_metadata_attribute
    * (optional) The metadata attribute name to provide the default name.
    * @param class-string|null $deriver
    * (optional) The deriver class.
    */
    public function __construct(
    public readonly string $id,
    public readonly TranslatableMarkup $label,
    public readonly ?TranslatableMarkup $description = NULL,
    public readonly array $allowed_field_types = [],
    public readonly array $forms = [],
    public readonly string $default_thumbnail_filename = 'generic.png',
    public readonly string $thumbnail_uri_metadata_attribute = 'thumbnail_uri',
    public readonly string $thumbnail_width_metadata_attribute = 'thumbnail_width',
    public readonly string $thumbnail_height_metadata_attribute = 'thumbnail_height',
    public readonly ?string $thumbnail_alt_metadata_attribute = NULL,
    public readonly ?string $thumbnail_title_metadata_attribute = NULL,
    public readonly string $default_name_metadata_attribute = 'default_name',
    public readonly ?string $deriver = NULL
    ) {}
    }
    <?php
    declare(strict_types=1);
    namespace Drupal\media\Attribute;
    use Drupal\Core\StringTranslation\TranslatableMarkup;
    /**
    * Defines a OEmbedMediaSource attribute.
    *
    * Plugin namespace: Plugin\media\Source
    *
    * For a working example, see \Drupal\media\Plugin\media\Source\OEmbed.
    *
    * @see \Drupal\media\MediaSourceInterface
    * @see \Drupal\media\MediaSourceBase
    * @see \Drupal\media\MediaSourceManager
    * @see hook_media_source_info_alter()
    * @see plugin_api
    */
    #[\Attribute(\Attribute::TARGET_CLASS)]
    class OEmbedMediaSource extends MediaSource {
    /**
    * Constructs a new OEmbedMediaSource attribute.
    *
    * @param string $id
    * The attribute class ID.
    * @param \Drupal\Core\StringTranslation\TranslatableMarkup $label
    * The human-readable name of the media source.
    * @param \Drupal\Core\StringTranslation\TranslatableMarkup|null $description
    * (optional) A brief description of the media source.
    * @param string[] $allowed_field_types
    * (optional) The field types that can be used as a source field for this
    * media source.
    * @param class-string[] $forms
    * (optional) The classes used to define media source-specific forms. An
    * array of form class names, keyed by ID. The ID represents the operation
    * the form is used for, for example, 'media_library_add'.
    * @param string[] $providers
    * (optional) A set of provider names, exactly as they appear in the
    * canonical oEmbed provider database at https://oembed.com/providers.json.
    * @param string $default_thumbnail_filename
    * (optional) A filename for the default thumbnail.
    * The thumbnails are placed in the directory defined by the config setting
    * 'media.settings.icon_base_uri'. When using custom icons, make sure the
    * module provides a hook_install() implementation to copy the custom icons
    * to this directory. The media_install() function provides a clear example
    * of how to do this.
    * @param string $thumbnail_uri_metadata_attribute
    * (optional) The metadata attribute name to provide the thumbnail URI.
    * @param string $thumbnail_width_metadata_attribute
    * (optional) The metadata attribute name to provide the thumbnail width.
    * @param string $thumbnail_height_metadata_attribute
    * (optional) The metadata attribute name to provide the thumbnail height.
    * @param string|null $thumbnail_alt_metadata_attribute
    * (optional) The metadata attribute name to provide the thumbnail alt.
    * "Thumbnail" will be used if the attribute name is not provided.
    * @param string|null $thumbnail_title_metadata_attribute
    * (optional) The metadata attribute name to provide the thumbnail title.
    * The name of the media item will be used if the attribute name is not
    * provided.
    * @param string $default_name_metadata_attribute
    * (optional) The metadata attribute name to provide the default name.
    * @param class-string|null $deriver
    * (optional) The deriver class.
    */
    public function __construct(
    public readonly string $id,
    public readonly TranslatableMarkup $label,
    public readonly ?TranslatableMarkup $description = NULL,
    public readonly array $allowed_field_types = [],
    public readonly array $forms = [],
    public readonly array $providers = [],
    public readonly string $default_thumbnail_filename = 'generic.png',
    public readonly string $thumbnail_uri_metadata_attribute = 'thumbnail_uri',
    public readonly string $thumbnail_width_metadata_attribute = 'thumbnail_width',
    public readonly string $thumbnail_height_metadata_attribute = 'thumbnail_height',
    public readonly ?string $thumbnail_alt_metadata_attribute = NULL,
    public readonly ?string $thumbnail_title_metadata_attribute = NULL,
    public readonly string $default_name_metadata_attribute = 'default_name',
    public readonly ?string $deriver = NULL
    ) {}
    }
    ...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
    use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Cache\CacheBackendInterface;
    use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Extension\ModuleHandlerInterface;
    use Drupal\Core\Plugin\DefaultPluginManager; use Drupal\Core\Plugin\DefaultPluginManager;
    use Drupal\media\Annotation\MediaSource; use Drupal\media\Attribute\MediaSource;
    /** /**
    * Manages media source plugins. * Manages media source plugins.
    ...@@ -24,7 +24,7 @@ class MediaSourceManager extends DefaultPluginManager { ...@@ -24,7 +24,7 @@ class MediaSourceManager extends DefaultPluginManager {
    * The module handler. * The module handler.
    */ */
    public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler) { public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler) {
    parent::__construct('Plugin/media/Source', $namespaces, $module_handler, MediaSourceInterface::class, MediaSource::class); parent::__construct('Plugin/media/Source', $namespaces, $module_handler, MediaSourceInterface::class, MediaSource::class, '\Drupal\media\Annotation\MediaSource');
    $this->alterInfo('media_source_info'); $this->alterInfo('media_source_info');
    $this->setCacheBackend($cache_backend, 'media_source_plugins'); $this->setCacheBackend($cache_backend, 'media_source_plugins');
    ......
    ...@@ -3,21 +3,22 @@ ...@@ -3,21 +3,22 @@
    namespace Drupal\media\Plugin\media\Source; namespace Drupal\media\Plugin\media\Source;
    use Drupal\Core\Entity\Display\EntityViewDisplayInterface; use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
    use Drupal\Core\StringTranslation\TranslatableMarkup;
    use Drupal\media\Attribute\MediaSource;
    use Drupal\media\MediaTypeInterface; use Drupal\media\MediaTypeInterface;
    /** /**
    * Media source wrapping around an audio file. * Media source wrapping around an audio file.
    * *
    * @see \Drupal\file\FileInterface * @see \Drupal\file\FileInterface
    *
    * @MediaSource(
    * id = "audio_file",
    * label = @Translation("Audio file"),
    * description = @Translation("Use audio files for reusable media."),
    * allowed_field_types = {"file"},
    * default_thumbnail_filename = "audio.png"
    * )
    */ */
    #[MediaSource(
    id: "audio_file",
    label: new TranslatableMarkup("Audio file"),
    description: new TranslatableMarkup("Use audio files for reusable media."),
    allowed_field_types: ["file"],
    default_thumbnail_filename: "audio.png"
    )]
    class AudioFile extends File { class AudioFile extends File {
    /** /**
    ......
    ...@@ -2,7 +2,9 @@ ...@@ -2,7 +2,9 @@
    namespace Drupal\media\Plugin\media\Source; namespace Drupal\media\Plugin\media\Source;
    use Drupal\Core\StringTranslation\TranslatableMarkup;
    use Drupal\file\FileInterface; use Drupal\file\FileInterface;
    use Drupal\media\Attribute\MediaSource;
    use Drupal\media\MediaInterface; use Drupal\media\MediaInterface;
    use Drupal\media\MediaTypeInterface; use Drupal\media\MediaTypeInterface;
    use Drupal\media\MediaSourceBase; use Drupal\media\MediaSourceBase;
    ...@@ -11,15 +13,13 @@ ...@@ -11,15 +13,13 @@
    * File entity media source. * File entity media source.
    * *
    * @see \Drupal\file\FileInterface * @see \Drupal\file\FileInterface
    *
    * @MediaSource(
    * id = "file",
    * label = @Translation("File"),
    * description = @Translation("Use local files for reusable media."),
    * allowed_field_types = {"file"},
    * default_thumbnail_filename = "generic.png"
    * )
    */ */
    #[MediaSource(
    id: "file",
    label: new TranslatableMarkup("File"),
    description: new TranslatableMarkup("Use local files for reusable media."),
    allowed_field_types: ["file"],
    )]
    class File extends MediaSourceBase { class File extends MediaSourceBase {
    /** /**
    ......
    ...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
    use Drupal\Core\Field\FieldTypePluginManagerInterface; use Drupal\Core\Field\FieldTypePluginManagerInterface;
    use Drupal\Core\File\FileSystemInterface; use Drupal\Core\File\FileSystemInterface;
    use Drupal\Core\Image\ImageFactory; use Drupal\Core\Image\ImageFactory;
    use Drupal\Core\StringTranslation\TranslatableMarkup;
    use Drupal\media\Attribute\MediaSource;
    use Drupal\media\MediaInterface; use Drupal\media\MediaInterface;
    use Drupal\media\MediaTypeInterface; use Drupal\media\MediaTypeInterface;
    use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
    ...@@ -17,16 +19,15 @@ ...@@ -17,16 +19,15 @@
    * Image entity media source. * Image entity media source.
    * *
    * @see \Drupal\Core\Image\ImageInterface * @see \Drupal\Core\Image\ImageInterface
    *
    * @MediaSource(
    * id = "image",
    * label = @Translation("Image"),
    * description = @Translation("Use local images for reusable media."),
    * allowed_field_types = {"image"},
    * default_thumbnail_filename = "no-thumbnail.png",
    * thumbnail_alt_metadata_attribute = "thumbnail_alt_value"
    * )
    */ */
    #[MediaSource(
    id: "image",
    label: new TranslatableMarkup("Image"),
    description: new TranslatableMarkup("Use local images for reusable media."),
    allowed_field_types: ["image"],
    default_thumbnail_filename: "no-thumbnail.png",
    thumbnail_alt_metadata_attribute: "thumbnail_alt_value"
    )]
    class Image extends File { class Image extends File {
    /** /**
    ......
    ...@@ -14,8 +14,10 @@ ...@@ -14,8 +14,10 @@
    use Drupal\Core\File\FileSystemInterface; use Drupal\Core\File\FileSystemInterface;
    use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\FormStateInterface;
    use Drupal\Core\Messenger\MessengerInterface; use Drupal\Core\Messenger\MessengerInterface;
    use Drupal\Core\StringTranslation\TranslatableMarkup;
    use Drupal\Core\Url; use Drupal\Core\Url;
    use Drupal\Core\Utility\Token; use Drupal\Core\Utility\Token;
    use Drupal\media\Attribute\OEmbedMediaSource;
    use Drupal\media\IFrameUrlHelper; use Drupal\media\IFrameUrlHelper;
    use Drupal\media\OEmbed\Resource; use Drupal\media\OEmbed\Resource;
    use Drupal\media\OEmbed\ResourceException; use Drupal\media\OEmbed\ResourceException;
    ...@@ -65,17 +67,15 @@ ...@@ -65,17 +67,15 @@
    * define a new class which extends it. With the code above, you will able to * define a new class which extends it. With the code above, you will able to
    * create media types which use the "Artwork" source plugin, and use those media * create media types which use the "Artwork" source plugin, and use those media
    * types to link to assets on Deviantart and Flickr. * types to link to assets on Deviantart and Flickr.
    *
    * @MediaSource(
    * id = "oembed",
    * label = @Translation("oEmbed source"),
    * description = @Translation("Use oEmbed URL for reusable media."),
    * allowed_field_types = {"string"},
    * default_thumbnail_filename = "no-thumbnail.png",
    * deriver = "Drupal\media\Plugin\media\Source\OEmbedDeriver",
    * providers = {},
    * )
    */ */
    #[OEmbedMediaSource(
    id: "oembed",
    label: new TranslatableMarkup("oEmbed source"),
    description: new TranslatableMarkup("Use oEmbed URL for reusable media."),
    allowed_field_types: ["string"],
    default_thumbnail_filename: "no-thumbnail.png",
    deriver: OEmbedDeriver::class,
    )]
    class OEmbed extends MediaSourceBase implements OEmbedInterface { class OEmbed extends MediaSourceBase implements OEmbedInterface {
    /** /**
    ......
    ...@@ -3,21 +3,22 @@ ...@@ -3,21 +3,22 @@
    namespace Drupal\media\Plugin\media\Source; namespace Drupal\media\Plugin\media\Source;
    use Drupal\Core\Entity\Display\EntityViewDisplayInterface; use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
    use Drupal\Core\StringTranslation\TranslatableMarkup;
    use Drupal\media\Attribute\MediaSource;
    use Drupal\media\MediaTypeInterface; use Drupal\media\MediaTypeInterface;
    /** /**
    * Media source wrapping around a video file. * Media source wrapping around a video file.
    * *
    * @see \Drupal\file\FileInterface * @see \Drupal\file\FileInterface
    *
    * @MediaSource(
    * id = "video_file",
    * label = @Translation("Video file"),
    * description = @Translation("Use video files for reusable media."),
    * allowed_field_types = {"file"},
    * default_thumbnail_filename = "video.png"
    * )
    */ */
    #[MediaSource(
    id: "video_file",
    label: new TranslatableMarkup("Video file"),
    description: new TranslatableMarkup("Use video files for reusable media."),
    allowed_field_types: ["file"],
    default_thumbnail_filename: "video.png"
    )]
    class VideoFile extends File { class VideoFile extends File {
    /** /**
    ......
    ...@@ -4,19 +4,20 @@ ...@@ -4,19 +4,20 @@
    use Drupal\Component\Utility\NestedArray; use Drupal\Component\Utility\NestedArray;
    use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\FormStateInterface;
    use Drupal\Core\StringTranslation\TranslatableMarkup;
    use Drupal\media\Attribute\MediaSource;
    use Drupal\media\MediaInterface; use Drupal\media\MediaInterface;
    use Drupal\media\MediaSourceBase; use Drupal\media\MediaSourceBase;
    /** /**
    * Provides test media source. * Provides test media source.
    *
    * @MediaSource(
    * id = "test",
    * label = @Translation("Test source"),
    * description = @Translation("Test media source."),
    * allowed_field_types = {"string"},
    * )
    */ */
    #[MediaSource(
    id: "test",
    label: new TranslatableMarkup("Test source"),
    description: new TranslatableMarkup("Test media source."),
    allowed_field_types: ["string"]
    )]
    class Test extends MediaSourceBase { class Test extends MediaSourceBase {
    /** /**
    ......
    ...@@ -4,18 +4,19 @@ ...@@ -4,18 +4,19 @@
    use Drupal\Core\Entity\Display\EntityFormDisplayInterface; use Drupal\Core\Entity\Display\EntityFormDisplayInterface;
    use Drupal\Core\Entity\Display\EntityViewDisplayInterface; use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
    use Drupal\Core\StringTranslation\TranslatableMarkup;
    use Drupal\media\Attribute\MediaSource;
    use Drupal\media\MediaTypeInterface; use Drupal\media\MediaTypeInterface;
    /** /**
    * Provides test media source. * Provides test media source.
    *
    * @MediaSource(
    * id = "test_different_displays",
    * label = @Translation("Test source with different displays"),
    * description = @Translation("Test source with different displays."),
    * allowed_field_types = {"entity_reference"},
    * )
    */ */
    #[MediaSource(
    id: "test_different_displays",
    label: new TranslatableMarkup("Test source with different displays"),
    description: new TranslatableMarkup("Test source with different displays."),
    allowed_field_types: ["entity_reference"]
    )]
    class TestDifferentDisplays extends Test { class TestDifferentDisplays extends Test {
    /** /**
    ......
    ...@@ -2,19 +2,20 @@ ...@@ -2,19 +2,20 @@
    namespace Drupal\media_test_source\Plugin\media\Source; namespace Drupal\media_test_source\Plugin\media\Source;
    use Drupal\Core\StringTranslation\TranslatableMarkup;
    use Drupal\media\Attribute\MediaSource;
    use Drupal\media\MediaInterface; use Drupal\media\MediaInterface;
    /** /**
    * Provides test media source. * Provides test media source.
    *
    * @MediaSource(
    * id = "test_translation",
    * label = @Translation("Test source with translations"),
    * description = @Translation("Test media source with translations."),
    * allowed_field_types = {"string"},
    * thumbnail_alt_metadata_attribute = "test_thumbnail_alt",
    * )
    */ */
    #[MediaSource(
    id: "test_translation",
    label: new TranslatableMarkup("Test source with translations"),
    description: new TranslatableMarkup("Test media source with translations."),
    allowed_field_types: ["string"],
    thumbnail_alt_metadata_attribute: "test_thumbnail_alt"
    )]
    class TestTranslation extends Test { class TestTranslation extends Test {
    /** /**
    ......
    ...@@ -2,19 +2,20 @@ ...@@ -2,19 +2,20 @@
    namespace Drupal\media_test_source\Plugin\media\Source; namespace Drupal\media_test_source\Plugin\media\Source;
    use Drupal\Core\StringTranslation\TranslatableMarkup;
    use Drupal\media\Attribute\MediaSource;
    use Drupal\media\MediaSourceEntityConstraintsInterface; use Drupal\media\MediaSourceEntityConstraintsInterface;
    use Drupal\media\MediaSourceFieldConstraintsInterface; use Drupal\media\MediaSourceFieldConstraintsInterface;
    /** /**
    * Provides generic media type. * Provides generic media type.
    *
    * @MediaSource(
    * id = "test_constraints",
    * label = @Translation("Test source with constraints"),
    * description = @Translation("Test media source that provides constraints."),
    * allowed_field_types = {"string_long"},
    * )
    */ */
    #[MediaSource(
    id: "test_constraints",
    label: new TranslatableMarkup("Test source with constraints"),
    description: new TranslatableMarkup("Test media source that provides constraints."),
    allowed_field_types: ["string_long"],
    )]
    class TestWithConstraints extends Test implements MediaSourceEntityConstraintsInterface, MediaSourceFieldConstraintsInterface { class TestWithConstraints extends Test implements MediaSourceEntityConstraintsInterface, MediaSourceFieldConstraintsInterface {
    /** /**
    ......
    ...@@ -4,18 +4,19 @@ ...@@ -4,18 +4,19 @@
    use Drupal\Core\Entity\Display\EntityFormDisplayInterface; use Drupal\Core\Entity\Display\EntityFormDisplayInterface;
    use Drupal\Core\Entity\Display\EntityViewDisplayInterface; use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
    use Drupal\Core\StringTranslation\TranslatableMarkup;
    use Drupal\media\Attribute\MediaSource;
    use Drupal\media\MediaTypeInterface; use Drupal\media\MediaTypeInterface;
    /** /**
    * Provides test media source. * Provides test media source.
    *
    * @MediaSource(
    * id = "test_hidden_source_field",
    * label = @Translation("Test source with hidden source field"),
    * description = @Translation("Test media source with hidden source field."),
    * allowed_field_types = {"string"},
    * )
    */ */
    #[MediaSource(
    id: "test_hidden_source_field",
    label: new TranslatableMarkup("Test source with hidden source field"),
    description: new TranslatableMarkup("Test media source with hidden source field."),
    allowed_field_types: ["string"],
    )]
    class TestWithHiddenSourceField extends Test { class TestWithHiddenSourceField extends Test {
    /** /**
    ......
    ...@@ -60,16 +60,15 @@ ...@@ -60,16 +60,15 @@
    * source plugin definition which provides an add form for the media library: * source plugin definition which provides an add form for the media library:
    * *
    * @code * @code
    * @MediaSource( * #[MediaSource(
    * id = "file", * id: "file",
    * label = @Translation("File"), * label: new TranslatableMarkup("File"),
    * description = @Translation("Use local files for reusable media."), * description: new TranslatableMarkup("Use local files for reusable media."),
    * allowed_field_types = {"file"}, * allowed_field_types: ["file"],
    * default_thumbnail_filename = "generic.png", * forms = [
    * forms = { * "media_library_add" => "\Drupal\media_library\Form\FileUploadForm",
    * "media_library_add" = "\Drupal\media_library\Form\FileUploadForm", * ]
    * }, * )]
    * )
    * @endcode * @endcode
    * *
    * This can also be done in hook_media_source_info_alter(). For example: * This can also be done in hook_media_source_info_alter(). For example:
    ......
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Please register or to comment