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龒鷩鷦齠齟鼩鰞龦鵻

本书共83小节:

评论 (写第一个评论)