本文整理汇总了PHP中Drupal\field\Entity\FieldStorageConfig::getType方法的典型用法代码示例。如果您正苦于以下问题:PHP FieldStorageConfig::getType方法的具体用法?PHP FieldStorageConfig::getType怎么用?PHP FieldStorageConfig::getType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\field\Entity\FieldStorageConfig
的用法示例。
在下文中一共展示了FieldStorageConfig::getType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: hook_rdf_apply_default_fields_alter
/**
* Alters the field configuration for fields related to rdf entities.
*
* @param \Drupal\field\Entity\FieldStorageConfig $storage
* The field configuration storage entity.
* @param array &$values
* An associative array of field values. This array include any additional
* data a field formatter includes.
*
* @ingroup rdf_entity_api
*/
function hook_rdf_apply_default_fields_alter(\Drupal\field\Entity\FieldStorageConfig $storage, &$values)
{
if ($storage->getType() == 'text_long') {
// Handle multiple values in a field.
foreach ($values as &$value) {
$value['format'] == 'my_custom_persistent_filter';
}
}
}
示例2: applyFieldDefaults
/**
* Allow overrides for some field types.
*
* @param FieldStorageConfig $storage
* Field storage configuration.
* @param array $values
* The field values.
*/
private function applyFieldDefaults(FieldStorageConfig $storage, &$values)
{
if (empty($values)) {
return;
}
foreach ($values as &$value) {
// Textfield: provide default filter when filter not mapped.
switch ($storage->getType()) {
case 'text_long':
if (!isset($value['format'])) {
$value['format'] = 'full_html';
}
break;
// Strip timezone part in dates.
// Strip timezone part in dates.
case 'datetime':
$time_stamp = strtotime($value['value']);
$date = date('o-m-d', $time_stamp) . "T" . date('H:i:s', $time_stamp);
$value['value'] = $date;
break;
}
}
$this->moduleHandler->alter('rdf_apply_default_fields', $storage, $values);
}
示例3: buildRow
/**
* XXXXX.
* @param \Drupal\field\Entity\FieldStorageConfig $field_storage.
* @return array
* xxx
*/
protected function buildRow(FieldStorageConfig $field_storage)
{
$row = [];
if ($field_storage->isLocked()) {
$row[0]['class'] = array('menu-disabled');
$row[0]['data']['id'] = $this->t('@field_name (Locked)', array('@field_name' => $field_storage->getName()));
} else {
$row[0]['data'] = $field_storage->getName();
}
$row[1]['data'] = $field_storage->getType();
$row[2]['data'] = $field_storage->getTargetEntityTypeId();
$row[3]['data'] = implode(",", $field_storage->getBundles());
$default_type = $this->fieldPermissions->fieldGetPermissionType($field_storage);
if ($default_type == FIELD_PERMISSIONS_PUBLIC) {
$row[4]['data'] = t("Public field (author and administrators can edit, everyone can view)");
$row[4]['colspan'] = 5;
} elseif ($default_type == FIELD_PERMISSIONS_PRIVATE) {
$row[4]['data'] = t("Private field (only author and administrators can edit and view)");
$row[4]['colspan'] = 5;
} elseif ($default_type == FIELD_PERMISSIONS_CUSTOM) {
$row[4]['data'] = t("Custom field Permission ()");
$row[4]['colspan'] = 5;
}
return $row;
}