Skip to content

Commit

Permalink
Change media path usage
Browse files Browse the repository at this point in the history
  • Loading branch information
Danny van Wijk committed Oct 12, 2021
1 parent f852860 commit ad958cf
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
7 changes: 6 additions & 1 deletion UPGRADE-5.10.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ UPGRADE FROM 5.9 to 5.10
AdminBundle
------------

* The `kunstmaan_admin.google_signin` config and related classes/functionality is deprecated and will be removed in 6.0. If you need the ability
* The `kunstmaan_admin.google_signin` config and related classes/functionality is deprecated and will be removed in 6.0. If you need the ability
to login in the admin interface with google, implement the authenticator in your project.
* Passing a service instance of `Symfony\Component\HttpFoundation\Session\SessionInterface` for the first argument in `Kunstmaan\AdminBundle\EventListener\PasswordCheckListener::__construct` is deprecated and an instance of `Symfony\Component\HttpFoundation\RequestStack` will be required in 6.0.

Expand All @@ -13,3 +13,8 @@ NodeBundle

* Passing a service instance of `Symfony\Component\HttpFoundation\Session\SessionInterface` for the first argument in `Kunstmaan\NodeBundle\EventListener\NodeTranslationListener::__construct` is deprecated and an instance of `Symfony\Component\HttpFoundation\RequestStack` will be required in 6.0.
* The fourth argument of `Kunstmaan\NodeBundle\EventListener\NodeTranslationListener::__construct` is deprecated and will be removed in 6.0. Check the constructor arguments and inject the required services instead.

MediaBundle
-----------

* Parameter `kunstmaan_media.full_media_path` is deprecated and will be removed in 6.0.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ public function load(array $configs, ContainerBuilder $container)
$container->setParameter('kunstmaan_media.enable_pdf_preview', $config['enable_pdf_preview']);
$container->setParameter('kunstmaan_media.blacklisted_extensions', $config['blacklisted_extensions']);
$container->setParameter('kunstmaan_media.web_root', $config['web_root']);

// NEXT_MAJOR: Remove parameter because this is not used
$container->setParameter('kunstmaan_media.full_media_path', $config['web_root'] . '%kunstmaan_media.media_path%');

$loader->load('services.yml');
Expand Down
9 changes: 6 additions & 3 deletions src/Kunstmaan/MediaBundle/Helper/File/FileHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ public function prepareMedia(Media $media)

$media->setContentType($contentType);
$media->setFileSize(filesize($media->getContent()));
$media->setUrl($this->mediaPath . $this->getFilePath($media));
$media->setUrl($this->getFilePath($media));
$media->setLocation('local');
}

Expand Down Expand Up @@ -334,7 +334,8 @@ private function getFilePath(Media $media)
}

return sprintf(
'%s/%s',
'%s%s/%s',
$this->mediaPath,
$media->getUuid(),
$filename
);
Expand All @@ -345,7 +346,9 @@ private function getFilePath(Media $media)
*/
private function getFileFolderPath(Media $media)
{
return substr($this->getFilePath($media), 0, strrpos($this->getFilePath($media), $media->getOriginalFilename()));
$filePath = $this->getFilePath($media);

return substr($filePath, 0, strrpos($filePath, $media->getOriginalFilename()));
}

private function guessMimeType($pathName)
Expand Down
2 changes: 1 addition & 1 deletion src/Kunstmaan/MediaBundle/Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ services:
kunstmaan_media.filesystem_adapter:
class: Gaufrette\Adapter\Local
arguments:
- '%kunstmaan_media.full_media_path%'
- '%kunstmaan_media.web_root%'
- true

kunstmaan_media.filesystem:
Expand Down

0 comments on commit ad958cf

Please sign in to comment.