My First Zend Module Build... Need Help


(Sherwin Gaddis) #1

I need some help with my module build.
This module is to get billing information from the billing table for none Medicaid payments that need to be processed by a credit card.

This is the error I am receiving





Too few arguments to function CCPaymentManager\Model\CCPaymentManagerTable::__construct(), 0 passed in /var/www/html/t/interface/modules/zend_modules/module/CCPaymentManager/src/CCPaymentManager/Controller/CCPaymentManagerController.php on line 35 and exactly 1 expected

I can’t see to find what argument it is looking for. I have searched the other modules but can’t see what is missing.

Thanks to ZH for posting this PDF
Zend Module Installer - OpenEMR Development - OpenEMR Community

@zhopenemr @ZHHealthcare @growlingflea @Rayaz @rmagauran

(Daniel) #2

I’ve seen this before. In PHP if you have a function that is declared with three arguments, i.e.
function foo($arg1, $arg2, $arg3) //function declaration

depending on the version calling the function

foo($arg1, $arg2) //function call

would be OK. With >= php7.2 you will need to go to the function call and put a null or blank. for example, replace

foo($arg1, $arg2) //function call that brings error in newest php versions


foo($arg1, $arg2, ‘’) //fixing the function call to prevent the error.

(Sherwin Gaddis) #3

Here is the working module. I need to take the $995 course that ZF offers. I really need to learn the details is what this exercise taught me. I can wing it but that is not good enough to excel.

(Jerry P) #4

I’d recommend learning Symfony, ES6 and web components/shadow dom etc. That’d be one dollar and 2 cents please. :open_hands:

(Sherwin Gaddis) #5

What is your cashapp ID?

(Stephen Nielson) #6

@juggernautsei Not sure if you saw my pull request and since it’s in the forum I wanted to throw this out there for other’s to reference with your question. This problem arose because the dependency was not being injected properly. That is why the constructor was failing to build because it expected the table adapter but the CCPaymentManagerController.php was creating the CCPaymentManagerTable object directly without sending in the payment adapter.

ZendFramework, Symfony, Laravel are frameworks that all use a design pattern called Dependency Injection so you can easily wire up different configurations of your objects as well as unit test them with greater isolation and control. In this case attempting to construct the object directly using ‘new’ won’t work as it needs the dependencies injected. The pull request I mention above should fix the wiring problem.

(Sherwin Gaddis) #7

You are right in the words that you are using. I kinda figure it out as I was stumbling through the ACL code because I knew that the ACL has to access the existing database table. So deconstructing what they did, I found the constructor you are referring to. Once I found where they were building the connector (lower in the ACL controller) I copied that and it fixed the issue.

That is why I said I need to learn why. Copying and mimicking code is one thing. Knowing why is quite another.

(Stephen Nielson) #8

Here is a great resource read for those wanting to understand how dependency injection and service locators work from Martin Fowler (pretty renowned design pattern and software engineering guru).