So I got this in my routing.yml:
requirements:
var1: \d+
var2: \d+
Both are checked on their own and valid. I need to check the combination of the 2, since the combination is not always valid.
For this case I need to check the relation between 2 objects in the database, the first should be the parent of the second. I can do this in the controller, but I don't really like that implementation. Also, I need this same check for more than 1 route.
How would I add another requirement that checks the combination? Can I define a method in the controller class that would be called?
Or would the best solution be something like:
public function indexAction($var1, $var2)
{
$result = $this->checkRelation($var1, $var2);
if ($result) {
// return errorpage
return $result;
}
// ...
}
The final solution I went with was the following:
In all this is very similar to what I posted in my initial question.
When using the same checkRelation in multiple controllers it might be a good idea to move it (partially) to a repository-class or something similar to prevent duplication of code/logic.