Issues

ZF-11826: Usage examples for Zend_Controller_Action_Helper_Json in manual are incorrect

Issue Type: Docs: Problem Created: 2011-10-19T01:31:10.000+0000 Last Updated: 2012-03-20T23:53:00.000+0000 Status: Resolved Fix version(s): - 1.11.12 (22/Jun/12)

  • 1.12.0 (27/Aug/12)

Reporter: Adam Lundrigan (adamlundrigan) Assignee: Adam Lundrigan (adamlundrigan) Tags: - Zend_Controller

  • state:patch-ready-for-review
  • zf-caretaker-adamlundrigan
  • zf-crteam-review

Related issues: Attachments: - ZF-11826.patch

Description

Most of the Zend_Controller_Action_Helper_Json examples on this page are incorrect: http://framework.zend.com/manual/en/…

+Pass-through options into Zend_Json+

<pre class="highlight">
$this->_helper->json($data, array('enableJsonExprFinder' => true));



Looking at the implementation of Zend_Controller_Action_Helper_Json::direct, the second argument ($sendnow) does not accept array:



<pre class="highlight">
public function direct($data, $sendNow = true, $keepLayouts = false)
{
    if ($sendNow) {
        return $this->sendJson($data, $keepLayouts);
    }
    return $this->encodeJson($data, $keepLayouts);
}



The parameter $keepLayouts is the one which is passed through to Zend_Json, so the proper example would be:



<pre class="highlight">
$this->_helper->json($data, true, array('enableJsonExprFinder' => true));

+Shortcut array notation+

This usage (2nd argument as array of options) is completely unsupported:

<pre class="highlight">
$this->_helper->json($data, array('keepLayouts' => true));

Comments

Posted by Adam Lundrigan (adamlundrigan) on 2011-10-23T02:09:08.000+0000

Rewrote the manual page section for Zend_Controller_Action_Helper_Json to correct the above issues and add additional information about the available methods and their arguments. Patch is attached.

Comments?

Posted by Adam Lundrigan (adamlundrigan) on 2012-03-20T23:53:00.000+0000

Fixed in trunk r24688 Merged to release-1.11 in r24689

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts