Browse Source

Issue #1848 EmitFileEvent.php: Call to undefined function getFileUri() (#838)

Explicitly check for function before it is called.
pull/841/head
Alexander O'Neill 3 years ago committed by GitHub
parent
commit
492be9fdef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      src/Plugin/Action/EmitFileEvent.php

6
src/Plugin/Action/EmitFileEvent.php

@ -105,11 +105,14 @@ class EmitFileEvent extends EmitEvent {
* {@inheritdoc}
*/
protected function generateData(EntityInterface $entity) {
$data = parent::generateData($entity);
// This function is called on Media and File entity types.
if (method_exists($entity, 'getFileUri')) {
$uri = $entity->getFileUri();
$scheme = StreamWrapperManager::getScheme($uri);
$flysystem_config = Settings::get('flysystem');
$data = parent::generateData($entity);
if (isset($flysystem_config[$scheme]) && $flysystem_config[$scheme]['driver'] == 'fedora') {
// Fdora $uri for files may contain ':///' so we need to replace
// the three / with two.
@ -118,6 +121,7 @@ class EmitFileEvent extends EmitEvent {
}
$data['fedora_uri'] = str_replace("$scheme://", $flysystem_config[$scheme]['config']['root'], $uri);
}
}
return $data;
}

Loading…
Cancel
Save