Turba_Driver::toTurbaKeys PHP Method

toTurbaKeys() public method

Translates a hash from being keyed on driver-specific fields to being keyed on the generalized Turba attributes. The translation is based on the contents of $this->map.
public toTurbaKeys ( array $entry ) : array
$entry array A hash using driver-specific keys.
return array Translated version of $entry.
    public function toTurbaKeys(array $entry)
    {
        $new_entry = array();
        foreach ($this->map as $key => $val) {
            if (!is_array($val)) {
                $new_entry[$key] = isset($entry[$val]) && (!empty($entry[$val]) || is_string($entry[$val]) && strlen($entry[$val])) ? trim($entry[$val]) : null;
            }
        }
        return $new_entry;
    }

Usage Example

Example #1
0
 /**
  * Translates a hash from being keyed on driver-specific fields to being
  * keyed on the generalized Turba attributes. The translation is based on
  * the contents of $this->map.
  *
  * @param array $entry  A hash using driver-specific keys.
  *
  * @return array  Translated version of $entry.
  */
 public function toTurbaKeys(array $entry)
 {
     if (isset($entry['__type']) && $entry['__type'] == 'Group' && isset($entry['display-name'])) {
         $entry['last-name'] = $entry['display-name'];
     }
     return parent::toTurbaKeys($entry);
 }
All Usage Examples Of Turba_Driver::toTurbaKeys