public function Textimage::setTargetUri in Textimage 8.4
Same name and namespace in other branches
- 8.3 src/Textimage.php \Drupal\textimage\Textimage::setTargetUri()
Set image destination URI.
Parameters
string $uri: A valid URI.
Return value
$this
Overrides TextimageInterface::setTargetUri
File
- src/
Textimage.php, line 377
Class
- Textimage
- Provides a Textimage.
Namespace
Drupal\textimageCode
public function setTargetUri($uri) {
if ($this->uri) {
throw new TextimageException("URI already set");
}
if ($uri) {
if (!$this->streamWrapperManager
->isValidUri($uri)) {
throw new TextimageException("Invalid target URI '{$uri}' specified");
}
$dir_name = $this->fileSystem
->dirname($uri);
$base_name = $this->fileSystem
->basename($uri);
$valid_uri = $this
->createFilename($base_name, $dir_name);
if ($uri != $valid_uri) {
throw new TextimageException("Invalid target URI '{$uri}' specified");
}
$this
->setTargetExtension(pathinfo($uri, PATHINFO_EXTENSION));
$this
->set('uri', $uri);
$this
->set('caching', FALSE);
}
return $this;
}