How to get parameters from url in a component?

netteman
Member | 122
+
0
-

Hi,

I figured out I can use Nette\Http\Request in a component to get a parameter from URL.

public function __construct(\Nette\Http\Request $httpRequest){
    $this->httpRequest = $httpRequest;
	}
	...
	$variable = $this->httpRequest->getQuery('a-parameter-from-url');

Is there a better/safer way how to get the parameters? I'd like to avoid getting my parameters in a presenter, passing them to a template and then passing them to a component

{control componentName $a, $b, $c, $d, $e...}

Thanks :)

David Matějka
Moderator | 6445
+
+2
-

You should pass them to the component from createComponent method (usign setter or using factory method)

netteman
Member | 122
+
0
-

David Matějka wrote:

You should pass them to the component from createComponent method (usign setter or using factory method)

Thanks :)