Jump to content
MakeWebGames

GL constructor


Sim

Recommended Posts

If I'm not mistaken GL has its own constructor for mods:

public $helper = null;
 
  public function constructModule() {
    include "class/ItemHelperFunctions.php";
    $this->helper = new ItemHelperFunctions();
    
    $this->method_view();
  }    

Now the issue rises:

All my methods I had to include in my helper class 

$this->getSelectedItem(); becomes $this->helper->getSelectedItem ();

But the real issue is on 2 of the 6 mods it doesn't work. $helper remains NULL(doesn't assign). Anyone got a solution? Or know the problem? I even tried using the regular constructor but the problem remains the same on 2 of the 6 mods. It's got me a bit confused.

Error: Uncaught Error: Call to a member function getSelectedItem() on null in /home/simmakew/public_html/GL/modules/installed/blackMarket/blackMarket.inc.php:357 Stack trace: #0

 

 

Edit: 

The constructors in any GL module following @Dayoformat is broke.

 

Using the method constructModule is not called first UNLESS ANOTHER METHOD IS NOT CALLED . To fix this issue

Open: class/module.PHP

Find:

if ($this->construct) {
                $this->constructModule();
            }

MOVE BEFORE:

if (isset($this->methodData->action)) {
                $methodAction = 'method_'.$this->methodData->action;
                if (method_exists($this, $methodAction)) {
                    $this->$methodAction();
                }
            }

 

Now I am not %100 sure why

function __construct()

Does not keep the globals from module PHP. The globals, $page, $db, $user no longer work. $this->page, $this->DB, $this->user

By my fix above handles all issues I have mentioned.

Error: Uncaught Error: Call to a member function prepare() on null in

Edited by Sim
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...