Author: jablko Date: Tue Aug 11 11:44:42 2009 New Revision: 3000 Log: Implement ArrayAccess in sfRequest, backport from symfony 1.3, revision 14592
Modified: trunk/lib/vendor/symfony/lib/request/sfRequest.class.php Modified: trunk/lib/vendor/symfony/lib/request/sfRequest.class.php ============================================================================== --- trunk/lib/vendor/symfony/lib/request/sfRequest.class.php Tue Aug 11 11:25:23 2009 (r2999) +++ trunk/lib/vendor/symfony/lib/request/sfRequest.class.php Tue Aug 11 11:44:42 2009 (r3000) @@ -20,7 +20,7 @@ * @author Sean Kerr <[email protected]> * @version SVN: $Id: sfRequest.class.php 12660 2008-11-05 11:32:23Z fabien $ */ -abstract class sfRequest +abstract class sfRequest implements ArrayAccess { const GET = 'GET'; const POST = 'POST'; @@ -132,26 +132,79 @@ $this->method = strtoupper($method); } + /** + * Returns true if the request parameter exists (implements the ArrayAccess interface). + * + * @param string $name The name of the request parameter + * + * @return Boolean true if the request parameter exists, false otherwise + */ public function __isset($name) { return $this->parameterHolder->has($name); } + public function offsetExists($offset) + { + $args = func_get_args(); + + return call_user_func_array(array($this, '__isset'), $args); + } + + /** + * Returns the request parameter associated with the name (implements the ArrayAccess interface). + * + * @param string $name The offset of the value to get + * + * @return mixed The request parameter if exists, null otherwise + */ public function __get($name) { return $this->parameterHolder->get($name); } + public function offsetGet($offset) + { + $args = func_get_args(); + + return call_user_func_array(array($this, '__get'), $args); + } + + /** + * Sets the request parameter associated with the offset (implements the ArrayAccess interface). + * + * @param string $offset The parameter name + * @param string $value The parameter value + */ public function __set($name, $value) { return $this->parameterHolder->set($name, $value); } + public function offsetSet($offset, $value) + { + $args = func_get_args(); + + return call_user_func_array(array($this, '__set'), $args); + } + + /** + * Removes a request parameter. + * + * @param string $offset The parameter name + */ public function __unset($name) { return $this->parameterHolder->remove($name); } + public function offsetUnset($offset) + { + $args = func_get_args(); + + return call_user_func_array(array($this, '__unset'), $args); + } + /** * Retrieves the parameters for the current request. * --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Qubit Toolkit Commits" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.ca/group/qubit-commits?hl=en -~----------~----~----~----~------~----~------~--~---
