zend framework2 - ZF2 Error trying to use ZfcUser\Service\User::register method to register User from another controller -


I want to register a user using ZfcUser and I want to add the database to the model in one format. So I increased the registration form and validated the data by postdata in different ways, like this:

  Namespace App \ Controller; Zend \ Mvc \ Controller \ AbstractActionController; Use Zend \ Form; Use Zend \ View \ Model \ ViewModel; Use the application \ model \ writer; Application \ form \ AuthorForm; Application \ form \ Author2Form; Use the ZfcUser \ Service \ user as a user service; Category Admin Controller AbstractActionController {Protected $ authorTable; Protected $ registerForm; Protected $ userService; Public function author () ($ author = new author); $ form = $ this-> getRegisterForm (); $ formRegister = $ this-> getServiceLocator () - & gt; receive ('zfcuser_register_form') ; $ formAuthor = New Author2Form (); $ request = $ this-> getRequest (); $ service = $ this- & gt; getUserService (); if ($ request-> ispost ()) {$ post $ request- & gt; getPost (); $ post ['email'] = $ post ['mail']; $ request & gt; setPost ($ post); $ formAuthor- & gt; setValidationGroup ('array $ FormRegister- & gt; setValidationGroup (array ('email', 'password', 'verify password')); $ form & gt; ; SetData ($ request & gt; getPost ()); $ FormAuthor-> setData ($ request & gt; getPost ()); $ FormRegister- & gt; setData ($ request & gt; getPost ()); if ($ formAuthor-> gt; ; isValid () & amp; amp; amp; form; form; Registry- & gt; isValid ()) {$ Service-> Register ($ formRegister- & gt; getData ()); $ author- & gt; exchangeArray ($ formAuthor- & gt; GetData ()); $ This- & gt; getAuthorTable () - & gt; SaveAuthor ($ author); Return $ this - & gt; Redirect () - & gt; Refresh (); }} New ViewModel (array ('authorList' =>> $ this-> getAuthorTable () -> Fatch ALL (), 'authorForm' = & gt; $ form,)); } Public function getRegisterForm () (if (! $ This-> RegisterForm) {$ this-> setRegisterForm ($ this- & amp; getServiceLocator () - & gt; Get ('app \ form \ author form '));} $$ Return-> Register Form;} Public Function Setgearform (AuthorForm $ RegisterForm) {$ this-> RegisterForm = $ RegisterForm;} Public Function getUserService () {If (! $ This- & gt; User service) {$ this-> User service = New UserService ();} Return $ this- & gt; User service;} Public The function set user service (user service $ user service) {$ this-> User service = $ userService; $ this return;}}   

In Module.php I under the factory The following code added:

  'application \ form \ authorForm' => function ($ sm) {$ option = $ sm-> gain ('zfcuser_module_options'); $ form = New author form ('writer form', $ option); return form $;},   

I am able to validate both forms and then see the following error:

< p> Fatal error: Call a member function () / var / www / * / em> / vendor / zf-commons / zfc-user / src / ZfcUser / Service / User.php non-object

This will be the following method:

  public function getOptions () {if (! $ $ -> this option-> option instancesof UserServiceOptionsInterface) {$ this-> setOptions ($ this- & gt; getServiceManager () - & gt; Mill ('zfcuser_module_options')); } $ This- & gt; Return options;   

I have tried many things to complete this already and I do not know what to try now ..

Does anyone help me Could?

Put it in your controller:

  $ service-> ; setServiceManager ($ this - & gt; getServiceLocator ());    

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -