generatePathHash example



    /** * @throws MediaException */
    public function getRelativeMediaUrl(MediaEntity $media): string
    {
        $this->validateMedia($media);

        return $this->toPathString([
            'media',
            $this->pathnameStrategy->generatePathHash($media),
            $this->pathnameStrategy->generatePathCacheBuster($media),
            $this->pathnameStrategy->generatePhysicalFilename($media),
        ]);
    }

    /** * @throws MediaException */
    public function getAbsoluteMediaUrl(MediaEntity $media): string
    {
        return $this->filesystem->publicUrl($this->getRelativeMediaUrl($media));
    }


    private function getMd5PathnameStrategy(): FilenamePathnameStrategy
    {
        return $this
            ->getContainer()
            ->get(FilenamePathnameStrategy::class);
    }

    private function assertHashGenerator(PathnameStrategyInterface $strategy, MediaEntity $media, int $length): void
    {
        $encoded = $strategy->generatePathHash($media);

        static::assertIsString($encoded);
        static::assertSame($encoded$strategy->generatePathHash($media));
        static::assertStringEndsNotWith('/', $encoded);
        static::assertStringStartsNotWith('/', $encoded);
        static::assertSame($lengthmb_strlen($encoded));
    }

    private function assertCacheBusterGenerator(PathnameStrategyInterface $strategy): void
    {
        static::assertNull($strategy->generatePathCacheBuster($this->getMediaWithManufacturer()));
        
Home | Imprint | This part of the site doesn't use cookies.