本文整理汇总了PHP中Drupal\Core\Field\FieldDefinitionInterface::getClass方法的典型用法代码示例。如果您正苦于以下问题:PHP FieldDefinitionInterface::getClass方法的具体用法?PHP FieldDefinitionInterface::getClass怎么用?PHP FieldDefinitionInterface::getClass使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\Core\Field\FieldDefinitionInterface
的用法示例。
在下文中一共展示了FieldDefinitionInterface::getClass方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isDefaultCompatible
/**
* Determine if we should try to make a default value widget.
*
* @param \Drupal\Core\Field\FieldDefinitionInterface $definition
*
* @return bool
*/
private function isDefaultCompatible(FieldDefinitionInterface $definition) {
$class = $definition->getClass();
$type = $definition->getType();
$compatible_types = [
'boolean',
'list_float',
'list_integer',
'list_string',
];
if (in_array($type, $compatible_types)) {
return TRUE;
}
if ('entity_reference' == $type) {
// We should only store a default value in the special case
// where the target is a config entity.
// Otherwise we would have config that pointed to content.
// The site-builder could still do this in manage fields for the Update type
// but should not en-courage this practice.
$target_type = $definition->getFieldStorageDefinition()->getSetting('target_type');
$definition = $this->entityTypeManager->getDefinition($target_type);
if ($this->definitionClassImplementsInterface($definition, ['Drupal\Core\Config\Entity\ConfigEntityInterface'])) {
return TRUE;
}
}
return FALSE;
}