Jump to content

Simple processwire module wrapper for php class, how?


blynx
 Share

Recommended Posts

Hi,

given there is a class with some namespace like "Super\Project\NiceClass",
how could I put that class into a module so that when I load that module via "$nice = $modules->get('NiceClass')", $nice is an instance of that class.

I think thats simple but failed somehow -

I tried to return the instance in the constructor or in the init() function, also in a separate function of that module - but had no luck.

Any hint would be nice, thanks!

Link to comment
Share on other sites

Yup yup,

actually I also think it's quite odd what I wanted to do from the languages standpoint.

I had a look into this discussion then: http://stackoverflow.com/questions/7026487/how-to-add-methods-dynamically

I haven't tried anything of that stuff there since I just use the class directly now, but maybe it is somehow possible with __call() and http://php.net/manual/en/function.get-class-methods.php

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...