Programming Language PHP

Namespace Plank\Mediable\Exceptions

Class MediaUrlException

Method/Function generatorNotFound

Total Examples 1

1 code examples of PHP Plank\Mediable\Exceptions\MediaUrlException::generatorNotFound extracted from open source projects

Was this example useful?
0
                                                    /**
     * Get a UrlGenerator instance for a media.
     * @throws MediaUrlException If no generator class has been assigned for the media's disk's driver
     */
    public function create(Media $media): UrlGeneratorInterface
    {
        $driver = $this->getDriverForDisk($media->disk);
        if (array_key_exists($driver, $this->driver_generators)) {
            $class = $this->driver_generators[$driver];

            $generator = app($class);
            $generator->setMedia($media);

            return $generator;
        }

        throw MediaUrlException::generatorNotFound($media->disk, $driver);
    }