private static function getValues(\contact\Resource\ContactInfo $contact_info, $sort_social = false) { $values['phone_number'] = $contact_info->getPhoneNumber(); $values['fax_number'] = $contact_info->getFaxNumber(); $values['email'] = $contact_info->getEmail(); $values['formatted_phone_number'] = $contact_info->getPhoneNumber(true); if ($values['fax_number']) { $values['formatted_fax_number'] = $contact_info->getFaxNumber(true); } $physical_address = $contact_info->getPhysicalAddress(); $map = $contact_info->getMap(); $values = array_merge($values, ContactInfo\PhysicalAddress::getValues($physical_address)); $values = array_merge($values, ContactInfo\Map::getValues($map)); if ($sort_social) { $social = ContactInfo\Social::getLinks(); foreach ($social as $label => $link) { if (isset($link['url'])) { $social_icons[$label] = $link; } } if (!empty($social_icons)) { $values = array_merge($values, array('social' => $social_icons)); } } else { $values = array_merge($values, array('social' => ContactInfo\Social::getLinks())); } return $values; }
public static function load() { $contact_info = new \contact\Resource\ContactInfo(); $contact_info->setPhoneNumber(\Settings::get('contact', 'phone_number')); $contact_info->setFaxNumber(\Settings::get('contact', 'fax_number')); $contact_info->setEmail(\Settings::get('contact', 'email')); $contact_info->setPhysicalAddress(ContactInfo\PhysicalAddress::load()); $contact_info->setMap(Factory\ContactInfo\Map::load()); $contact_info->setSocial(Factory\ContactInfo\Social::load()); return $contact_info; }
public function post(\Request $request) { $social_links = \contact\Factory\ContactInfo\Social::pullSavedLinks(); $label = $request->getVar('label'); $url = $request->getVar('url'); if (empty($url)) { unset($social_links[$label]); } else { $social_links[$label] = $url; } \contact\Factory\ContactInfo\Social::saveLinks($social_links); echo 'post successful'; exit; }