getBody(), true); return new CreateCommand( $parsedBody['classId'] ?? $parsedBody['classUri'] ?? MediaService::ROOT_CLASS_URI, $parsedBody['name'] ?? null, $parsedBody['languageId'] ?? $parsedBody['languageUri'] ?? null ); } public function makePatchCommand(string $id, string $body, User $user): PatchCommand { $name = hash('md5', $id); $file = $this->getDirectory()->getFile($name); $file->put($body); return new PatchCommand( $id, $this->getSerializer()->serialize($file), $user->getIdentifier() ); } private function getDirectory(): Directory { if (is_null($this->directory)) { /** @var FileSystemService $fileSystemService */ $fileSystemService = $this->getServiceLocator()->get(FileSystemService::SERVICE_ID); $this->directory = $fileSystemService->getDirectory(self::DEFAULT_DIRECTORY); } return $this->directory; } private function getSerializer(): FileReferenceSerializer { return $this->getServiceLocator()->get(FileReferenceSerializer::SERVICE_ID); } }