Skip to content

Commit

Permalink
Issue #1848 EmitFileEvent.php: Call to undefined function getFileUri() (
Browse files Browse the repository at this point in the history
#838)

Explicitly check for function before it is called.
  • Loading branch information
alxp committed Jun 30, 2021
1 parent cf82e8f commit 492be9f
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/Plugin/Action/EmitFileEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,18 +105,22 @@ public static function create(ContainerInterface $container, array $configuratio
* {@inheritdoc}
*/
protected function generateData(EntityInterface $entity) {
$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.
if (strpos($uri, $scheme . ':///') !== FALSE) {
$uri = str_replace($scheme . ':///', $scheme . '://', $uri);

// 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');

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.
if (strpos($uri, $scheme . ':///') !== FALSE) {
$uri = str_replace($scheme . ':///', $scheme . '://', $uri);
}
$data['fedora_uri'] = str_replace("$scheme://", $flysystem_config[$scheme]['config']['root'], $uri);
}
$data['fedora_uri'] = str_replace("$scheme://", $flysystem_config[$scheme]['config']['root'], $uri);
}
return $data;
}
Expand Down

0 comments on commit 492be9f

Please sign in to comment.