I would like to include / decrypt the parameters (e.g. ID) in the URL / route automatically , for example:
domain.com/item/show/1 should look like domain.com/item/show/uj7hs2 .
Current (pseudo) code
public function myControllerFunctionAction() { // ... $id = $this->get('my.crypt')->encrypt($item->getId()); return $this->redirectToRoute('routeTo_myOtherControllerAction', array('id' => $id)); } public function myOtherControllerFunctionAction($id) { $id = $this->get('my.crypt')->decrypt($id); // decrypt $item = $this->get('my.repository')->find($id); // ... }
I would like to avoid manual en / decrypting .
Something like this would be perfect:
# routing.yml routeTo_myOtherControllerAction: path: /item/show/{id} defaults: { _controller: appBundle:Items:show } options: crypt_auto: true crypt_method: %default_crypt_method%
I have not yet found a solution other than my service. Any ideas?
Thanks in advance!
Mr. B. source share