false, ]; private const TEMPLATE = '@ChillDocStore/Button/wopi_edit_document.html.twig'; private const TEMPLATE_BUTTON_GROUP = '@ChillDocStore/Button/button_group.html.twig'; private DiscoveryInterface $discovery; private NormalizerInterface $normalizer; public function __construct(DiscoveryInterface $discovery, NormalizerInterface $normalizer) { $this->discovery = $discovery; $this->normalizer = $normalizer; } /** * return true if the document is editable. * * **NOTE**: as the Vue button does have similar test, this is not required if in use with * the dedicated Vue component (GroupDownloadButton.vue, WopiEditButton.vue) */ public function isEditable(StoredObject $document): bool { return in_array($document->getType(), self::SUPPORTED_MIMES, true); } /** * @param array{small: boolean} $options * * @throws \Twig\Error\LoaderError * @throws \Twig\Error\RuntimeError * @throws \Twig\Error\SyntaxError */ public function renderButtonGroup(Environment $environment, StoredObject $document, ?string $title = null, bool $canEdit = true, array $options = []): string { return $environment->render(self::TEMPLATE_BUTTON_GROUP, [ 'document' => $document, 'document_json' => $this->normalizer->normalize($document, 'json', [AbstractNormalizer::GROUPS => ['read']]), 'title' => $title, 'can_edit' => $canEdit, 'options' => array_merge(self::DEFAULT_OPTIONS_TEMPLATE_BUTTON_GROUP, $options), ]); } public function renderEditButton(Environment $environment, StoredObject $document, ?array $options = null): string { return $environment->render(self::TEMPLATE, [ 'document' => $document, 'options' => $options, ]); } }