Skip to content
Snippets Groups Projects
Commit 1e68dcae authored by Vladimir Roudakov's avatar Vladimir Roudakov
Browse files

Issue #3166139 by owenbush, isholgueras: Sometimes there is no route object to...

Issue #3166139 by owenbush, isholgueras: Sometimes there is no route object to pass to TitleResolver::getTitle()
parent 063505cf
Branches
Tags
No related merge requests found
......@@ -189,8 +189,15 @@ class SharethisWidgetBlock extends BlockBase implements ContainerFactoryPluginIn
);
$mpath = $path_obj->toString();
}
$request = $this->requestStack->getCurrentRequest();
$title = $this->titleResolver->getTitle($request, $this->routeMatch->getRouteObject());
$title = $this->configFactory->get('system.site')->get('name');
$route_object = $this->routeMatch->getRouteObject();
if (!empty($route_object)) {
$title = $this->titleResolver->getTitle($request, $route_object);
}
$title = is_object($title) ? $title->getUntranslatedString() : $title;
$mtitle = ($this->configuration['sharethis_path'] == 'current') ? $title : $this->configFactory->get('system.site')
->get('name');
......
......@@ -140,7 +140,11 @@ class SharethisManager implements SharethisManagerInterface {
// Get an absolute path to the current page.
$m_path = $request->getUri();
$mtitle = $this->titleResolver->getTitle($request, $this->routeMatch->getRouteObject());
$mtitle = "";
$route_object = $this->routeMatch->getRouteObject();
if (!empty($route_object)) {
$mtitle = $this->titleResolver->getTitle($request, $route_object);
}
if (!empty($mtitle) && is_object($mtitle)) {
$m_title = $mtitle->getUntranslatedString();
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment