本文整理汇总了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();
}
}
}