Source for file Mapper.class.php
Documentation is available at Mapper.class.php
* Gumbo Library Framework
* This library is being released under the terms of the New BSD License. A
* copy of the license is packaged with the software (LICENSE.txt). If no
* copy is found, a copy of the license template can be found at:
* http://www.opensource.org/licenses/bsd-license.php
* @copyright Copyright (c) 2007, iBayou, Michael Luster
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
* @author Michael Luster <mluster79@yahoo.com>
* @link http://sourceforge.net/projects/phpgumbo
* The Mapper is responsible for holding Maps. A Map is simply a key reference
* to some outside data (see Gumbo_Interface_Map for more details). The Mapper
* can hold a single Map, or multiple Maps referenced by a key.
* Once the Maps are assigned, the 'map' method will be responsible for taking
* some foreign data and applying the appropriate Map. For example, if the
* Mapper Class wants to Map internal properties to an HTML form, the program would
* pass the $_REQUEST array (or some other) into the 'map' method. The Map class
* would define the reference from the HTML form name to the internal property.
* // quick implementation of map method (assume inside class)
* public function map ($data, $key=null) {
* $map = $this->getMap ($key);
* foreach ($data as $key=>$val) {
* if (!$map->isForeignKey ($key)) { continue; }
* $property = $map->getKey ($key);
* $this->$property = $val;
* // map foreign data to the Mapper
* $mapper = new Some_Mapper_Class ();
* $mapper->map ($_REQUEST); // assuming a Map was created
* @copyright Copyright (c) 2007, iBayou, Michael Luster
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
* @author Michael Luster <mluster79@yahoo.com>
* @link http://sourceforge.net/projects/phpgumbo
* @see Gumbo_Interface_Map
gumbo_load ("Interface_Map");
* @param Gumbo_Interface_Map $map
* @param string $key reference string to the Map object
* @param bool $replace replaces original
public function addMap (Gumbo_Interface_Map $map, $key=
null, $replace=
false);
* @postcondition !getAllMaps()
* Maps information into the Mapper
* @param array $data where key=>"form field name", value=>user data
* @param string $key Map reference key
public function map ($data, $key=
null);
* @return Gumbo_Interface_Map
public function getMap ($key=
null);
* @return Gumbo_Interface_Map[]
* Returns if the Map exists
* @param string $key reference key string
public function isMap ($key=
null);