44. 实体Entity(二)配置实体基类

实体Entity(二)配置实体基类

龷龴龰龯龭龬龪龩龧龦龥龤龡龟龛龚龷龴龰龯龤龘龖龭龬龕龒龎龋龰龯龭龬龕龈龇龅龷龴龰龯龤龄龁齾齻龛齹齵龕齴龯龤龷龴龰龯齱齱齮龒龎齭龕齫齩龛齥齣齟龰龯龕齛齘齕齑齍齊齈齄齀龕龬龦龥齩鼾鼻

Drupal\Core\Config\Entity\ConfigEntityBase

龰鼅龅龷龴龰龯鼁黿鼻

Drupal\Core\Config\Entity\ConfigEntityInterface

黼鼁黿龒龎龅龰龯鼁黿黺黶黲黮黪龴鼁黿鼻

Drupal\Core\Entity\EntityInterface

Drupal\Core\Config\Entity\ThirdPartySettingsInterface

龷龴龰龯龭龬 ConfigEntityBase 黝黙龴黗龷龴黕黓黏龕黺黋黈龰龯龭龬黄龇龩龧黀龄龰龯龬麾龤龭麻龕麸麷麶麵麲麯麫麪鼻

龷龴麨麤鼻

龷龴龰龯齀麣麢麞齭麛麗龤麨麤龕麖麒麑麛龤麨麤麎黗齭麍齀麣黝麉麇龕黗龷龴麅麁龤鹿鹻黏麨麤鹺鹸鹵龪麒鹳麗龤龕齫齩鹰鹭龷龴龰龯龤鹪鹨黝麅麁龕鹧鹥龷龴龰龯齱齱麛麗黝鹣鹟鹝龷龴龰龯齱齱麨麤齭龤鹰鹭鹙鹖鹪鹨鹔龕鹰鹭鹙鹐麎黗龅龕龷龴龰龯鹌鹊黼黝麅麁鹈麨麤龩龧黗龷龴麉麇鹇麅麁黺鹆鹄鹀鸾黝鸺龛龕鸸鸴麒鸱鸸龤麨麤鸯鸬鸪龩鹈

龷龴龰龯齀麣黗齭龤鸦黓龦龥鸥鸤龤 config_dependencies 鸡黏麢麞麨麤龕麑麨麤龤鸠龖龪齛鸝鸚龬麾鸙龡鼻

鹪鹨 'module', 麷麶 'theme', 龷龴龰龯 'config', 黋黈龰龯 'content'

鸐鸏 config_dependencies 鸡龪龡龟鸋黕龕鸡鸈鸇齛鸝鸚龬麾鸙龡龕鸡鸅鸇鸠鹊龤麨麤鸅龕齩鼾麑鸁鼻

      array(
        'config' => array('user.role.anonymous', 'user.role.authenticated'),
        'content' => array('node:article:f0a189e6-55fb-47fb-8005-5bef81c44d6d'),
        'module' => array('node', 'user'),
        'theme' => array('seven'),
      );

黶龡鷓鸡鸈鸇麑麨麤鷑龤龬麾龕鷐鸚龬麾鼾鸴麎鷌黝麨麤龤鸠龖鸈龕齀麣麒鷊龟龕鸠龖鸈鷉鷅鸇鼻

鹪鹨龬麾鼻鸠龖鸈鸇鹪鹨鸈

麷麶龬麾鼻鸠龖鸈鸇麷麶鸈

龷龴龬麾鼻鸠龖鸈鸇龷龴龰龯鸠龖鸈龕齩鷂龪龷龴龰龯黼鸈鷀龋龰龯龤 getConfigDependencyName() 黮鶽

黋黈龬麾鼻龩龧黏麑麒黋黈龬麾龤鶺鶸鶴龪龰龯龕鸠龖鸈鸇黋黈龰龯龬麾 id+ 鶮鼻鶬 + 龰龯 bundle+ 鶮鼻鶬 + 龰龯龤 UUID 龕鹆齘鷀龋龰龯龤 getConfigDependencyName() 黮鶽

