Closed quisse closed 3 years ago
Either this is wrong:
https://github.com/sonata-project/SonataMediaBundle/blob/0b793970580fc3e4dfbde9efeacac384e112609b/src/Model/MediaInterface.php#L324-L327
and we need to document that properly and adapt this piece of code:
https://github.com/sonata-project/SonataMediaBundle/blob/0b793970580fc3e4dfbde9efeacac384e112609b/src/Extra/Pixlr.php#L183-L190
or there is a bug in implementation of MediaInterface
. Does it make sense not to have an extension for a media?
AFAIK it doesn't make sense to have an extension when there is no media (= new empty object). I'm also in doubt if the Pixlr should do anything when there's no media.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Not sure how to take this forward? For me this is currently out of scope.
public function getExtension()
{
$providerReference = $this->getProviderReference();
if (!$providerReference) {
return null;
}
// strips off query strings or hashes, which are common in URIs remote references
return preg_replace('{(\?|#).*}', '', pathinfo($providerReference, PATHINFO_EXTENSION));
}
Is not compatible with
/**
* @return string
*/
public function getExtension();
I don't know the context of this bundle:
null
is not a valid value, you should create a PR to change it.null
is a valida value, you should update the signature of the Interface
. Then you should modify the implementation of Pixir::isEditable
(and maybe others class/methods) to handle the null
case.
Environment
Sonata packages
Symfony packages
PHP version
Subject
When trying to create a media object from a \Sonata\Form\Type\ModelListType, it fails.
Steps to reproduce
Try to create a new media item by selecting the image provider.
Expected results
A newly created media item.
Actual results
(temporary) solution
Adding following lines to the extended media entity.