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

鹂麟鼄鹮鹪鵰麥鮦鯸鯭鶐鲘鮧龎龉鴚鲘鮧龟鮦鯸黡龶龳龥龤鲀鲛鮲鮱鵊鵉龄

本书共83小节:

评论 (写第一个评论)