黗龷龴龰龯黏麣 $this->dependencies 鶥鶢鸴麎麨麤龕黗鶠鶞黏麢麞龕鶛鶚黄齩鶖龕鶒鷊鶏龡龟鸡鸈鼻 enforced 龕黼鸡鸈鼾龤鸅鶚黄鹵齩鶖龕齭齊鶌鶋鶈龤麨麤龕齻鶇龪鹐齀黝龋鶃鵿鵼鵹鶠鵵鵲鵯鼾龤麨麤龕麣鵫鵨黮鵦鵢龦龕鶋鶈龤麨麤黗鸴麎龷龴龰龯鵠鹐黝鵜鵙鵿鵼龕鵗鶛鵖鵒黗鷐鵏鸴麎鵠鶴鵎黝鵜鵙鵿鵼龕鵋鵊 $this->dependencies 鶥鶢龤鶚黄齩鼾鼻

      array(
        'config' => array('user.role.anonymous', 'user.role.authenticated'),
        'content' => array('node:article:f0a189e6-55fb-47fb-8005-5bef81c44d6d'),
        'module' => array('node', 'user'),
        'theme' => array('seven'),
        'enforced'=>array(
                           'config' => array(),
                           'content' => array(),
                           'module' => array(),
                           'theme' => array(),
                            )
      );

龷龴龰龯龛麣鼾黮鶽鷀鵈鵇麨麤鼻

protected function addDependency($type, $name);

鵅鵄鵃龬麾龤麨麤龕 $type 鸇龬麾鸈龕 $name 鸇麨麤鸠龖鸈龕黗龷龴龰龯龭龬黏黝鵜齕龕鸠鶮 core 鶬黺龷龴龰龯麑黗龤鹪鹨鹐鵂鴿鵅鵄

protected function addDependencies(array $dependencies);

鵅鵄鷊龟麨麤龕 $dependencies 龤鸡鸈鸇龬麾鸈龕鸡鸅鸇麨麤鸠龖鸈鸋黕

public function getDependencies();

鴾鴽龷龴龰龯麨麤龕龪鵎 $this->dependencies 黺鶛黏龤 enforced 鸡鴼鴺龤鶚鷂

protected function calculatePluginDependencies(PluginInspectionInterface $instance);

鵿鵼鸦黓龤麨麤龕 $instance 鸇鸦黓龰鴷龕齱齱龪鸦黓鴶黏龤龡龟龰鴷龕鴲鴮黼黮鶽黏鴬龛龤 calculateDependencies 黮鶽黺龷龴龰龯龭龬黏龤鹆鸈黮鶽龪鹐龡齘龤龕鴪黮鶽鸈鴦鹆龕鵖鴥黗鹐鹆鼁黿黏龦龥龕鴣鹙鴢鴠龤龪龷龴麨麤鸋鴟龕鵗鴜鹙鴢鴠龷龴龰龯麸鴛

public function calculateDependencies();

鵿鵼龷龴龰龯龤麨麤龕齻鶇黗鸴麎龷龴龰龯鴣鴬龛龕齭鸇龷龴龰龯龤 $this->dependencies 鶥鶢鵜鵙鴗鸅龕鴢鴠龷龴龰龯麸鴛龕鸸鸴鸱鸸龰鵠龤麨麤鸪龩龕鶒鶛黏龤 enforced 鵒龪鹐齮黝鴕鴑龤龕黼黮鶽麖龪鵿鵼麨麤龤齻龛黮鶽龕齭麨鴍鸦黓黺黶黲黮黪龴鷀鴋鴉龕齩鷂麛麗龤麨麤鹐齵齻鹿鸏鴆鴂龕鹧鹥鴀龬麛麗鳽鳹龰鼅龕鳸鳵鳲鴬龛鵖龕鴀龬龰鼅鵠鸺龛 addDependency($type, $name); 鷀鵅鵄麨麤

齩鷂龷龴龰龯鳱鸇龡龟鳮鳬鹖 (module, theme, or profile) 鹔龤鳪鳨龷龴龕鹧鹥黼龷龴龰龯龤麨麤鹵龪黼鳮鳬龤麨麤龕麛麗齕鳤鳮鳬龤 info 鸤黓

