Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MediaBundle] Change media path usage #2784

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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%'
Copy link
Member

@acrobat acrobat Oct 12, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this change "wrong" as it currently injects path/to/web/root/uploads/media/ and now would inject path/to/web/root?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uploads/media is handled in the FileHandler. We already using this configuration without any problems.

- true

kunstmaan_media.filesystem:
Expand Down