mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
ckeck document mime (TO BE CHECKED)
This commit is contained in:
parent
ef42227e6c
commit
0b5a0e65a8
@ -11,6 +11,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\DocStoreBundle\Templating;
|
||||
|
||||
use ChampsLibres\WopiLib\Contract\Service\Discovery\DiscoveryInterface;
|
||||
use Chill\DocStoreBundle\Entity\StoredObject;
|
||||
use Twig\Extension\AbstractExtension;
|
||||
use Twig\TwigFilter;
|
||||
@ -19,6 +20,13 @@ use Twig\TwigFunction;
|
||||
class WopiEditTwigExtension extends AbstractExtension
|
||||
{
|
||||
|
||||
private DiscoveryInterface $discovery;
|
||||
|
||||
public function __construct(DiscoveryInterface $discovery)
|
||||
{
|
||||
$this->discovery = $discovery;
|
||||
}
|
||||
|
||||
public function getFilters(): array
|
||||
{
|
||||
return [
|
||||
@ -38,6 +46,16 @@ class WopiEditTwigExtension extends AbstractExtension
|
||||
|
||||
public function isEditable(StoredObject $document): bool
|
||||
{
|
||||
return true;
|
||||
$mime = $this->discovery->discoverMimeType($document->getType());
|
||||
|
||||
// TO CHECk is it better condition ?
|
||||
if (array_key_exists('default', $mime[0])
|
||||
&& $mime[0]['default'] === 'true'
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
//dump($document, $mime);
|
||||
return false;
|
||||
}
|
||||
}
|
@ -1,6 +1,8 @@
|
||||
services:
|
||||
|
||||
Chill\DocStoreBundle\Templating\WopiEditTwigExtension:
|
||||
arguments:
|
||||
$discovery: '@ChampsLibres\WopiLib\Contract\Service\Discovery\DiscoveryInterface'
|
||||
tags:
|
||||
- { name: twig.extension }
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user