Jump to content

Usage of own php interfaces in modules possible?


blynx
 Share

Recommended Posts

Hi,

is there a way to implement own interfaces to processwire modules?

I am working on some new "submodules" (putting some optional sub-functionality into modules) and I thought it would be nice if they complied to an interface.

I am requiring the interface file in the main module file. Now, the installation of the new sub-module fails with Interface 'ProcessWire\MarkupPwpswpGalleryInterface' not found.
... hm. Any ideas?

cheers
Steffen

Link to comment
Share on other sites

51 minutes ago, blynx said:

I am requiring the interface file in the main module file. Now, the installation of the new sub-module fails with Interface 'ProcessWire\MarkupPwpswpGalleryInterface' not found.

If I understand correctly you require the interface in the main module, but not in the sub module were you implement it.

Maybe you need to require it in the sub module.

Link to comment
Share on other sites

Interesting topic! I'm very curious if/how this will work (if you get past the not found issues.).

Is this of any help?

https://stackoverflow.com/questions/3704841/php-interface-problem-class-not-found

Back to ProcessWire, the   processwire/wire/core/Module.php file has some important documentation at the top about requirements for modules, e.g. modules need to implement the module interface, etc. 

Link to comment
Share on other sites

That should work - but that would kinda eliminate the use of it for me.
I Just try to find a way for others to make  those kind of modules. So the interface should have been some guide for that.

Butttt: Actually it's nothing big and I do hardly need it aaaaand: These submodules extend this one base submodule now which implements the interface already and therefore the functions are already implemented there and can be used by extending modules. So ... ... ... 

Ah, message incoming while typing ... thanks kongondo, but I think a problem like that was already solved.
In the beginning I had a typo and got an error thrown that the interface was not found or something like that. Corrected it and the processwire module list worked fine. Then, the error occurred when installing the modules.

So I thought when installing modules the main module is probably not loaded yet and the interface fails?

The setup:

MarkupTheModule -- is already installed and includes the interface
MarkupSubmodule -- not installed yet, one of those submodules which can be used by TheModule, should implement interface
MarkupSubmoduleB ...
MarkupSubmoduleC ...
...

#+ä+0ad :-[ ASdsdjfgs dgiguh 

aha. So I tested some things after I wrote down the setup and it actually works now. So I must have missed something.

*blush*

 

edit

Mhm! Maybe what I was looking for are abstract classes ...

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...