54. 实体类型bundle信息服务entity_type.bundle.info

龺龷龴龳bundle龥龡龝龙龘龕龔龒龎龝龙id龋entity_type.bundle.info齻齷齵齴齳齰齭龋齬齨齥齡齠龎龝龙齻齜齙齕齒齏齍龒龺龷龴龳龎bundle龥龡齻齌齊齆齄齀龎鼽鼹鼶鼵鼲龋bundle齻鼱齬鼰鼯鼭鼫鼩bundle齭齨鼦鼣齻鼡鼞鼝齏鼙鼖齆鼓鼑齬齨鼐鼍鼋鼈鼄鼃鼁黽

龝龙id黺entity_type.bundle.info

龴黺Drupal\Core\Entity\EntityTypeBundleInfo

龺點黛黚黺Drupal\Core\Entity\EntityTypeBundleInfoInterface

齭齨龝龙龴齥齡齠齻黒黑黎齨黊黇齻黃麿麽麹麵getAllBundleInfo()黊黇齻齆麫麩齬齨麨鼁麧黑龺龷龴龳龎bundle龥龡龎麥麢齻麡麝黺

Array
(
   [node] => Array
        (
            [article] => Array
                (
                    [label] => 文章
                    [translatable] => 1
                )
            [page] => Array
                (
                    [label] => 基本页面
                    [translatable] => 
                )
        )
)

麂齬鹾鹼鹹鼑龺龷龴龳id齻麂鹵鹾鼑bundle鹹齻鹴鹰龋齬齨鹮鹫麥麢黺鹧龴鹦鹢龎bundle鹟鹝鹙鹕bundle龎鹦鹒鹐鹍黽

鹦齙龘鹋鹈龔龒鹆鹂齙麝齵齴鹀鸾鸼齏齍龒龎麧黑bundle龥龡黺

        \Drupal::service('entity_type.bundle.info')->clearCachedBundles();
        $bundle_info = \Drupal::service('entity_type.bundle.info')->getAllBundleInfo();
        print_r(array_keys($bundle_info));
        print_r($bundle_info);
        exit();

Bundle龥龡鸝鸜鸘龘cache.discovery鸕龎齙麝cid龒黺

entity_bundle_info:鸒鸏鸌鸈id

麡鸄鸀鷼鸜鸘麥鷸齻鷶鼲鷵鷱鷭鷩麡麝黺

鹆鹂鷧鷣鷟entity_bundle_info鷞齙鷚鷗鷖鷕鷔鷒龎bundle龥龡

鷑鷐鹀鷍麧黑龎龺龷龴龳齻麡鸄龘鷌麑龒鷊鷈鼶bundle_entity_type齻鷶鼲齒鷄麧黑龎龺龷bundle

麂鹵鼰龋齄齀鼫鼩鷟bundle鷞鼦鼣龎鹮鹼齻龘齏齍龒龺龷龴龳龎齬齨bundle鷀龺鶿龋齬齨龺龷齻齜齙鶾鸘齭齨龺龷龎龴龳鶺bundle龺龷龴龳齻齭鶿龋鼑鼵鼲龘龺龷鷌麑鹼龒鶺鶶鷟bundle_entity_type鷞齭齨鹹鶴龎鶲鼡齻鶯鼑鶾鸘齭齨bundle龥龡龺龷龎龺龷龴龳黽龘齏齍龒鷟node鷞龺龷龴龳龋鶾鸘鶫龕龎齻鶪龎bundle龋齬齨鶩鷈龥龡鶥鶡齻齜鼄鶝齄鶴鶙龥龡齻鶾鸘齭齨鶩鷈龥龡鶥鶡鶿鶕鶔齬齨鶩鷈龺龷齻鼡鼞鷟node_type鷞龋齬齨鶾鸘鶩鷈龺龷龎鶩鷈龺龷龴龳齻齜鼄鶾鸘鷟node鷞龺龷龴龳龎bundle龺龷黽

龘鸏齬鼰鷑鷐龺龷龴龳鶒齻麡鸄龺龷龴龳鶏黑bundle齻鷶鼲鼖鶎鶍鼓鼑鶎鶍龎bundle

鹆鹂鶌鶉鷧鷣鷟entity_bundle_info鷞鶇鷖鷕鶃鶁鶀鶌鶉bundle龥龡齻龘鵼鵻鵹鵶麝齭齬鼰龒content_translation鷖鷕鶇bundle鵳齳鼶龋鵯鵬齜鹒鹐龎鹟鵨齻鷧鷣鵦麥鹹鼑黺content_translation_entity_bundle_info_alter齻鵢齊齙麝麑鵞龒黺

core\modules\content_translation\content_translation.module

鵘鵕齬齨bundle龋鵯鵬齜鹒鹐龎齵齴龋黺

\Drupal::service('content_translation.manager')->isEnabled($entity_type, $bundle);

鵑鵎鵌齨鵋鼈黺

鶫龕龺龷龴龳齜鼄鶾鸘鶫龕齻齆龎bundle龋齬齨鶩鷈龺龷齻齜鼄鶝齄鶴鶙龥龡齻鷶鼲鶩鷈龺龷龴龳龋鼄鶾鸘鶩鷈龥龡龎齻齆龎bundle鵉龋鼵鼲鵆鵂鼄鶶鼵鼲鵆鵂龘齏齍龒鵁鶏黑鷄點鶩鷈龺龷龴龳龎bundle齻鶪龋齬齨龺龷鴿齜鼄鶝齄鷟鶩鷈鴼鷞龥龡鴸鵂

鷟龺龷鷞鹙鷟龺龷龴龳鷞龎鴴鴲齻鼑鼵鼲龘drupal9龒鴬鴪鷟龺龷鴨鼫龔鷞鴦齥鴢鴠鴜鴛黛齜鷟龺龷龴龳鷞鴨鼫龔鵆鵂

鴗鷭鼝鼋鼈龎鴓鴑鸼龋鵯鴏鴍鴌鼶齏齍鴉鷔鷟bundle鷞齭齨鹹鴆龎鶲鼡鵆齻龋龎齻鷶鶿龋鷟鴂鵳鷞鴀鷟鳾鳽鳼鳻鷞齻鴗鷭龘齬齨鳸龴齳麄鳶鵳齬鳳鳯龎鳭鹍鳬鳨齬齨鳦龴齻鳢鳟鳞鼑鷣龴齻鳶鵳龎齭鳳鳭鹍鶿龋bundle齻齭齨黑麹鳜OOP龎鳕鳒齻鷣龴黑鳑鴢鳭鹍齻鳢鳟齰鷣龴龋鳑鳐龎鳐齀黽

龘drupal龒鳌麹鶿龋齬齨鳸龴齻鳊鶫龕龴龳鶿龋齬齨鷣龴齻齭鳆鳅鶡鹾鴲龋齥鳃龎黽齷鲿鲼鲻鲹麵鹦齙鶇bundle鲿鲼龎鼩鷌齻鲵麡龋齬齨鷣龴鴲龎龥龡龕龔鲳鲲鲱龎鼩鷌鲯鴀齬齨鲬鼽麥鷸鷖龳鲳鶥鲵鲩鶫齬鳳cms龎鼩鷌鲯鲨鲨黽

本书共83小节:

评论 (写第一个评论)