class LinkBindingFactory in Drupal 7 to 8/9 Module Upgrader 8
Factory class to create link bindings, depending on the source route's type.
Hierarchy
- class \Drupal\drupalmoduleupgrader\Routing\LinkBinding\LinkBindingFactory
Expanded class hierarchy of LinkBindingFactory
1 string reference to 'LinkBindingFactory'
1 service uses LinkBindingFactory
File
- src/
Routing/ LinkBinding/ LinkBindingFactory.php, line 12
Namespace
Drupal\drupalmoduleupgrader\Routing\LinkBindingView source
class LinkBindingFactory {
/**
* @var \Drupal\Component\Plugin\PluginManagerInterface
*/
private $linkManager;
public function __construct(PluginManagerInterface $link_manager) {
$this->linkManager = $link_manager;
}
/**
* Factory method. Returns a link binding object appropriate for the source link type.
*
* @param \Drupal\drupalmoduleupgrader\Routing\Drupal7\RouteWrapper $source
* The source (Drupal 7) route.
* @param \Drupal\drupalmoduleupgrader\Routing\Drupal8\RouteWrapper $destination
* The destination (Drupal 8) route.
*
* @return mixed
* A link binding object; either an instance of this class or a subclass thereof.
*/
public function create(Drupal7Route $source, Drupal8Route $destination) {
if ($source
->isLink()) {
return new MenuLinkBinding($source, $destination);
}
elseif ($source
->isLocalTask() || $source
->isDefaultLocalTask()) {
return new LocalTaskLinkBinding($source, $destination, $this->linkManager);
}
elseif ($source
->isLocalAction()) {
if ($source
->isContextualLink()) {
return new LinkBinding($source, $destination);
}
else {
return new LocalActionLinkBinding($source, $destination);
}
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
LinkBindingFactory:: |
private | property | ||
LinkBindingFactory:: |
public | function | Factory method. Returns a link binding object appropriate for the source link type. | |
LinkBindingFactory:: |
public | function |