3 namespace Drupal\settings_tray\RouteProcessor;
5 use Drupal\Core\Render\BubbleableMetadata;
6 use Drupal\Core\RouteProcessor\OutboundRouteProcessorInterface;
7 use Drupal\Core\Routing\RouteProviderInterface;
8 use Symfony\Component\Routing\Route;
11 * Processes the Block entity off-canvas form BC route.
15 class BlockEntityOffCanvasFormRouteProcessorBC implements OutboundRouteProcessorInterface {
20 * @var \Drupal\Core\Routing\RouteProviderInterface
22 protected $routeProvider;
25 * Constructs a BlockEntityOffCanvasFormRouteProcessorBC object.
27 * @param \Drupal\Core\Routing\RouteProviderInterface $route_provider
30 public function __construct(RouteProviderInterface $route_provider) {
31 $this->routeProvider = $route_provider;
37 public function processOutbound($route_name, Route $route, array &$parameters, BubbleableMetadata $bubbleable_metadata = NULL) {
38 if ($route_name === 'entity.block.off_canvas_form') {
39 $redirected_route_name = 'entity.block.settings_tray_form';
40 @trigger_error(sprintf("The '%s' route is deprecated since version 8.5.x and will be removed in 9.0.0. Use the '%s' route instead.", $route_name, $redirected_route_name), E_USER_DEPRECATED);
41 static::overwriteRoute($route, $this->routeProvider->getRouteByName($redirected_route_name));
46 * Overwrites one route's metadata with the other's.
48 * @param \Symfony\Component\Routing\Route $target_route
49 * The route whose metadata to overwrite.
50 * @param \Symfony\Component\Routing\Route $source_route
51 * The route whose metadata to read from.
53 * @see \Symfony\Component\Routing\Route
55 protected static function overwriteRoute(Route $target_route, Route $source_route) {
56 $target_route->setPath($source_route->getPath());
57 $target_route->setDefaults($source_route->getDefaults());
58 $target_route->setRequirements($source_route->getRequirements());
59 $target_route->setOptions($source_route->getOptions());
60 $target_route->setHost($source_route->getHost());
61 $target_route->setSchemes($source_route->getSchemes());
62 $target_route->setMethods($source_route->getMethods());