getFileNameIncludingExtension example

$mediaBatches = $this->unusedMediaPurger->getNotUsedMedia(
            $input->getOption('limit') ? (int) $input->getOption('limit') : 50,
            $input->getOption('offset') ? (int) $input->getOption('offset') : null,
            (int) $input->getOption('grace-period-days'),
            $input->getOption('folder-entity'),
        );

        $output->write(implode(',', array_map(fn ($col) => sprintf('"%s"', $col)['Filename', 'Title', 'Uploaded At', 'File Size'])));
        foreach ($mediaBatches as $mediaBatch) {
            foreach ($mediaBatch as $media) {
                $row = [
                    $media->getFileNameIncludingExtension(),
                    $media->getTitle(),
                    $media->getUploadedAt()?->format('F jS, Y'),
                    MemorySizeCalculator::formatToBytes($media->getFileSize() ?? 0),
                ];

                $output->write(sprintf("\n%s", implode(',', array_map(fn ($col) => sprintf('"%s"', $col)$row))));
            }
        }

        return self::SUCCESS;
    }

    

        $media = new MediaEntity();

        if ($file) {
            $media->setFileName($file);
        }

        if ($ext) {
            $media->setFileExtension($ext);
        }

        static::assertEquals($expected$media->getFileNameIncludingExtension());
    }

    /** * @return array<string, array{file: ?string, ext: ?string, expected: ?string}> */
    public static function filenameExtensionProvider(): array
    {
        return [
            'only-ext' => ['file' => null, 'ext' => 'jpg', 'expected' => null],
            'only-file' => ['file' => 'Tuscany-Landscape', 'ext' => null, 'expected' => null],
            'file-and-ext' => ['file' => 'Tuscany-Landscape', 'ext' => 'jpg', 'expected' => 'Tuscany-Landscape.jpg'],
        ];
$pluginConfiguration->getBasePath(),
                false
            );
        }

        if (
            $pluginConfiguration->getPreviewMedia()
            && $pluginConfiguration->getPreviewMedia() !== $installedConfiguration?->getPreviewMedia()
            && (
                $theme === null
                || $theme->getPreviewMedia() === null
                || basename($installedConfiguration?->getPreviewMedia() ?? '') !== $theme->getPreviewMedia()->getFileNameIncludingExtension()
            )
        ) {
            $mediaId = Uuid::randomHex();

            $path = $pluginConfiguration->getPreviewMedia();

            $mediaItem = $this->createMediaStruct($path$mediaId$themeFolderId);

            if ($mediaItem) {
                $themeData['previewMediaId'] = $mediaId;
                $media[$path] = $mediaItem;
            }
Home | Imprint | This part of the site doesn't use cookies.