RouteSubscriber.php in Menu Link Clone 8.3
File
src/Routing/RouteSubscriber.php
View source
<?php
namespace Drupal\menu_link_clone\Routing;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Routing\RouteSubscriberBase;
use Symfony\Component\Routing\RouteCollection;
class RouteSubscriber extends RouteSubscriberBase {
protected $entityTypeManager;
public function __construct(EntityTypeManagerInterface $entity_manager) {
$this->entityTypeManager = $entity_manager;
}
protected function alterRoutes(RouteCollection $collection) {
$menu = $this->entityTypeManager
->getDefinition('menu')
->id();
if ($menu) {
if ($route = $collection
->get("entity.{$menu}.clone_form")) {
$route
->setDefault('_form', '\\Drupal\\menu_link_clone\\Form\\EntityMenuLinkCloneForm');
}
}
}
}