You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 8, 2021. It is now read-only.
if i want to create a custom adapter into Module.php i get an error: cannot create service with the same name.
It's because BjyProfiler contain a custom config who create a factory by default.
I suggest to clear the config file and just make its content optionnal.
There is an example who can generate the error:
i'm building a multi website application. Each website is a module and need to get it's own adapter, so i did that:
classModule
{
publicfunctiononBootstrap(MvcEvent$e)
{
$eventManager = $e->getApplication()->getEventManager();
$moduleRouteListener = newModuleRouteListener();
$moduleRouteListener->attach($eventManager);
$this->bootstrapDb($e);
}
publicfunctionbootstrapDb(MvcEvent$e)
{
$e->getApplication()->getEventManager()->getSharedManager()
->attach('Zend\Mvc\Controller\AbstractActionController', 'dispatch', function ($e) {
// Comment this line to get the error$e->getApplication()->getServiceManager()->setAllowOverride(true);
/** @var AbstractActionController $controller */$controller = $e->getTarget();
$controllerClass = get_class($controller);
$moduleNamespace = substr($controllerClass, 0, strpos($controllerClass, '\\'));
$dbConfig = $e->getApplication()->getServiceManager()->get('config')['db'];
// Global Application config$config = array_merge(
array_intersect_key(
$dbConfig,
array_flip(array('username', 'password', 'driver', 'dsn', 'options'))
),
$dbConfig[strtolower($moduleNamespace)]
);
$controller->getServiceLocator()->setFactory(
'Zend\Db\Adapter\Adapter',
function ($sm) use ($config) {
$adapter = new \BjyProfiler\Db\Adapter\ProfilingAdapter($config);
$adapter->setProfiler(new \BjyProfiler\Db\Profiler\Profiler);
if (isset($config['options']) && is_array($config['options'])) {
$options = $config['options'];
} else {
$options = array();
}
$adapter->injectProfilingStatementPrototype($options);
return$adapter;
}
);
}, 100);
}
}
So i have to set AllowOverride to true in serviceManager to get it working
The text was updated successfully, but these errors were encountered:
if i want to create a custom adapter into Module.php i get an error: cannot create service with the same name.
It's because BjyProfiler contain a custom config who create a factory by default.
I suggest to clear the config file and just make its content optionnal.
There is an example who can generate the error:
i'm building a multi website application. Each website is a module and need to get it's own adapter, so i did that:
So i have to set AllowOverride to true in serviceManager to get it working
The text was updated successfully, but these errors were encountered: