Problem in the Return of JsonModel

1

I'm developing an App using Zend Framework 2 and Angular.js.

I have an API Rest module and I also use a standard module returning JsonModel from more specific things (the problem lives there).

In my module.config.php, I set up my view_manager like this:

'view_manager' => array(
    'display_not_found_reason' => true,
    'display_exceptions'       => true,
    'doctype'                  => 'HTML5',
    'not_found_template'       => 'error/404',
    'exception_template'       => 'error/index',
    'template_map' => array(
        'layout/layout'           => __DIR__ . '/../view/layout/layout.phtml',
        'portal/index/index' => __DIR__ . '/../view/portal/index/index.phtml',
        'error/404'               => __DIR__ . '/../view/error/404.phtml',
        'error/index'             => __DIR__ . '/../view/error/index.phtml',
    ),
    'template_path_stack' => array(
        __DIR__ . '/../view',
    ),
    'strategies' => array(
        'ViewJsonStrategy'
    )
),

During a development time, if I (on my controller) did this:

...
return new JsonModel(array('teste'=>true));
...

It would return a JSON like this:

{"teste":true}

I just do not know why it started to return like this:

{"children":[],"options":[],"template":"portal-admin\/transportadora\/verifica-cnpj-cadastrado","terminate":true,"variables":{"teste":true},"append":false}

I have already looked at the class reference on the Zend website and could not find a solution.

Does anyone know how to solve this situation?

Thank you!

    
asked by anonymous 13.07.2015 / 13:24

1 answer

0

Solved, the problem was in my controller.

I have a BaseController in which all other controllers are "extended" from it. The problem was when I created this controller. I've extended it from the AbstractRestFulController, rather than extending it from the AbstractActionController class.

After shredding the names, everything worked correctly!

Thank you!

    
13.07.2015 / 15:07