Conversation
yenyasinn
reviewed
Sep 17, 2020
tests/Traits/MediaCreationTrait.php
Outdated
| 'oe_media_image' => [ | ||
| 'target_id' => $file_id, | ||
| 'alt' => $properties['alt'] ?? $properties['name'], | ||
| 'title' => $properties['title'] ?? $properties['name'], |
Contributor
There was a problem hiding this comment.
Could you please check createBlock() in build/core/modules/views/tests/src/Kernel/Plugin/BlockDependenciesTest.php. Might be it can be useful to organise code as there (look at the $settings) - it allows to provide wide range of variables even that we don't expect now.
Also would be nice to have ability to override media status.
3321c22 to
ec39a1f
Compare
yenyasinn
reviewed
Sep 18, 2020
tests/Traits/MediaCreationTrait.php
Outdated
| $settings += [ | ||
| 'name' => $this->getFileNameSuggestion($file), | ||
| 'file_id' => FALSE, | ||
| 'alt' => 'image', |
Contributor
There was a problem hiding this comment.
Might be we can use $this->getFileNameSuggestion($file) for alt and title to make them more specific.
nagyad
requested changes
Sep 18, 2020
tests/Traits/MediaCreationTrait.php
Outdated
| trait MediaCreationTrait { | ||
|
|
||
| /** | ||
| * Create a file entity from given file path. |
tests/Traits/MediaCreationTrait.php
Outdated
| * @return \Drupal\media\Entity\Media | ||
| * The media object. | ||
| */ | ||
| protected function createMediaDocument(FileInterface $file, array $settings = []): Media { |
Member
There was a problem hiding this comment.
Return type hint should be MediaInterface.
tests/Traits/MediaCreationTrait.php
Outdated
| * @param array $settings | ||
| * An associative array of settings for the media entity. | ||
| * | ||
| * @return \Drupal\media\Entity\Media |
tests/Traits/MediaCreationTrait.php
Outdated
| * @return \Drupal\media\Entity\Media | ||
| * The media object. | ||
| */ | ||
| protected function createMediaImage(FileInterface $file, array $settings = []): Media { |
tests/Traits/MediaCreationTrait.php
Outdated
| * @return \Drupal\media\Entity\Media | ||
| * The media object. | ||
| */ | ||
| protected function createMediaAvPortalPhoto(MediaAvPortalSourceInterface $media_source, array $settings = []): Media { |
tests/Traits/MediaCreationTrait.php
Outdated
| * @return \Drupal\media\Entity\Media | ||
| * The media object. | ||
| */ | ||
| protected function createMediaRemoteVideo(array $settings = []): Media { |
nagyad
approved these changes
Sep 21, 2020
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
EWPP-253
Description
Move media creation into trait.
Change log