private function createInstantiationListener(EventManagerInterface $eventManager)
    {
        return function ($proxy, $instance, $method, $params, $returnValue) use ($eventManager) {
            $eventName = ('create' === $method)
                ? ServiceManagerEvent::EVENT_SERVICEMANAGER_CREATE
                : ServiceManagerEvent::EVENT_SERVICEMANAGER_GET;

            $serviceName = $params['name'];

            if (is_array($serviceName)) {
                list($canonicalName, $serviceName) = $serviceName;
            } else {
                $canonicalName = strtolower(
                    strtr($serviceName, array('-' => '', '_' => '', ' ' => '', '\\' => '', '/' => ''))
                );
            }

            $eventManager->trigger(new ServiceManagerEvent(
                $eventName,
                $proxy,
                $returnValue,
                $serviceName,
                $canonicalName
            ));
        };
    }