|
|
@ -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; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|