public function UrlBag::setAlias in Mini site 8
Set alias.
Note that this will "guess" different pieces of the url "bag" based on the currently set URI.
Parameters
string $alias: An alias to set.
Throws
\Drupal\minisite\Exception\UrlBagException If provided alias does not contain correct URI set in this bag.
File
- src/
UrlBag.php, line 132
Class
- UrlBag
- Class UrlBag.
Namespace
Drupal\minisiteCode
public function setAlias($alias) {
$path_in_archive = $this
->getPathInArchive();
if (strpos($alias, $path_in_archive) === FALSE) {
throw new UrlBagException('Provided alias does not contain correct URI');
}
$parent_alias = str_replace($path_in_archive, '', $alias);
$parent_alias_parts = array_filter(explode('/', $parent_alias));
// Remove root dir.
array_pop($parent_alias_parts);
$this
->setParentAlias(implode('/', $parent_alias_parts));
}