X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FUtils%2FType.php;h=65b726c98f04b7353ed46b90b424d2060dba5aec;hb=110647e99322a4a7231379a041c474872b6d4f69;hp=9244e8c0dd4966db20131d09131fd7f5e23b2837;hpb=17926a82b59aa0fc2080dd63c05d7efa3bcc6741;p=civicrm-core.git diff --git a/CRM/Utils/Type.php b/CRM/Utils/Type.php index 9244e8c0dd..65b726c98f 100644 --- a/CRM/Utils/Type.php +++ b/CRM/Utils/Type.php @@ -3,7 +3,7 @@ +--------------------------------------------------------------------+ | CiviCRM version 4.7 | +--------------------------------------------------------------------+ - | Copyright CiviCRM LLC (c) 2004-2016 | + | Copyright CiviCRM LLC (c) 2004-2017 | +--------------------------------------------------------------------+ | This file is a part of CiviCRM. | | | @@ -28,7 +28,7 @@ /** * * @package CRM - * @copyright CiviCRM LLC (c) 2004-2016 + * @copyright CiviCRM LLC (c) 2004-2017 */ class CRM_Utils_Type { const @@ -144,7 +144,29 @@ class CRM_Utils_Type { } /** - * Helper function to call escape on arrays + * Get the data_type for the field. + * + * @param array $fieldMetadata + * Metadata about the field. + * + * @return string + */ + public static function getDataTypeFromFieldMetadata($fieldMetadata) { + if (isset($fieldMetadata['data_type'])) { + return $fieldMetadata['data_type']; + } + if (empty($fieldMetadata['type'])) { + // I would prefer to throw an e-notice but there is some, + // probably unnecessary logic, that only retrieves activity fields + // if they are 'in the profile' and probably they are not 'in' + // until they are added - which might lead to ? who knows! + return ''; + } + return self::typeToString($fieldMetadata['type']); + } + + /** + * Helper function to call escape on arrays. * * @see escape */