Gumbo_Interface_Mapper
Mapper Interface
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
Author(s): |
Michael Luster <mluster79@yahoo.com> |
License: | New BSD License |
Copyright: | Copyright (c) 2007, iBayou, Michael Luster |
Link: | http://sourceforge.net/projects/phpgumbo |
Version: | 0.0.1 |
Interface Methods
public void addMap ( Gumbo_Interface_Map $map, [string $key], [bool $replace] )
[line 73]
Adds a Map
Parameter(s):
- (Gumbo_Interface_Map) $map
- (string) $key :: reference string to the Map object
- (bool) $replace :: replaces original
[ Top ]
public bool isMap ( [string $key] )
[line 115]
Returns if the Map exists
Parameter(s):
- (string) $key :: reference key string
[ Top ]
public void map ( array $data, [string $key] )
[line 92]
Maps information into the Mapper
Parameter(s):
- (array) $data :: where key=>"form field name", value=>user data
- (string) $key :: Map reference key
[ Top ]