龩龧龦龥龅龡龟鳡鳝龤龷龴龰龯麨麤鸠龖鼻

Drupal\Core\Config\Entity\ConfigEntityDependency

麒黀龟黄鳛鳙鸋鼻龷龴龰龯龤龷龴鸠龖鸈鹇龷龴龰龯黏鳕鳔龤鸋鴟

黼龬齫鳑鳎鳋龕麷麗龛龚鳈鳄鵿鵼龷龴麨麤龕麖麒黲龟黮鶽鼻

public function getDependencies($type) 鼻鴾鴽鵃龬麾龤麨麤

public function hasDependency($type, $name) 鼻鴋鴉龪鳂麒鵃麨麤

public function getConfigDependencyName() 鼻鴾鴽龷龴龰龯龤龷龴鸠龖鸈

龷龴麨麤龤鲾黮鸤鲼鲺鲹鼻

https://www.drupal.org/docs/8/api/configuration-api/configuration-entit…

龷龴麨麤鸈鼻

getConfigDependencyName() 鴾鴽龤龪龷龴麨麤鸈龕鹵鹌龪龷龴龰龯龤龷龴鸠龖鸈龕黺鳎鳋龷龴鸠龖龤龷龴鸠龖鸈龪龧龡龤鹈

鲲鵦鸇鼻龷龴鴣鲰 + . + 龷龴 id

龷龴鴣鲰鸇鼻鹪鹨鸈 + . + 龷龴龰龯鸥鸤黏龦龥龤 config_prefix

齩鷂鲨麒龦龥 config_prefix 鷅麣鸥鸤黏龤鸦黓 id 齊鲦

鸦黓鴶鼻

黗龷龴龰龯龭龬黏鷊鵏鲣鲠鴽鸦黓鴶龤鲟鳱龕鹵鹌龪 EntityWithPluginCollectionInterface 鼁黿龕鸪龚鸦黓鴶鹺鹸齩鼾鼻

黗鲚鷊鲘鲗鼾龩龧黏龡龟鸦黓龬麖龰鴷鲔鶏龡龟龰鴷鸠龖龕鶒龡鲓齀龷龴龤鸦黓龬麾龕鲒鴟鹐鹆龷龴麛麗鲎鲌鹐鹆龰鴷龕齫齩鹨鸦黓龕鹨齀齵齮鶏鼅黗鲈鲄黏鷊龟鲺黮龕鷐龟龰鴷鶴麒龋鲃龤龷龴龕鹐鹆鲀麶鹇黋黈鱼鱼龕龩龧鱹鲚鱵鵇鱲鱱鸠鹐鹆龷龴鸇鹆龡龟鸦黓龬鱰鱯鷊龟龰鴷龕鱬鸏鲎鲌龅鶮鸦黓鴶 PluginCollection 鶬齛龟鹺鹸龕鸇龅黺鴶鱫鲄鷊龟鸦黓鱧鱣龕鸦黓龩龧鸺龛鸦黓鴶 Plugin collections 鸠龖鷀鱵鵇鷊龟龰鴷龕龩龧黕黓黏鹰鹭龅龡龟鸦黓鴶鸠龖龤龘龖龭龬鼻

\Drupal\Component\Plugin\LazyPluginCollection

黗鱛鱙黏鹰鹭龅龡龟鳪鳨龰鼅鼻

Drupal\Core\Plugin\DefaultLazyPluginCollection

鳪鳨龰鼅龤鸦黓鴶鸠龖龤黄鳛鱗鸋鼁鱖黀龟鳙鸋鼻

鸦黓鱵鵇鱕鼻龛鷀龰鴷鲔鸦黓龕龰鴷鲔鵠鱒鳤龷龴鶺鶸龕鶛龰鸦黓鱵鵇鱕龰鼅龅鸦黓鱏鱌鼁黿龕龩龧黏麑麒龤鸦黓鶴龪齀麣鱒鳤龷龴鶺鶸龤

龷龴鶺鶸鼻鴶鱫麑麒鸦黓龤龷龴鶺鶸龕龪龡龟鸋黕龕鸡鸈鵎鱈鸇鸦黓龤龰鴷 id

