Answer the question
In order to leave comments, you need to log in
Explain the benefits of multiple abstractions using zfcUser as an example?
I can't figure out how to benefit from all of this. studied on this issue nemeryanno different information. I myself use OOP at the level of data grouping and the definition of common behavioral methods that I can use when inherited.
Well, I decided to use this module, please show me with a practical example what benefit can I get from what the authors have defined, various interfaces, implemented hydrators, mappers?
Well, for example, you need ajax authentication. my code (simplified)
public function loginAction() {
$user = $this->getServiceLocator()->get('some-service-for-make-sql-request')->search(['email'=>$_REQUEST['email'],'pwd'=>$_REQUEST['pwd']]); // service makes some crypt for 'pwd' before sql request
$result = $user ? ['message'=>'ok','userdata'=>$user] : ['message'=>'fail','userdata'=>$user];
return new JsonModel($result);
}
.....
$this->getRequest()->getPost()->set('identity', $data['identity']);
$this->getRequest()->getPost()->set('credential', $data['credential']);
$this->zfcUserAuthentication()->getAuthAdapter()->resetAdapters();
$this->zfcUserAuthentication()->getAuthService()->clearIdentity();
$adapter = $this->zfcUserAuthentication()->getAuthAdapter();
$adapter->prepareForAuthentication($this->getRequest());
$auth = $this->zfcUserAuthentication()->getAuthService()->authenticate($adapter);
if (!$auth->isValid()) {
......
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question