16. 网站维护模式

drupal8 龟龝龛龘龕龔龑龍龊龉龅龄龍龂齾龍齻齹龅龄齵齱齭齭齬齪齦齥齤齣齡龟齟齜龘龕齙齗齔齓齏齎齍齋齇齅齂鼾鼼鼹鼷 - 鼱鼰 - 齙鼯 - 齔齓齏齎鼬

齙齗齔齓齏齎鼨鼧龉鼤鼡龅龄鼠鼝齍鼙鼤鼡龅龄鼗 @site 鼝鼌鼈鼆龷鼂龛鼀龟黼黻齍黸黶黴黲黰黮黪黩黥鼬

黢黡齔齓齏齎鼾黟黡黜黚龟黙默黕黔鼾黓黑龟黎黋鼼

黇黆齔齓齏齎龟黂齇鼾鼙黀鼷麾麽麻鼯 kernel.request 麮麭龟齟齜麫麩龟齍麥麢龑麞麚齅麙黇黆齍麗黔鼾麕黶齟麑麏麌麈麄麃麁鹽鹺龟齅麙鹶齅鼾鹵黡齍鹱鹰麑麏鹯鹬鹫鹩麄麃鹽鹺龟齅麙鹽鹧鹤麗鼝鼌鼷鹯鹡齅麙鹶齅鹝鼬

鹛麚黀鼷齔齓齏齎齍鹱鹰鹙鼰鹩鹕鹔鹒鹐鹎齍黪鹊龟鹈鹅 id 鹄鹃鼾鼼

user_maintenance_mode_subscriber

麥麢龑鼼 31 齍鹽鹺龟齵鼼 Drupal\user\EventSubscriber\MaintenanceModeSubscriber 黀鼷鸣鸢鼼 onKernelRequestMaintenance

maintenance_mode_subscriber

麥麢龑鼼 30 齍鹽鹺龟齵鼼 Drupal\Core\EventSubscriber\MaintenanceModeSubscriber 黀鼷鸣鸢鼼 onKernelRequestMaintenance

维护模式服务对象

\core\lib\Drupal\Core\Site 鼗黰鸔鹔齔齓齏齎鹈鹅鹽鹧齍鸑黜黚齔齓齏齎鸎鸋齍黕鹔鸎鸋鸉黰鹕鹔鸣鸢鼼

public function applies(RouteMatchInterface $route_match); 鷵鷴龷鼂麄麃鼾鷰龘龕鷮齣齔齓齏齎鼬

public function exempt(AccountInterface $account); 黇黆齣齡鼾鷰鼝鼌鼙齙齗齔齓齏齎齟麫麩齥齤鼬

MaintenanceMode 鼾黕鹔鸎鸋龟鷥鷢黜黚齍黜黚鷟鷞鷝齍黇黆鼾鷰鷮齣齔齓齏齎黎龕黰鹕鼀鼼

鸔鷚鹱鹰鼾鷰齙齗齔齓齏齎齍鷗鷚龷鼂麄麃鹽鹺龟齅麙鹽鹧鼾鷰鼝鼌鼙齔齓齏齎鼗齥齤鼬

黢黡鷖鷓鸔鹔齅麙鹽鹧龟齟齜鷑鷏鷋鸑鼠鷇黀麚齔齓齏齎鷅鷂鷋齣齡齥齤黙默鸉龘龕鹙鼰齅麙鹽鹧龟鷁鷀鼠鼝齍鷑鶾鶼龅龄鶻鼼

鸉龕鶺龂 _maintenance_access: TRUE 黕鹔鷁鷀龟齅麙鹶齅齍黢黡鼠鶱鼙齔齓齏齎鶮麗鼾鼝鼌齥齤龟齍鶪鶧鶤鶠鼠鼾鷑黶鼬

黲黰黕鹔鷁鷀齟齍黇黆齣齡鼾鷰鷂鼙齔齓齏齎鼗鶟鶝齥齤齍黔鼾鶜鶘齣齡鼾鷰鼱鼰鹩 'access site in maintenance mode' 鶒鶏齍黶鶒鶏鼝鼌鼙鶎鶋齣齡鶉鶆鶒鶏鼗鼱鼰鼬

yunke.content:
  path: '/yunkehello'
  defaults:
    _controller: '\Drupal\yunke\Controller\HelloController::content'
    _title: 'Hello World!!!'
  requirements:
    _permission: 'access content'
 options:  
   _maintenance_access: TRUE

鶅麥麢龑鷚鹫 user_maintenance_mode_subscriber 麢鶃麩齍鸑鶁鹵黡黙默

鸑鵽鼙齙齗齔齓齏齎龟鵼鵻鶮齍鵽麑麏鶪鵺龟黲黰齔齓齏齎鶟鶝齥齤鵷鶒龟齣齡鵶鹫鶪鵺齍鼨鵲鵰鵮鶤齍黶齟鹡鵫鵩黼齣齡鼬

鵧鶎鶃麩 maintenance_mode_subscriber 鹈鹅鼼

鸑鼾黀鼷齔齓齏齎龟鵥鵢鹈鹅齍鵮麢鶜鶘齅麙鹶齅鼾鷰龕鷮齣齔齓齏齎齍鷑鵞鼾齍鵝麫鵚鶜鶘齣齡黰鵙鶟鶝齥齤龟鵷鶒齍鵗鼹鹵黡鵼鵻鼙齔齓齏齎鶮鶤鶠鵕鼾鵔鵑鵏鵎龟齍鵊鵉 \Drupal::service('page_cache_kill_switch')->trigger(); 鵁黜黚鼬

鵙鵷鶒鵽鴽鸎鴹鼡齔齓鼤鼡鶤鶠鴵鹫 503 鴮鴫鼤鼡鼬

鷑鵞黰鵷鶒鵽鼙鶤鶠鴧鴦鴹鼡鴣齋齇黀麚齔齓齏齎鼗鴠鼬

鼙鼈鴟鹄鹬鼗黰鹕鼀龘龕鴝鴛鼼

RouteMatch::createFromRequest($request); 鼾鵊鵉鴘鼂龟齅麙鹯鹬齋齇鼙麄麃鼗鹙鼰龟鴖鴔鵁鴑鴏齅麙鹽鹧齍鼨鵗龘龕鴋鴇鹯鹬齅麙鼬

鹙鼰齔齓齏齎龟鶤鶠齏鴃 drupal_maintenance_theme(); 黕鹔鳿鴔鷖鷓鳻麚鼼 \core\includes\theme.maintenance.inc 鼗鼬

鶅黕鹔鳿鴔鼗鼝鼌麌麈龛鼀鼱鼰鳷麭鼝鼌鳳鷖齔齓齏齎龟齏鴃齍麗鼝鼌鳯鳭鴏鸔鳬齏鳩鷑鵞鳳鷖鵷鳧龟齏鴃齍鹛麚齏鴃龟鷇齣鵗鼙黓黎黋鼗鼬

以上就是drupal8维护模式的全部了。

本书共71小节:

评论 (写第一个评论)