Jump to content

Recommended Posts

Hi!

I'm currently building an application on my framework (Rapid Development Framework) which is based on a router, main controller and a serie of different classes that helps building my pages. So, my router points the user to a specific application controller class and method within it, decided by the uri.

 

My application controller builds a relation to my main controller by:

class Application extends Controller

 

Everything is working perfect without any problems, well - till you add a constructor to the application controller class. The relation between my app controller and the main controller seems to crash (still the application class and method runs without any error-messages), but my controller is out of reach.

 

I call the application controller through call_user_func(), and my first thought is that this function cant handle the relations correctly (?)

<?php
/**
 * Run Application
 * This will launch our controller and point to a given method
 */
private function runApplication ()
{
	return call_user_func(array(
		$this->controller,
		$this->method
	));
}
?>

 

Why is this happing and how can I fix it?

Thansk!

// Daniel

Probably a seemingly stupid question to you, but some people mess up and do this.. and if you do it's perfectly fine...

 

Are you overwriting a constructor that's in your parent controller class that's required for the controller to function? I always use a seperate method in my controllers that is called immediately after the class is constructed. I do this mainly because I use the constructor in the parent controller classes, which is why I bring up the issue.

Ohhhhhh, I'm really stupid... The main controller constructor has to be called throught the app controller as it's not automatically constructed when the child has a constructor of its own. I guess I could blame all these hours of coding today ;)

 

Thanks! // Daniel

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.