23. 渲染占位符及其产生器

drupal龤龠龟龝龙龖龓龑龏龎龌龎龈龆龃龀齽齹齶齳齲齰齮齭齩齧齤龈龀齽齣齟齜龠齛齘齕齛

齮齭齑齏齌齋齉齈齄
1齄鼾鼽鼼鼺鼸龈鼷鼶鼷鼳龎齰鼯鼯鼬鼷鼨鼦鼢鼷鼳齰鼞鼜鼷鼘鼺鼸鼯鼔鼐龎龠鼏鼎鼢鼷鼳齰鼜鼍鼾鼷鼋龎龠鼏鼈鼢龈鼇鼄齣齟鼁黿齟鼷鼋黼黸黴龈鼢黲黮龎齰黭鼢黫黨齰黴黤黢點黜黛黙齋默黗黔黒黏
2齄鼾黉黅黁麽麺麶齛麵麱麮齰麪麦麥齤麽麺齰麢麡麞麝齰黴鼘鼽鼼齣齟龎麚麗麖麓齤黏齰龤龠齣齟鼢黲黮齰麑齌麎麽麺麶齛麵麱麮龎麊麉麈麆麅齩齰鼢麃鹿齣齟
3齄鼾黉黅黁鹷麮齤黒鹴齰齣齟鹲鹱鹰鹬鹪齰鹨鹤鹢鹡齣齟鹟鹿麚麗齰麑齌麎黴麊麉黅黁麈麆麅齩鼢麃鹿齣齟


鹞黙鹝鹙鹘鹖齰鹒鹤鹏黢鹎鹍齤麓鹌齣齟鹘鼇鼦齄黙齋默鹋鹉鹅鹋鼽鹂齰鸾鸼黴黉鸸鸷鸳鸲齣齟鼢黲黮鸰鹡黒黏
鹝齌鸭鸫龙龖龓龑龏齰麎黴黉齣齟鼢黲黮龎黅黁麉鸧麅齩齰鼄鸸齩龎鸥鸡鸭鸫鼷鼘龙龖龓齰鸞鸛鼯齣齟黲黮龎黅黁齰龟龝鼽鸙齣齟鸘麅黔鸔鸛鸒鸑鸔龙龖龓鸏鸋鸊麎齣齟鼢黲黮龎黅黁龟龝鸛鸇鸃鸁鷽鷹鷵
麑齌鷱麅龟龝黔鷮龎龙龖龓龑龏龈鷭鷪鼾龠龎齰麗鷦黙齧龈麎齽鷣鷠鹋齽黗黔龎黅黁鷜龤龠齣齟鼢黲黮龎黅黁鷚鷗鷕龟龝齰鷑鷎齣齟齳齲鷋
鷉鷇鼺鼸鼬麊麉龈鷅齣齟黲黮鸙鷁鶾龠龙龖龓龎黒鶺黜黛鶶Auto-placeholdering鶚鷜鶖鷣龙龖黒鶺鷚齰鶕龈鶓鹰鶖鷣龎鶒黸齤鶐鶏鸔龟龝鶌鸫
黁鶈鶅黔鼁龎renderer.config齤龈鵺鶌鸫齰鵶鵲鹪鼜齋齄鷜鵱鵯鵮黅黁鵬鷚

麑齌鷱鵩鼄auto_placeholder_conditions鼁麑齌鵤鵠鹤鵜鵚齣齟鼢黲黮龎鵙龌鵖鵕鵑鵠龆鵶鵲鶌鸫龃齰黴黉麎麃鹿龙龖龓鸁鷽
鼇鶌鸫麞鵎龎黅黁齤鼇鶏鸔鵌鵉龎鵇鵃鴿鴾齰黴黭龈鵌鵉鴺麺龎鼷鼘鴷鼇黅黁鷋
黴鼘鵶鵲鹪龈鼄core.services.yml鼁鵑鵠龎齰龠鼏麑齌鼄\sites\default\services.yml鼁鶖鵠鴩齰鶕鹤鴧鴦鴣鴟龀鴜龎鶌鸫

