You are here

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

Expanded class hierarchy of LinkBindingFactory

1 file declares its use of LinkBindingFactory
Links.php in src/Plugin/DMU/Converter/Links.php
1 string reference to 'LinkBindingFactory'
drupalmoduleupgrader.services.yml in ./drupalmoduleupgrader.services.yml
drupalmoduleupgrader.services.yml
1 service uses LinkBindingFactory
drupalmoduleupgrader.link_binding in ./drupalmoduleupgrader.services.yml
Drupal\drupalmoduleupgrader\Routing\LinkBinding\LinkBindingFactory

File

src/Routing/LinkBinding/LinkBindingFactory.php, line 12

Namespace

Drupal\drupalmoduleupgrader\Routing\LinkBinding
View 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

Namesort descending Modifiers Type Description Overrides
LinkBindingFactory::$linkManager private property
LinkBindingFactory::create public function Factory method. Returns a link binding object appropriate for the source link type.
LinkBindingFactory::__construct public function