本文整理匯總了PHP中Drupal::typedData方法的典型用法代碼示例。如果您正苦於以下問題:PHP Drupal::typedData方法的具體用法?PHP Drupal::typedData怎麽用?PHP Drupal::typedData使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Drupal
的用法示例。
在下文中一共展示了Drupal::typedData方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: buildProperties
/**
* Discovers all fields/properties of an entity.
*
* @param \Drupal\feeds\ImporterInterface $importer
* The importer.
*/
protected static function buildProperties(EntityProcessor $processor)
{
$entity_type = $processor->entityType();
$info = \Drupal::entityManager()->getDefinition($entity_type);
$bundle_key = NULL;
if (isset($info['entity_keys']['bundle'])) {
$bundle_key = $info['entity_keys']['bundle'];
}
$field_definitions = \Drupal::entityManager()->getFieldDefinitions($entity_type, $processor->bundle());
foreach ($field_definitions as $id => $field_definition) {
if ($field_definition->isReadOnly() || $id == $bundle_key) {
continue;
}
static::$properties[$id] = $field_definition->getItemDefinition()->toArray();
static::$properties[$id]['label'] = $field_definition->getLabel();
static::$properties[$id]['description'] = $field_definition->getDescription();
static::$properties[$id]['settings'] = $field_definition->getSettings();
foreach (\Drupal::typedData()->create($field_definition->getItemDefinition())->getPropertyDefinitions() as $property => $data_definition) {
if (!$data_definition->isComputed()) {
static::$properties[$id]['properties'][$property] = $data_definition->toArray();
}
}
$instance_id = $entity_type . '.' . $processor->bundle() . '.' . $id;
$instance = \Drupal::entityManager()->getStorageController('field_instance')->load($instance_id);
if ($instance) {
static::$properties[$id]['label'] = $instance->getLabel();
static::$properties[$id]['description'] = $instance->getDescription();
static::$properties[$id]['settings'] = $instance->getSettings();
}
}
}