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. 16
      src/Plugin/Condition/MediaSourceHasMimetype.php

16
src/Plugin/Condition/MediaSourceHasMimetype.php

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

Loading…
Cancel
Save