/** * Remap. * * @param FormatAble $data * @param string $newKey * @param string $oldKey */ protected function remap(&$data, $oldKey, $newKey) { if ($newKey !== null && $newKey !== false) { $data->setProperty($newKey, $data->getProperty($oldKey)); } $data->unsetProperty($oldKey); }
/** * Format the meta fields from the given data. * * @param FormatAble $data * * @return FormatAble */ public function format($data) { if (!$data->hasProperty('meta')) { return $data; } // Loop through the meta arrays/objects/whatever foreach ($data->getProperty('meta') as $meta) { $regex = false; // Check if the meta array is valid if (!$this->metaKeyExists($meta) && !($regex = $this->metaKeyIsRegex($meta))) { continue; } // Get the property if ($regex) { $property = $this->getRegexProperty($regex, $regex['value']); } else { $property = $this->metaFields[$meta['meta_key']]; } // Get the value $value = $this->getUnserializedValue($meta); // Set it $data->setProperty($property, $value); } $data->unsetProperty('meta'); return $data; }