I don't understand why I get return from my controllers but it wont print a simple var_dump
.
Steps I follow:
modules/controllers/home.php
$result = modules::run("apis/c_$api/data", $parameters);
var_dump($result); //works
modules/apis/controllers/c_api1.php
function data()
{
#....
case 'getDataInfo':
echo 'baa'; //Not working
$result = simplexml_load_string($this->api1->getDataEntry($parameters['id'], false));
var_dump($result); //Not working
break;
#....
}
Any ideas why this happens? The fact that returning $result
works but not the echo
or var_dump()
The function works because if I comment the $result
line inside the case, I have no output. That means that the case works, but even so I don't get the echo
I think that MX HMVC extension blocks in some way the output of a module when called via Modules::run
.
Here is a small piece of MX's Modules.php, you can see that the output is not sent to the browser but returned instead:
ob_start();
$args = func_get_args();
$output = call_user_func_array(array($class, $method), array_slice($args, 1));
$buffer = ob_get_clean();
return ($output !== NULL) ? $output : $buffer;
As far as I know there is no way to send something to the output calling a module with Modules::run
unless you want to modify the code above.
That's why you are able to print $result
on the caller controller and not on the invoked one.
You need to return what you want to print so that you can print it on the caller side.
print
dump
echo
or what ever outputting function, and print
it again inside the caller - Alex 2012-04-04 22:25
The most obvious cause would be that case
is not being matched.
Without seeing more of api1.php
, I am forced to speculate.
$result
but does not the bloody echo. Lo - Alex 2012-04-04 21:54
echo
is not switched off, then it must be executing another module, another function, or with different data - wallyk 2012-04-04 21:55
$result
line... I have no output. I know, it's strange and it's freaking me out x - Alex 2012-04-04 21:58