I am trying to work my path through the source of DoctrineModule for Zend2, since comprehensive documentation for beginners is virtually non-existent.
In there, I found a custom authentication adapter, ObjectRepository. This class takes an object of DoctrineModule\Options\Authentication. All I need to set the credentialCallable
value to a custom, BCrypt-based function.
I wrote a class for my controllers to wrap the adapter:
namespace User\Controller\Plugin;
class UserAuthentication extends AbstractPlugin {
protected $_authAdapter = null;
protected $_authService = null;
public function __construct($authAdapter) {
$this->setAuthAdapter($authAdapter);
}
// More setters/getters
}
Now I need to configure the module in a way that this call here will give me a valid instance.
$uAuth = $this->getServiceLocator()->get('User\Controller\Plugin\UserAuthentication');
So naturally, I will have to work with the module condifguration. But here I am completely and entirely stuck, as I could not find any hint on how to create the instances of the classes properly. This is what I came up with so far:
return array(
'di' => array(
'instance' => array(
'User\Event\Authentication' => array(
'parameters' => array(
'userAuthenticationPlugin' => 'User\Controller\Plugin\UserAuthentication',
),
),
'User\Controller\Plugin\UserAuthentication' => array(
'parameters' => array(
'authAdapter' => 'DoctrineModule\Authentication\Adapter\ObjectRepository'
),
),
),
),
'service_manager' => array(
'factories' => array(
'DoctrineModule\Authentication\Adapter\ObjectRepository' => function ($sm) {
/// ????
},
'DoctrineModule\Options\Authentication' => function($sm) {
/// ????
},
),
),
);
So I have no idea what to fill in there, or if this is even the correct way to go. Perhaps I go the wrong path entirely, since when executing this, I get:
An abstract factory could not create an instance of usercontrollerpluginuserauthentication(alias: User\Controller\Plugin\UserAuthentication).
I appreciate any ideas and hints. And please don't direct me to ZfcUser
or similar, I want/need to implement this myself.