05.
kernel.controller Event & Controller Arguments
Keep on Learning!
If you liked what you've learned so far, dive in! Subscribe to get access to this tutorial plus video, code and script downloads.
If you liked what you've learned so far, dive in! Subscribe to get access to this tutorial plus video, code and script downloads.
Whoops, an error! Please, try again later.
2 Comments
return $this->mergeDefaults(array_replace($matches, array('_route' => 'genus_show')), array ( '_controller' => 'AppBundle\\Controller\\GenusController::showAction',))
Please, tell me, how: \\ transforms to: \ ?
If, let say :
protected function mergeDefaults($params, $defaults)
{
dump($defaults);die;
We get:
array:1 [▼
"_controller" => "AppBundle\Controller\GenusController::showAction"
]
Hey Andrew!
Yes, I can see why this might look confusing! Here is the reason: http://php.net/manual/en/language.namespaces.faq.php#language.namespaces.faq.quote
The problem is that \ is also the escaping character in PHP. When you have a string in single-quotes, that's no problem - the \ is not treated special in single quotes. But in double-quotes, you may need to double-escape the slash (i.e. \), else it may treat the next character like a special character. Even though this isn't a problem with single quotes, we often double-slash for consistency. Here's some code to back this up:
Cool question!
"Houston: no signs of life"
Start the conversation!