鱆鴥齀麣鱄鴽麣鶖鸦黓鴶龬黏鶴麒鶮 Lazy 鶬鱁齘龕齭龪鰽鹥鴮鰹鰷鰳齭齊鶌鰲鰮龰鴷鲔龕鸦黓鴶鸠龖黏鸴麎龅麑麒鸦黓龤龷龴鶺鶸龕鰬麛麗鵃龟鸦黓鵠麍麨鴟龷龴鶺鶸龰鴷鲔齭龕鵗鹐龪鰪鶖鰨龁鶴龰鴷鲔龅龕齛龪鱬龚鶢齵鰧鸐龕齭黺黈鱕龬鰦龕麖麒麛麗鵠麍龰鴷鲔鹈

龩龧鰥龰鼅龅龡龟鶠鵵龤鸦黓鴶鸠龖鼻

Drupal\Core\Plugin\DefaultSingleLazyPluginCollection

龡鰢鷀鰠鸦黓鴶鱫鲄齮鱵鵇鷊龟鸦黓龕鶒麒鵠麖麛麗龡龟鵠鷅鸺龛黼鸠龖龕齭麖鱵鵇龡龟鸦黓龕齛龪鱬龚鰲鰮龰鴷鲔鰜鷀龤鶢齵鰛鰚鵹鶛鵖鰖龤鹈

龩龧鸇麛麗龛鴽鸦黓鴶龤鸠龖龦龥龅龡龟鼁黿鼻

Drupal\Core\Plugin\ObjectWithPluginCollectionInterface

鱫鲄麖麒龡龟黮鶽鼻

public function getPluginCollections();

鴲鴮 Collection 龪鰑鸋鰐鵦龕黼黮鶽鴮鸇鴾鴽鷊龟鸦黓鴶龕鷊龟龪鰽鹥鴮鰹鰷鰳鳋龟鸦黓鴶鸠龖鱫鲄齀麣鱵鵇鷊龟鸦黓龕鶒鰬鸦黓麛麗麣鵃鸚黮鵦齾龬鵠龕鹌齀麣鵎鷐龡龬鸦黓鰌鸇龡龟鴶龕鱬鸏鰐龇鷊龟鸦黓鴶龕齛鰜鷀鰉鷊龤鰆鰅鶢龕齫齩鹨鸦黓黏龕齀麣鵎齀鰂龤鹨黺鹐齀鰂龤鹨齾鯾黙黗黀龟鴶鱫鲄龕齛鹌龪鷊龟鸦黓鴶龤鱬鷀龕黼黮鶽鴢鴠龡龟鸋黕龕鸡鸈鸇鶌鸁鸦黓齾龬龤鶥鶢鸈龕鸡鸅鸇黼齾龬鼾龤鸦黓鴶鸠龖鹈

龷龴龰龯 id:

龷龴龰龯龤 id 龪龡龟鰨鯼鯹龡龤鱁鯸鯴龕鱁鯸鯴 ’0’ 鵹鯲鱁鯸鯴龪鯱鯮龤 id

龷龴麉麇鯪麅麁鼻

龷龴龤麉麇黺麅麁鹐龪龡龟鳎鳋龤鹿鹻龕齮鹆鹄鵈鵇麨麤鸪龩龕齀齵齮鴑鶃鶛鵖黕黓龕鸐鸏齛龡鹿鹻龪麛麗鵠鸾龤龕鸇鸏龩龧黗龷龴龰龯龭龬黏黪龴龅黀龟鶥鶢鼻

$isSyncing 鼻鯨鯥鸅龕鶌麞龷龴龰龯黗鯡鳤鹿鹻黏龪鳂鵈龚鱰鱯鹇鰉鵙鵹鹣鹟鯞鵨

$isUninstalling 鼻鯨鯥鸅龕黗麅麁鹿鹻黏龕鶌麞龷龴龰龯龪鳂鵈龚鸱黗鹣鹟龤鯞鵨

鸪龚龷龴麉麇鹇麅麁鹇鯡鳤鹇鯡鶏麸龩鯝齮麒龡龟鳡鳝麷麶鷀鯜鯙鹈

龷龴鯖鯓鼻

