Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save DanyelMorales/03adfd367f23576f7b53081e5b5dc83b to your computer and use it in GitHub Desktop.
Save DanyelMorales/03adfd367f23576f7b53081e5b5dc83b to your computer and use it in GitHub Desktop.
Get RouteMatch object from ServiceManager inside a factory in ZendFramework 2
<?php
// ...
public function createService(ServiceLocatorInterface $serviceLocator)
{
$sm = $serviceLocator->getServiceLocator();
$routeMatch = $sm->get('application')->getMvcEvent()->getRouteMatch();
$param = $routeMatch->getParam('id', 0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment