The LeaveRedirectDefunctRouteHandler will automatically update old routes
to redirect the browser to the route which has replaced it. This effectively
means you can rename your objects without worrying about users receiving HTTP
404 responses.

The handler will replace the old route with a RedirectRoute at the same
path.

namespaceSymfony\Cmf\Component\RoutingAuto\DefunctRouteHandler;useSymfony\Cmf\Component\RoutingAuto\DefunctRouteHandlerInterface;useSymfony\Cmf\Component\RoutingAuto\UriContextCollection;useSymfony\Cmf\Component\RoutingAuto\Adapter\AdapterInterface;classRemoveDefunctRouteHandlerimplementsDefunctRouteHandlerInterface{protected$adapter;publicfunction__construct(AdapterInterface$adapter){$this->adapter=$adapter;}publicfunctionhandleDefunctRoutes(UriContextCollection$uriContextCollection){// get all routes that refer to the subject object$referringAutoRouteCollection=$this->adapter->getReferringAutoRoutes($uriContextCollection->getSubjectObject());foreach($referringAutoRouteCollectionas$referringAutoRoute){// if the route no longer existsif(false===$uriContextCollection->containsAutoRoute($referringAutoRoute)){// get the new route$newRoute=$uriContextCollection->getAutoRouteByTag($referringAutoRoute->getAutoRouteTag());// migrate the children to the new route$this->adapter->migrateAutoRouteChildren($referringAutoRoute,$newRoute);// remove the old route$this->adapter->removeAutoRoute($referringAutoRoute);}}}}

All defunct route handlers should be tagged with
cmf_routing_auto.defunct_route_handler. The above class is registered as following: