I need some direction as to where I need to go about injecting some code to
do some dynamic editing of controller return data.

Situation:
 - Our REST application has the ability to overload the return response
data to flip between JSON and XML. While we use Accept headers, we default
to XML return (even if viewed in browser).

I need to capture the array return data from Controller methods
(AbstractRestfulController) and convert the data to either a View\JsonModel
or View\XmlModel (custom).

In addition, when converting, I need the View Strategies to trigger. <-
This is the problem I'm having.

My controller:

       public function getList() {
return ['getList' => 'this is a test']; }

My Module:

    public function onBootstrap( $e)
    {

$e->getApplication()->getEventManager()->attach(MvcEvent::EVENT_DISPATCH,
array($this, 'onDispatch'));
    }

    public function onDispatch(MvcEvent $e) {

        $model =  new
\Zend\View\Model\JsonModel($e->getResult()->getVariables());
        $e->setResult( $model );

        return $model;
    }


This successfully converts the $model. However, I'm running into a huge
problem: this isn't triggering the ViewJsonStrategy!

---
Philip
g...@gpcentre.net
http://www.gpcentre.net/

Reply via email to