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} * {@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(); }
$mid = $entity->id(); $media = $this->getContext('media');
if ($mid && !empty($this->configuration['mimetype'])) { if ($media->hasContextValue()) {
$source = $entity->getSource(); $entity = $media->getContextValue();
$mid = $entity->id();
if ($mid) {
$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