Skip to content
Snippets Groups Projects

Issue #3196084: Added function to access the URL object.

Open sayan_k_dutta requested to merge issue/flag-3196084:3196084-provide-a-method into 8.x-4.x
Files
3
@@ -92,12 +92,8 @@ abstract class ActionLinkTypeBase extends PluginBase implements ActionLinkTypePl
@@ -92,12 +92,8 @@ abstract class ActionLinkTypeBase extends PluginBase implements ActionLinkTypePl
}
}
$action = $this->getAction($flag, $entity);
$action = $this->getAction($flag, $entity);
$url = $this->getUrl($action, $flag, $entity);
$url->setRouteParameter('view_mode', $view_mode);
$url->setOption('query', ['destination' => $this->getDestination()]);
$title = $flag->getShortText($action);
$title = $flag->getShortText($action);
return Link::fromTextAndUrl($title, $this->getAsUrl($flag, $entity, $view_mode));
return Link::fromTextAndUrl($title, $url);
}
}
/**
/**
@@ -116,9 +112,7 @@ abstract class ActionLinkTypeBase extends PluginBase implements ActionLinkTypePl
@@ -116,9 +112,7 @@ abstract class ActionLinkTypeBase extends PluginBase implements ActionLinkTypePl
}
}
if ($access->isAllowed()) {
if ($access->isAllowed()) {
$url = $this->getUrl($action, $flag, $entity);
$url = $this->getAsUrl($flag, $entity, $view_mode);
$url->setRouteParameter('destination', $this->getDestination());
$url->setRouteParameter('view_mode', $view_mode);
$render = [
$render = [
'#theme' => 'flag',
'#theme' => 'flag',
'#flag' => $flag,
'#flag' => $flag,
@@ -152,6 +146,17 @@ abstract class ActionLinkTypeBase extends PluginBase implements ActionLinkTypePl
@@ -152,6 +146,17 @@ abstract class ActionLinkTypeBase extends PluginBase implements ActionLinkTypePl
return $render;
return $render;
}
}
 
/**
 
* {@inheritdoc}
 
*/
 
public function getAsUrl(FlagInterface $flag, EntityInterface $entity, ?string $view_mode = NULL) {
 
$action = $this->getAction($flag, $entity);
 
$url = $this->getUrl($action, $flag, $entity);
 
$url->setRouteParameter('view_mode', $view_mode);
 
$url->setOption('query', ['destination' => $this->getDestination()]);
 
return $url;
 
}
 
/**
/**
* Helper method to get the next flag action the user can take.
* Helper method to get the next flag action the user can take.
*/
*/
Loading