Browse Source

Fix for media_source_mimetype to allow entities to display when not specified. (#803)

pull/814/head
Nigel Banks 4 years ago committed by GitHub
parent
commit
836d521273
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 20
      src/Plugin/Condition/MediaSourceHasMimetype.php

20
src/Plugin/Condition/MediaSourceHasMimetype.php

@ -44,20 +44,24 @@ class MediaSourceHasMimetype extends ConditionPluginBase {
* {@inheritdoc}
*/
public function evaluate() {
foreach ($this->getContexts() as $context) {
if ($context->hasContextValue()) {
$entity = $context->getContextValue();
$mid = $entity->id();
if ($mid && !empty($this->configuration['mimetype'])) {
$source = $entity->getSource();
if (empty($this->configuration['mimetype']) && !$this->isNegated()) {
return TRUE;
}
$media = $this->getContext('media');
if ($media->hasContextValue()) {
$entity = $media->getContextValue();
$mid = $entity->id();
if ($mid) {
$source = $entity->getSource();
if ($source) {
$source_file = File::load($source->getSourceFieldValue($entity));
if ($this->configuration['mimetype'] == $source_file->getMimeType()) {
return !$this->isNegated();
return TRUE;
}
}
}
}
return $this->isNegated();
return FALSE;
}
/**

Loading…
Cancel
Save