Current situation:
- I have a current version of my MVC Framework that uses classes as controllers.
- I have some “vintage” modules from my old MVC Framework, which uses simple, flat versions as controllers.
Significant simplification means:
A new version:
<?PHP class blaController extends baseController { private $intVar; function dosomethingFunction() { $this->intVar = 123; $this->view('myView'); } } ?>
Old version:
<?PHP $globalVar = 123;
Now I'm trying to write a shell to be able to use my old controllers in my new MVC without rewriting everything. For this, I have a wrapper controller:
class wrapController extends baseController { function dosomethingFunction() { require 'old_dosomething.function.php'; $this->view('old_dosomething_view'); } }
(Once again: this is VERY, VERY simplified - just to understand that this is not real code.)
The problem with this approach is that previously the global variable $ globalVar now exists only inside the "dosomethingFunction" method and cannot be accessible for presentation.
This is not so if I could make the requirement behave as "in the global scope", so $ globalVar will be available again in the global scope.
So: is there a way to achieve " require_global " or something like that?
(One solution to my problem was to change my old controllers to start with a bunch of "global" commands, but I would prefer a solution in which I don't need to change such old code.)
(Note: Please don’t tell me that GLOBALS are bad. This is completely out of the question. Just accept that it is a requirement to keep the old code in a newer, cleaner environment.)
source share