Welcome Guest, Not a member yet? Register   Sign In
Is my library function from common file a good practice ?
#4

(This post was last modified: 07-01-2020, 03:28 PM by ivantcholakov.)

Try this

Code:
$this->shopLibrary = \Config\Services::shopLibrary();

This way you will have a singleton. And since you have an instance, avoid using static methods, because they will force you to remember and recall what is the full namespace of the library, which is not convenient.

And we all know it is a library, maybe just "shop" would be nicer than "shopLibrary". Edit: Or "shopping" if you want to avoid a future name collision.
Reply


Messages In This Thread
RE: Is my library function from common file a good practice ? - by ivantcholakov - 07-01-2020, 03:16 PM



Theme © iAndrew 2016 - Forum software by © MyBB