2 declare(strict_types = 1);
53 return GeneralUtility::hmac($content);
68 $this->definedInvocations[$command] = $type;
70 unset($this->definedInvocations[$command]);
87 string $combinedFileIdentifier,
88 string $contentSignature =
null
92 $combinedFileIdentifier,
96 if ($index !==
null) {
100 $this->allowedInvocations[] = [
101 'command' => $command,
102 'combinedFileIdentifier' => $combinedFileIdentifier,
103 'contentSignature' => $contentSignature,
113 public function onPreFileCreate(
string $fileName, FolderInterface $targetFolder): void
121 self::COMMAND_FILE_CREATE,
122 $combinedFileIdentifier
132 string $targetFileName,
133 FolderInterface $targetFolder,
134 string $sourceFilePath
147 self::COMMAND_FILE_ADD,
148 $combinedFileIdentifier,
149 file_get_contents($sourceFilePath)
157 public function onPreFileRename(FileInterface $file,
string $targetFileName): void
160 $file->getParentFolder(),
165 self::COMMAND_FILE_RENAME,
166 $combinedFileIdentifier
174 public function onPreFileReplace(FileInterface $file,
string $localFilePath): void
177 $file->getParentFolder(),
182 self::COMMAND_FILE_REPLACE,
183 $combinedFileIdentifier
192 public function onPreFileMove(FileInterface $file, FolderInterface $targetFolder,
string $targetFileName): void
199 && $this->isFormDefinition($targetFileName)
200 || $this->isRecycleFolder($targetFolder)) {
210 self::COMMAND_FILE_MOVE,
211 $combinedFileIdentifier
222 $file->getParentFolder(),
227 self::COMMAND_FILE_SET_CONTENTS,
228 $combinedFileIdentifier,
241 string $combinedFileIdentifier,
242 string $content =
null
248 $definedInvocation = $this->definedInvocations[$command] ??
null;
250 if ($definedInvocation ===
true) {
254 if ($definedInvocation ===
false) {
255 throw new FormDefinitionPersistenceException(
257 'Persisting form definition "%s" is denied',
258 $combinedFileIdentifier
264 $contentSignature =
null;
265 if ($content !==
null) {
270 $combinedFileIdentifier,
274 if ($allowedInvocationIndex ===
null) {
275 throw new FormDefinitionPersistenceException(
277 'Persisting form definition "%s" is denied',
278 $combinedFileIdentifier
283 unset($this->allowedInvocations[$allowedInvocationIndex]);
294 string $combinedFileIdentifier,
295 string $contentSignature =
null
297 foreach ($this->allowedInvocations as $index => $allowedInvocation) {
299 $command === $allowedInvocation[
'command']
300 && $combinedFileIdentifier === $allowedInvocation[
'combinedFileIdentifier']
301 && $contentSignature === $allowedInvocation[
'contentSignature']
318 $folder->getStorage()->getUid(),
319 $folder->getIdentifier(),
342 $role = $folder->getStorage()->getRole($folder);