0

I created a module for Drupal 8.6. I have a variable $store_id with the id of a store

How do I insert $store_id into the folowing link:

Url::fromUri('internal:/store/?????/cgv', $attributes)

For example when $store_id = 6 I want to get:

internal:/store/6/cgv as the argument to Url::fromUri

George
  • 2,860
  • 18
  • 31
553aa08930
  • 33
  • 7
  • Doesn't `Url::fromUri("internal:/store/$store_id/cgv", $attributes)` work? Note you need to change to `"` from `'` to get variable substitution. – Nick Nov 06 '18 at 00:34
  • @Nick Super, thank you it works ;-) I have an identical question, can be with you the answer https://stackoverflow.com/questions/53155040/why-are-characters-inserted-in-my-php-link she is different because she uses `Link::createFromRoute` – 553aa08930 Nov 06 '18 at 00:41
  • Sorry I don't know Drupal well enough to be able to answer your other question. Good luck. – Nick Nov 06 '18 at 01:04
  • Rephrased the question a little to clarify what is required – George Nov 06 '18 at 08:56

1 Answers1

-1

As per Nick's comment, just change it to:

Url::fromUri("internal:/store/$store_id/cgv", $attributes)

George
  • 2,860
  • 18
  • 31