本文整理匯總了PHP中ca_metadata_elements::getDataTypeForElementCode方法的典型用法代碼示例。如果您正苦於以下問題:PHP ca_metadata_elements::getDataTypeForElementCode方法的具體用法?PHP ca_metadata_elements::getDataTypeForElementCode怎麽用?PHP ca_metadata_elements::getDataTypeForElementCode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ca_metadata_elements
的用法示例。
在下文中一共展示了ca_metadata_elements::getDataTypeForElementCode方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getInstance
/**
* @param string $ps_table
* @param string $ps_content_fieldname
* @return \ElasticSearch\FieldTypes\FieldType
*/
public static function getInstance($ps_table, $ps_content_fieldname)
{
if ($ps_table == 'created' || $ps_table == 'modified') {
return new Timestamp($ps_table);
}
// if this is an indexing field name, rewrite it
if (preg_match("/^(I|A)[0-9]+\$/", $ps_content_fieldname)) {
if ($ps_content_fieldname[0] === 'A') {
// Metadata attribute
$vn_field_num_proc = (int) substr($ps_content_fieldname, 1);
$t_element = new \ca_metadata_elements($vn_field_num_proc);
if (!$t_element->getPrimaryKey()) {
return null;
}
$ps_content_fieldname = $t_element->get('element_code');
} else {
// Plain intrinsic
$vn_field_num_proc = (int) substr($ps_content_fieldname, 1);
$ps_content_fieldname = \Datamodel::load()->getFieldName($ps_table, $vn_field_num_proc);
}
}
if ($vn_datatype = \ca_metadata_elements::getDataTypeForElementCode($ps_content_fieldname)) {
switch ($vn_datatype) {
case 2:
return new DateRange($ps_table, $ps_content_fieldname);
case 4:
return new Geocode($ps_table, $ps_content_fieldname);
case 6:
return new Currency($ps_table, $ps_content_fieldname);
case 8:
return new Length($ps_table, $ps_content_fieldname);
case 9:
return new Weight($ps_table, $ps_content_fieldname);
case 10:
return new Timecode($ps_table, $ps_content_fieldname);
case 11:
return new Integer($ps_table, $ps_content_fieldname);
case 12:
return new Float($ps_table, $ps_content_fieldname);
default:
return new GenericElement($ps_table, $ps_content_fieldname);
}
} else {
return new Intrinsic($ps_table, $ps_content_fieldname);
}
}