Skip to content

Instantly share code, notes, and snippets.

@rlandas
Created November 16, 2012 22:18
Show Gist options
  • Save rlandas/4091394 to your computer and use it in GitHub Desktop.
Save rlandas/4091394 to your computer and use it in GitHub Desktop.
ZF2: Extract (get) the module namespace from the requestedName in AbstractFactory class
namespace MyModule\Factory;
use Zend\ServiceManager\AbstractFactoryInterface;
class SomeClassFactory implements AbstractFactoryInterface {
// ... some other code
/**
* Determine if we can create a service with name
*
* @param ServiceLocatorInterface $serviceLocator
* @param $name
* @param $requestedName
* @return bool
*/
public function canCreateServiceWithName (ServiceLocatorInterface $serviceLocator, $name, $requestedName)
{
$namespace = substr($requestedName, 0, strpos($requestedName, '\\'));
return true;
}
// ... some other code
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment