l10n->t('Block file versioning'); } #[\Override] public function getDescription(): string { return $this->l10n->t('Automatic tag based blocking of file version creation.'); } #[\Override] public function getIcon(): string { return $this->urlGenerator->imagePath('files_versions', 'app.svg'); } #[\Override] public function isAvailableForScope(int $scope): bool { return $scope === IManager::SCOPE_ADMIN; } #[\Override] public function validateOperation(string $name, array $checks, string $operation): void { if (empty($checks)) { throw new \UnexpectedValueException($this->l10n->t('No rule given')); } } #[\Override] public function onEvent(string $eventName, Event $event, IRuleMatcher $ruleMatcher): void { if ($eventName !== CreateVersionEvent::class || !($event instanceof CreateVersionEvent)) { return; } $node = $event->getNode(); $path = $node->getInternalPath(); $ruleMatcher->setFileInfo( $node->getStorage(), $path, $node instanceof Folder, ); $ruleMatcher->setEntitySubject($this->fileEntity, $node); $ruleMatcher->setOperation($this); $flows = $ruleMatcher->getFlows(); if ($flows !== []) { $this->logger->debug('Blocking version creation due to matching workflow rules', [ 'path' => $path, ]); $event->disableVersions(); } } #[\Override] public function getTriggerHint(): string { return $this->l10n->t('A new version is created'); // TRANSLATORS: This will be shown as "When: " "A new version is created" } }