[renderer.config] => Array    
                 (    
                     [required_cache_contexts] => Array    
                         (    
                             [0] => languages:language_interface    
                             [1] => theme    
                             [2] => user.permissions    
                         )    
     
                     [auto_placeholder_conditions] => Array    
                         (    
                             [max-age] => 0    
                             [contexts] => Array    
                                 (    
                                     [0] => session    
                                     [1] => user    
                                 )    
     
                             [tags] => Array    
                                 (    
                                 )    
                         )   

下面来看看drupal具体是怎么实现占位符机制的:

鼇龤龠龙龖龓龑龏龎黅黁鴛龈齣齟鼢黲黮龎齰鼄鴙鷪龎龟龝鴖鶺鼁麎麓黴麊麉黅黁龎龟龝麈麆麅齩齰鼄鸇鸛麃鹿
龆鵺齹齶鴔龟龝黔鷮鵠鴩龃鼷鼘黜黛鷗鷕鴐鴍龎鴋鼎齄$elements['#lazy_builder']齰鶕龎鹪龈鼷鼘鳷鼾鳳鼘鼨鼦龎黔鷮
鳲鼷鼘鼨鼦鳮鼐鷹鳪齰鳲鳩鼘鼨鼦鳮鼐鷹鳪龎鶅黔齰鶅黔鵕鳨龏龆鼯鹉鳤黔鸔鳣鳡鳞NULL
鼇麃鹿龙龖龓龑龏龟龝龎黅黁鳖鳓鸭鸫鷗鷕鴐鴍齰龤龠鷹鳪鳏鳎黅黁
鸭鸫龃鷗鷕鴐鴍龎龟龝黔鷮鳮鼐鳋龟龝黔鷮龎鹝鼾黅黁鵖鸾鷗鷕鴐鴍鷹鳪鳏鳎齰鹲鼾黒鵎龎鳇齳黭鹲鼾鳃鼨鼦
鷽鳂鳀鲼齤龈鳋龟龝黔鷮鼢鲻鲺鼾'#lazy_builder','#cache','#create_placeholder'鲵鲳龎鼨鼦齟鼄
鲰麓黴鼳龎龟龝黔鷮麃鹿龟龝鼽齹齶鷉鷇鶕齲鼢齲齘鳋鼢鳋鳏鳎龙龖龓齰鼜鼍麑齌鲯鲭黒龟龝齰鲪鼄鲩龟龝黔鷮鼁鳏鳎鼷鼘龙龖龓鷜麖鲰鸼鲥鼽鲡鷹鼷鼘龙龖龓鲞龆龟龝鲜鼍markup鷚
鷉鷇齘鳏鳎龙龖龓龎鲕鲞龈鸾龟龝龙龖龓鳏鳎鶈鵇黢龎齰鶕鼄黁鶈鼁龎鲑鲏id龆render_placeholder_generator
鳣鵇黢齄Drupal\Core\Render\PlaceholderGenerator 鶕鵇黢龃鲇鲃齄Drupal\Core\Render\PlaceholderGeneratorInterface
鳋鲇鲃鹷鱽鱺齰鳷鼾鹘鼘鸡鱹齰麉麱麓鹌鸼齲鼢齲鷜齹齶齲鷅鱸鴍鷚鹋鳋鼢鳋鷜鸑鸔龟龝鶌鸫鷉鷇龈鷅鹌鳋鱸鴍鷚鹋鱸鴍龙龖龓鷜鱵鱴齮齭鱸鴍鲕鲞鷚
齩鷱鼷齋龟龝龙龖龓鳏鳎鶈龎齮齭鵇黢齄
鱱鱰龖鸼齄Drupal\Core\Render\PlaceholderGenerator鷜鱯齄鼄麗齹鱮鸛鱪默鱦鼁鵖龤龠鼎鱢鱟鹂鵑鱱鱱鱰龖鸫齰鷱鵩黴鱝鱜鱘鹌麑齌鱖黒鳣鱓鱒鶈鱑鱍默鱌龖鸫鷚
canCreatePlaceholder鸡鱹齄鼇鱸鴍龙龖龓鳖鳓鼇齟鼄鷗鷕鴐鴍#lazy_builder齰齌鱋#create_placeholder鼢龆false鳞鼢鸭鸫
shouldAutomaticallyPlaceholder鸡鱹齄鶏鸔龟龝鶌鸫齩鷉鷇龈鷅鹌鳋鶾龠龙龖龓龑龏
createPlaceholder鸡鱹齄麑齌鷱鵩鷹鳪鶅黔龈鼷鼘鱢龓鱊鱈鱇齰鲡鷹龎龙龖龟龝黔鷮鳷鱃鱂齄#lazy_builder鹋#cache鹋#markup鹋#attached齰鰿鼁#markup鱃鱂龎黅黁齤龈龙龖龓齰麑齌鷱鵩鳪鰻鸏鸋

总结注意:

龙龖黅黁鸾鷹鳪鳏鳎齰鹝齌鶾龠龙龖龓龑龏鼽齰#lazy_builder鳖鳓齟鼄
鸭鸫#lazy_builder鼽鼜鼍齟鼄#create_placeholder鰿鹪龆false,麎鼢鹤鳏鳎龙龖龓齰鷁龈鰸鲇龟龝齰黴鷪龠鸼鸑龟龝
#lazy_builder鵑鵠龎鷹鳪鲡鷹龎龟龝黔鷮麎鼄鰷鲳鼷鼘龟龝黙齋默鼁龟龝齰鶕龎鳃鼨鼦麑齌龈鰳鰲龎齰鼜鼍龈鹪鶐麃鹿齣齟龎黅黁麎鹤鵕齣齟齰黴鰯鰬鸼龟龝龎鶖鰫鰧鰯鳪龠鵇黢
鸇鸃鲡鷹龎龟龝鼺鼸鹤黫鲪鹝鼾龎齣齟鳇齳黔鸔齰鱃鰤龙龖龟龝黔鷮龎黔鸔齰黴黉黔鸔鹤鵕drupal龎鷣鷠齣齟鼶鰢龠鵩

本书共63小节:

评论 (写第一个评论)