Drupal 8在config中引用一个配置实体

时间:2018-12-01 12:52:59

标签: drupal-8

我有这样的配置模式:

my_module.search_api_endpoint.*:
  label: 'Search API endpoint configuration'
  type: config_entity
  mapping:
    id:
      type: string
      label: 'Id'
    label:
      type: label
      label: 'Label'
    url:
      type: uri
      label: 'API endpoint'
    timeout:
      type: integer
      label: 'API request timeout'
my_module.settings:
  type: config_object
  label: 'Search settings'
  mapping:
    endpoint:
      type: id
      label: 'API Endpoint'

search_api_endpoint实体的列表是有限的,不会更改,但是可以更改和导出实体中的值(ids除外)。 my_module.settings.endpoint也可以更改和导出。

在当前状态\ Drupal :: config('my_module.settings')-> get('endpoint')返回实体的ID,我需要调用/注入实体类型管理器以加载实体并访问其值。

我想使\ Drupal :: config('my_module.settings')-> get('endpoint')返回实体本身而不是其ID,但在my_module.settings中仍然没有完整的实体数据.endpoint导出后。

我试图了解动态类型如何工作,但失败了。您能举个例子吗?

0 个答案:

没有答案