黺鳎鳋龷龴鸠龖龡齘龕龷龴龰龯鹵麒鯖鯓鶥鶢龕龛 $langcode 鯐麎鯖鯓齊齈龕鳪鳨鸇鯏鯖

黶黲黮龷龴黪龴鼻

龷龴龰龯鼁黿龪龒龎龅黶黲黮黪龴鼁黿鼻

Drupal\Core\Config\Entity\ThirdPartySettingsInterface

鸐鸏龷龴龰龯龭龬龰鼅龅黶黲黮黪龴鯌鳹鶺鶸龤齹齵龕麑鯈黶黲黮龪鵢麛麗黗龷龴龰龯鱫鲄鯐麎黺鶛鯄鯃鮿鴼龤鶺鶸龤鹪鹨龕齛鲓鶺鶸黗龷龴龰龯黏龛 $third_party_settings 鶥鶢鯐麎龕鸡鸈鸇鹪鹨鸈龕鸅鸇龡龟鸡鸅鸠鸋黕龕龪鹪鹨麛麗龤鶺鶸鹈

龷龴龰龯黺黋黈龰龯鸾龤鹐鹆鼻

黗鵙鱯龤龰龯黏龷龴龰龯麒 id 龕鵗黋黈龰龯鲨麒龕鰂鼻 https://www.drupal.org/node/2478811

龷龴龰龯黏龤龷龴鶺鶸鯡鶏鴽鸋黕鼻

齀麣黗龷龴龰龯龬鸥鸤黏鵢龦 config_export 鷀鰠麞麛麗鯡鶏鹧鲓龷龴鵒龕齛鲓鵒齮黺麣鼾鵒鴼鴺鼻

        [ 
          'uuid' => 'uuid',
          'langcode' => 'langcode',
          'status' => 'status',
          'dependencies' => 'dependencies',
          'third_party_settings' => 'third_party_settings',
          '_core' => '_core',
        ];

齛齘龤鴼鴺鲟鳱黏 config_export 鵢龦龤鵒鰛鮷鷓鰉鮴龕黼鸋黕黏鸡鸈龪龷龴鵒龤鶥鶢鸈龕鸡鸅龪鯡鶏龤龷龴鸋黕黏鸠鹊龤鵙鸡鸈龕齩鷂鸥鸤黏鲨麒鵢龦 config_export 鸡龕鹧鹥齮鮰鮮鸠鹊龷龴鸠龖龤龬麾鲔 Schema 龦龥黏 mapping 鶥鶢龤鸡鸈鳱鸇麛麗鯡鶏龤鵒龕黼龷龴鸠龖鸈鸇鼻龷龴龰龯龤龷龴鴣鲰 + 鮫鮪 + 龷龴 id 龕鹻鸬齊齈鸇鼻

$entity_type->getConfigPrefix() . '.' . $this->id()

鸴麎鴣鲟鳱鼻

齩鷂龷龴龰龯龰鼅龅鸦黓鴶鼁黿鼻

Drupal\Core\Entity\EntityWithPluginCollectionInterface

鹧鹥鸴麎鸦黓鴶龤龷龴鶺鶸鹈鮨鹟龷龴龰龯龤 uuid 鮧鮣鹈鸸鸴鮡鮟麎黗龤龷龴龰龯 uuid 鹐黝鴑鮜鹈鰬龷龴龰龯鹐鵈龚鹆鹄鯞鵨鵠龕鵿鵼龷龴麨麤

鮚麎鲀鮗鼻

龷龴龰龯龤齻龛鮚麎鲀鮗鹐鹆龚黋黈龰龯鹖鲀鮗鸈鸇鼻龰龯龬麾 id+ 鶮鼻鶬 + 龰龯 id 鹔龕鵗龪鼻

config:+ 龷龴麨麤鸈鶬龕鶛黏龷龴麨麤鸈鸇鼻龷龴鴣鲰 + . + 龷龴 id

鸴麎黺鹣鹟鵠麖鮖鯮鯝鶌鲀鮗龕龋鴛鲀鮗龤鮖鯮黗龷龴龩龧鱫鲄鮡鮟鵂鴿龅

本书共71小节:

评论 (写第一个评论)