- Issue created by @reszli
- Open on Drupal.org →Core: 10.0.7 + Environment: PHP 7.4 & MySQL 5.7last update
over 1 year ago Waiting for branch to pass - @reszli opened merge request.
- Status changed to Needs review
over 1 year ago 2:16pm 21 July 2023
I'm trying to move the ShURLy links to a different path / menu structure as requested by a customer.
But the views field plugins use hard-coded path with Url::fromUri() which will not work once I override the path of the routes.
namespace Drupal\mymodule\Routing;
use Drupal\Core\Routing\RouteSubscriberBase;
use Symfony\Component\Routing\RouteCollection;
/**
* Listens to the dynamic route events.
*/
class RouteSubscriber extends RouteSubscriberBase {
/**
* {@inheritdoc}
*/
public function alterRoutes(RouteCollection $collection) {
if ($route = $collection->get('shurly.create')) {
$route->setPath('/admin/content/shurly');
}
if ($route = $collection->get('shurly.edit')) {
$route->setPath('/admin/content/shurly/edit/{rid}');
}
if ($route = $collection->get('shurly.deactivate')) {
$route->setPath('/admin/content/shurly/deactivate/{rid}');
}
}
}
edit and deactivate links will not work anymore on /admin/shurly page
use Url::fromRoute() instead of Url::fromUri()
also, use dependency injection for services
create a patch
none
none
none
Needs review
1.0
Code