本文整理匯總了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;
}