Skip to content

Commit

Permalink
Merge pull request #13 from lingoda/07-bugfix
Browse files Browse the repository at this point in the history
Fix delete image on edit and avoid double slash & remove #tmp on saving
  • Loading branch information
jorisdugue committed Sep 4, 2020
2 parents 43e0b88 + a5e80e5 commit b94fdf0
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
14 changes: 11 additions & 3 deletions Core/H5POptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,23 @@ public function getUploadedH5pPath($set = null)

public function getRelativeH5PPath()
{
return "/". $this->getOption('storage_dir');
$dir = $this->getOption('storage_dir');

return $dir[0] === '/' ? $dir : '/' . $dir;
}

public function getAbsoluteH5PPathWithSlash(){
return $this->getAbsoluteWebPath() . '/' . $this->getOption('storage_dir') .'/';
$dir = $this->getOption('storage_dir');
$dir = $dir[0] === '/' ? $dir : '/' . $dir;

return $this->getAbsoluteWebPath() . $dir .'/';
}
public function getAbsoluteH5PPath()
{
return $this->getAbsoluteWebPath() . '/' . $this->getOption('storage_dir');
$dir = $this->getOption('storage_dir');
$dir = $dir[0] === '/' ? $dir : '/' . $dir;

return $this->getAbsoluteWebPath() . $dir;
}

public function getAbsoluteWebPath()
Expand Down
2 changes: 1 addition & 1 deletion Core/H5PSymfony.php
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ private function storeContent($contentData, Content $content)
{
$library = $this->manager->getRepository('StuditH5PBundle:Library')->find($contentData['library']['libraryId']);
$content->setLibrary($library);
$content->setParameters($contentData['params']);
$content->setParameters(str_replace('#tmp','', $contentData['params']));
$content->setDisabledFeatures($contentData['disable']);
$content->setFilteredParameters(null);
$this->manager->persist($content);
Expand Down
5 changes: 4 additions & 1 deletion DependencyInjection/StuditH5PExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ public function load(array $configs, ContainerBuilder $container)
$loader->load('services.yml');
/** @var $definition Definition **/
$definition = $container->getDefinition("studit_h5p.core");
$definition->setArgument(1, $container->getParameter('kernel.project_dir') . '/' . $config['web_dir'] . '/' . $config["storage_dir"]);
$dir = $config["storage_dir"];
$dir[0] === '/' ? $dir : '/' . $dir;

$definition->setArgument(1, $container->getParameter('kernel.project_dir') . '/' . $config['web_dir'] . $dir);
$definition->setArgument(2, '/');
$definition->setArgument(3, 'en');
$definition->setArgument(4, true);
Expand Down
2 changes: 1 addition & 1 deletion Editor/LibraryStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function storeLibraryData($library, $parameters, Content $content = null)
if (!$content){
$contentData['id'] = $contentId;
}
$this->updateLibraryFiles($contentId, $contentData, $oldLibrary, $oldParameters);
$this->updateLibraryFiles($contentId, $contentData, $oldLibrary, $oldParameters->params ?? null);
return $contentId;
}
private function updateLibraryFiles($contentId, $contentData, $oldLibrary, $oldParameters)
Expand Down

0 comments on commit b94fdf0

Please sign in to comment.