Get controller data from inside a snippet component

This may not be the most common question to ask but I’m using a snippet component and need to get controller data in the render function.

Because controllers are loaded first they are somewhere in the memory, I just need to get them out.

I tried this:

$test = kirby()->registry->get('controller', 'category-custom');

The result I got was:

Closure Object
(
[parameter] => Array
(
[$site] => <required>
[$pages] => <required>
[$page] => <required>
))

I probably need to send the page or site etc but I could not figure out how to send it. It’s a closure object.

I figured it out:

$controller = kirby()->registry->get('controller', 'category-custom');
	
if(is_a($controller, 'Closure')) {
	$controller_data = (array)call_user_func_array($controller, array(
		site(),
		site()->children(),
		page(),
	));
}

print_r($controller_data);