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龐鼨鷛鳐鳋鳋黿

本书共71小节:

评论 (写第一个评论)