View Source

<ac:macro ac:name="info"><ac:parameter ac:name="title">New Proposal Template</ac:parameter><ac:rich-text-body>
<p>This page has been created from a template that uses &quot;zones.&quot; To proceed:</p>

<ol>
<li>Edit the page</li>
<li>Replace sample content within each zone-data tag</li>
<li>Remove this notice</li>
<li>Save the page</li>
<li>When you are ready for review, remove the <ac:emoticon ac:name="warning" /> Under Construction notice</li>
</ol>
</ac:rich-text-body></ac:macro>

<ac:macro ac:name="note"><ac:parameter ac:name="title">Under Construction</ac:parameter><ac:rich-text-body>
<p>This proposal is under construction and is not ready for review.</p></ac:rich-text-body></ac:macro>

<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[{zone-template-instance:ZFDEV:Zend Proposal Zone Template}

{zone-data:component-name}
Zend_View_Helper_Request
{zone-data}

{zone-data:proposer-list}
[xavividal@gmail.com|mailto:xavividal@gmail.com]
{zone-data}

{zone-data:revision}
{zone-data}

{zone-data:overview}
Zend_View_Helper_Request allows access to the Request object from a View script. The purpose of this helper is get quick access to superglobals variables.
{zone-data}

{zone-data:references}
* [View Helpers|http://framework.zend.com/manual/en/zend.view.helpers.html]
{zone-data}

{zone-data:requirements}
Most requirements take the form of "foo will do ...." or "foo will not support ...", although different words and sentence structure might be used. Adding functionality to your proposal is requirements creep (bad), unless listed below. Discuss major changes with your team first, and then open a "feature improvement" issue against this component.

* This component *will* correctly reads a developers mind for intent and generate the right configuration file.
* The generated config file *will not* support XML, but will provide an extension point in the API.
* This component *will* use no more memory than twice the size of all data it contains.
* This component *will* include a factory method.
* This component *will not* allow subclassing. (i.e. when reviewed, we expect to see "final" keyword in code)
* This component *will* only generate data exports strictly complying with RFC 12345.
* This component *will* validate input data against formats supported by ZF component Foo.
* This component *will not* save any data using Zend_Cache or the filesystem. All transient data *will be* saved using Zend_Session.
{zone-data}

{zone-data:dependencies}
* Zend_Controller_Front
{zone-data}

{zone-data:operation}
This Helper gets the request from the Front Controller when gets instantiated, once saved, let the view script to get access to superglobals variables using the "get" method from the Request object.
{zone-data}

{zone-data:milestones}
Describe some intermediate state of this component in terms of design notes, additional material added to this page, and / code. Note any significant dependencies here, such as, "Milestone #3 can not be completed until feature Foo has been added to ZF component XYZ." Milestones will be required for acceptance of future proposals. They are not hard, and many times you will only need to think of the first three below.
* Milestone 1: [design notes will be published here|http://framework.zend.com/wiki/x/sg]
* Milestone 2: Working prototype checked into the incubator supporting use cases #1, #2, ...
* Milestone 3: Working prototype checked into the incubator supporting use cases #3 and #4.
* Milestone 4: Unit tests exist, work, and are checked into SVN.
* Milestone 5: Initial documentation exists.

If a milestone is already done, begin the description with "\[DONE\]", like this:
* Milestone #: \[DONE\] Unit tests ...
{zone-data}

{zone-data:class-list}
* Zend_View_Helper_Request
{zone-data}

{zone-data:use-cases}
||UC-01||
Requesting a variable
{code}
...
<p><?php echo $this->request('name', 'default') ?></p>
...
{code}

||UC-02||
Requesting a GET variable
{code}
...
<p><?php echo $this->request('name', 'default', 'get') ?></p>
...
{code}
{zone-data}

{zone-data:skeletons}
{code}
<?php

/**
* @category Zend
* @package Zend_View
* @copyright Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

require_once 'Zend/View/Helper/FormElement.php';

class Zend_View_Helper_Request extends Zend_View_Helper_FormElement
{
protected $request;

public function __construct()
{
if (null === $this->request) {
$this->request = Zend_Controller_Front::getInstance()->getRequest();
}
}

public function request($label, $value = null, $superglobal = 'all')
{
switch($superglobal) {
case 'get' : return $this->request->getQuery($label, $value);
case 'post' : return $this->request->getPost($label, $value);
case 'cookie': return $this->request->getCookie($label, $value);
case 'server': return $this->request->getServer($label, $value);
case 'env' : return $this->request->getEnv($label, $value);
case 'all' :
default : return $this->request->get($label, $value);
}
}
}

{code}
{zone-data}

{zone-template-instance}]]></ac:plain-text-body></ac:macro>