本文整理匯總了PHP中Drupal\Core\Entity\EntityTypeInterface::isFieldable方法的典型用法代碼示例。如果您正苦於以下問題:PHP EntityTypeInterface::isFieldable方法的具體用法?PHP EntityTypeInterface::isFieldable怎麽用?PHP EntityTypeInterface::isFieldable使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Drupal\Core\Entity\EntityTypeInterface
的用法示例。
在下文中一共展示了EntityTypeInterface::isFieldable方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: hook_entity_field_storage_info
/**
* Provides field storage definitions for a content entity type.
*
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
* The entity type definition.
*
* @return \Drupal\Core\Field\FieldStorageDefinitionInterface[]
* An array of field storage definitions, keyed by field name.
*
* @see hook_entity_field_storage_info_alter()
* @see \Drupal\Core\Field\FieldStorageDefinitionInterface
* @see \Drupal\Core\Entity\EntityManagerInterface::getFieldStorageDefinitions()
*/
function hook_entity_field_storage_info(\Drupal\Core\Entity\EntityTypeInterface $entity_type)
{
// Expose storage definitions for all exposed bundle fields.
if ($entity_type->isFieldable()) {
// Query by filtering on the ID as this is more efficient than filtering
// on the entity_type property directly.
$ids = \Drupal::entityQuery('field_storage_config')->condition('id', $entity_type->id() . '.', 'STARTS_WITH')->execute();
// Fetch all fields and key them by field name.
$field_storages = entity_load_multiple('field_storage_config', $ids);
$result = array();
foreach ($field_storages as $field_storage) {
$result[$field_storage->getName()] = $field_storage;
}
return $result;
}
}