U
U
ukoHka2017-02-03 10:50:17
PHP
ukoHka, 2017-02-03 10:50:17

Why is the current object being returned?

I am learning MVC.
There are two controllers Controller_AJAX and Controller_Blog. Both are derived from Controller. In the action of the first controller I write, $blog = Controller_Blog::getInstance();
but the Controller_AJAX object is returned. At the same time with other controllers everything works fine.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Anton Perevoshchikov, 2017-02-03
@Fett

What's in the getInstance method? Controller_Blog definitely inherits from Controller?
Perhaps this will help

A
Alexander Pavlenko, 2017-02-03
@RichyNix

You have a very strange application architecture. I think it's worth digging towards the singleton ... As an option.

U
ukoHka, 2017-02-13
@ukoHka

Understood. It turns out that use Singleton was separately registered in Controller_User, and for other classes it was registered in the parent Controller class. Accordingly, getInstance returned the parent class, and the current successor of this class was assigned. I registered use Singleton in all controllers and the problem was solved.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question