-
Notifications
You must be signed in to change notification settings - Fork 7
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
EWPP-253: Move media creation into trait. #124
base: master
Are you sure you want to change the base?
Conversation
tests/Traits/MediaCreationTrait.php
Outdated
'oe_media_image' => [ | ||
'target_id' => $file_id, | ||
'alt' => $properties['alt'] ?? $properties['name'], | ||
'title' => $properties['title'] ?? $properties['name'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
tests/Traits/MediaCreationTrait.php
Outdated
$settings += [ | ||
'name' => $this->getFileNameSuggestion($file), | ||
'file_id' => FALSE, | ||
'alt' => 'image', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be we can use $this->getFileNameSuggestion($file) for alt and title to make them more specific.
tests/Traits/MediaCreationTrait.php
Outdated
trait MediaCreationTrait { | ||
|
||
/** | ||
* Create a file entity from given file path. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... from the given file path.
tests/Traits/MediaCreationTrait.php
Outdated
* @return \Drupal\media\Entity\Media | ||
* The media object. | ||
*/ | ||
protected function createMediaDocument(FileInterface $file, array $settings = []): Media { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MediaInterface
tests/Traits/MediaCreationTrait.php
Outdated
* @return \Drupal\media\Entity\Media | ||
* The media object. | ||
*/ | ||
protected function createMediaImage(FileInterface $file, array $settings = []): Media { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be MediaInterface
tests/Traits/MediaCreationTrait.php
Outdated
* @return \Drupal\media\Entity\Media | ||
* The media object. | ||
*/ | ||
protected function createMediaAvPortalPhoto(MediaAvPortalSourceInterface $media_source, array $settings = []): Media { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MediaInterface
tests/Traits/MediaCreationTrait.php
Outdated
* @return \Drupal\media\Entity\Media | ||
* The media object. | ||
*/ | ||
protected function createMediaRemoteVideo(array $settings = []): Media { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MediaInterface
EWPP-253
Description
Move media creation into trait.
Change log