Define node array id as parameter in routing Is that possible to send somehow an array of nids and automatically convert it into and array of nodes? Something like:

custom.custom_nodes:
  path: '/custom/{nodes}'
  defaults:
    _form: '\Drupal\custom\Form\CustomForm'
    _title_callback: '\Drupal\custom\Form\CustomForm::titleCallback'
    nodes: []
  requirements:
    _access: 'TRUE'


Then I call this: /custom/1+2+3

And I will get at the backend an array of loaded nodes, which id's is 1, 2, 3.

If yes, how do I need to separate the nids from eachother? (And what else do I need to do?) Are there any best practice right now for this? What do I need if I need just an array of ids?
A custom parameter converter would probably be the best solution.

It's quite easy to implement; + symbols tend to be quirky in URLs so this example uses commas instead:

MODULE/src/ParamConverter/NodesConverter.php

namespace Drupal\MODULE\ParamConverter;

use Drupal\Core\Entity\EntityTypeManagerInterface;
use Symfony\Component\Routing\Route;
use Drupal\Core\ParamConverter\ParamConverterInterface;

class NodesConverter implements ParamConverterInterface {

  protected $entityTypeManager;

  public function __construct(EntityTypeManagerInterface $entity_type_manager) {
    $this-&gt;entityTypeManager = $entity_type_manager;
  }

  public function convert($value, $definition, $name, array $defaults) {
    // Add whatever extra validation you feel is necessary here
    $nids = explode(',', $value);

    if (!empty($nids)) {
      return $this-&gt;entityTypeManager-&gt;getStorage('node')
        -&gt;loadMultiple($nids);
    }
  }

  public function applies($definition, $name, Route $route) {
    return !empty($definition['type']) &amp;&amp; $definition['type'] == 'nodes';
  }

}


MODULE/MODULE.services.yml:

services:
  module_nodes:
    class: Drupal\MODULE\ParamConverter\NodesConverter
    arguments: ['@entity_type.manager']
    tags:
      - { name: paramconverter }


MODULE/MODULE.routing.yml:

custom.custom_nodes:
  path: '/custom/{nodes}'
  defaults:
    _form: '\Drupal\custom\Form\CustomForm'
    _title_callback: '\Drupal\custom\Form\CustomForm::titleCallback'
    nodes: '[\d\,]+'
  requirements:
    _access: 'TRUE'
  options:
    parameters:
      nodes:
        type: 'nodes'


The regex for the route could probably be improved, the param could be made optional, etc; other than that it should work. The controller for the route at /custom/1,2,3 will receive an array of loaded nodes for the same IDs in the $nodes argument (or an empty/smaller array if none/only some were found).