Context (Long Story Short):
I am using a PHP script and the $_POST variable to handle certain ajax POST requests from a view template. It needs access to database connector classes which can be accessed within controller.php, or from the associated view.html.php view class.
Short story long (ts;dr):
My current problem is that I can't include the files within my script because of the line:
defined('_JEXEC') or die('Restricted access');
The solution I thought of was to make a separate connector class which the view class can give its instance. Then the POST request handling script can fetch the instance from the connector class, since it doesn't need the restricted access line.
Basically: ViewClass -> InstanceConnector <- -> requestHandler.php <- AJAX
The problem with this is because the script is well... a script, it can't store variables outside of its own run-time, so the InstanceConnector class needs to store a singleton reference to itself for the script to access. Which I know is evil for polluting the global namespace...
This is mainly a general concern than a direct question. I'm assuming there is a Joomla framework in place for doing the requests (Although JRequest seems to be deprecated). However I could see other situations where this problem could come up... not being able to pass around references because of the restricted access.
If you haven't noticed, I am quite new both to Joomla! and full stack dev, so any veteran advice would be greatly appreciated. Has anyone else experienced related issues? I would like to stay within the MVC pattern as best I can and I have a sneaking suspicion that might not be what I am doing...