/** * {@inheritdoc} */ public function getUrl() { if (!$this->isPubliclyAccessible()) { throw MediaUrlException::cloudMediaNotPubliclyAccessible($this->media->disk); } return $this->filesystem->disk($this->media->disk)->url($this->media->getDiskPath()); }
/** * Get the path to relative to the webroot. * @return string * @throws \Plank\Mediable\Exceptions\MediaUrlException If media's disk is not publicly accessible */ public function getPublicPath() { if (!$this->isPubliclyAccessible()) { throw MediaUrlException::mediaNotPubliclyAccessible($this->getAbsolutePath(), public_path()); } if ($this->isInWebroot()) { $path = str_replace(public_path(), '', $this->getAbsolutePath()); } else { $path = rtrim($this->getDiskConfig('prefix', 'storage'), '/') . '/' . $this->media->getDiskPath(); } return $this->cleanDirectorySeparators($path); }
/** * Verify that a class name is a valid generator. * @param string $class * @return void * @throws \Plank\Mediable\Exceptions\MediaUrlException If class does not exist or does not implement `UrlGenerator` */ protected function validateGeneratorClass($class) { if (!class_exists($class) || !is_subclass_of($class, UrlGeneratorInterface::class)) { throw MediaUrlException::invalidGenerator($class); } }