Skip to content

Instantly share code, notes, and snippets.

@robertbasic
Created October 9, 2012 19:23
Show Gist options
  • Select an option

  • Save robertbasic/3860865 to your computer and use it in GitHub Desktop.

Select an option

Save robertbasic/3860865 to your computer and use it in GitHub Desktop.
public function createServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName)
{
$namespace = substr($requestedName, 0, strpos($requestedName, 'ModelTable'));
$classname = substr($requestedName, strlen($namespace . 'ModelTable'));
$class = ucfirst($namespace) . "\\Model\\Table\\" . ucfirst($classname);
$dbAdapter = $serviceLocator->get('dbAdapter');
$table = new $class($dbAdapter);
return $table;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment