ensureFileNameIsUnique example

/** * @throws MediaException */
    public function persistFileToMedia(
        MediaFile $mediaFile,
        string $destination,
        string $mediaId,
        Context $context
    ): void {
        $currentMedia = $this->findMediaById($mediaId$context);
        $destination = $this->validateFileName($destination);
        $this->ensureFileNameIsUnique(
            $currentMedia,
            $destination,
            $mediaFile->getFileExtension(),
            $context
        );

        $this->validateFileExtension($mediaFile$mediaId$currentMedia->isPrivate());

        $this->removeOldMediaData($currentMedia$context);

        $mediaType = $this->typeDetector->detect($mediaFile);
        
Home | Imprint | This part of the site doesn't use cookies.