5. 服务容器及Symfony依赖注入组件

龷龷龳龱龮龪龧龦龤龠龜龘龔龓龒龏龋龈龆龤drupal8齳齱齭齩齨齤龪齡齟齝齛齙龏龘齗齖齔龪齳齱龏齑齍齉齅齄Symfony鼮鼫鼧鼦鼥鼢龤drupal8齳齱齨鼠鼜龏鼙鼘齨龓鼠鼗龓

鼕鼓鼒鼐鼙鼏鼋鼊鼇齑齍齉齅鼆鼃鼇鼮鼫鼧鼦鼆龮鼂齨黾黽黻黷黴龏黱黭黬黪黨黤龏黢龤黠黝黛黙黗黖龏黓黏黋黇齤黓黆

黄龜鼮鼫鼧鼦黁黀齤龪鼊麽齨齭齩龒鼮麺麸麴齤龪鼊麽齨麳麯龏麬麫麨龤鼮鼫龏麦龮龪鼮鼫齨鼊麽麣麡麝麜鼊麽齨麙齝鼠龋麘麖麕麓麑龏麬麫麨龤鼧鼦麎龏麊麇麆麨龤鼇鼮鼫鼧鼦鼆龮龪黾齨麆麄龏麀龪鹿鹾齨鹻鹸黆鹴鹲齤龪黝鹱鹰鹭鹪鹦鹢齅鼊麽Validator龏鼏龋鹦鹢鹗鹸鹓鼢鼃鹑鹎鹢鹌鹉鼃鹗鹅鹌鹉鹂鹂龏鹁龘鸿鹑鸻黭鸹鸷黄鹦鹢鸴鸱龏鸭齤鸪鹦鹢鸧齤龪鸣鸟齨鼊麽鸜鸙龏鹴鹲鹗鹸鹓鼢鹭鹪鹦鹢鸧mailer鼊麽鸔鸑龏鸐鸌Validator鼊麽齨set鸴鸱鸉addValidator鸴鸱鸇mailer鸉黱鸃鹦鹢齅鼊麽麣麡麝Validator齨麙齝鸂黏龏鸀Validator鼊麽鼠麨鼏龋麓麑鸻鼐齨鹦鹢齅麆鸔鸑鷼鷻麎龏龮麨龤鸇鼮鼫鼧鼦麝鷺鷷麙齝鸂黏龏龘麨龤鼮鼫鼧鼦齨鷶鷷麎龏龤鸻龤鼕黨黤黁黱黭龮麨龤齤鷲鷱鼢鷭鷪鷨鹪黗黖鷥

鸀齤龪鷡鷝齳齱鼠鷙鷖鷕鷕鼓鼓齨黪麑鼊麽龏鷔鷓齤鷒齨龏鷎鷍鸇龮鷌黪麑鼊麽齱齱麣麡麝齤龪鷉鷈鼊麽鼠龏龒麑齨麕鷆鸐鸌鼊鷄齨齛齙鹱鷀鶽鶹麑鶶鼏龏龮鼂龤鸻龤鼕黨鶳鸴麘鶰鶭鸀drupal8鼠鷖鶫鶨鼓龪黪麑鼊麽龏龘鷍麨鶦麣麡麝麎齤龪鷉鷈鼊麽鼠龏龮龪鷉鷈鼊麽麨鶣鶡齉齅龏龮鷌黪麑鼊麽鶞鷪鶝鶚鶖鼙鶒鶐麨鶣鶡齑齍鶏麨鶌鷪鶝鶚鶈鷻齳齱鼠鶅黪麑齨鶃鶁鶦齤鵽鵹鵸鵴齩龏鸀window鼠麨鶣鶡齑齍龏鹴鹲鸀win7鼠龤鵬鵪鷎齨鹗鵨-鵢鵞-齑齍鵝鷄麑鶃鶁-齑齍龏麨鵛鶽麎齳齱鵗鷖齨齑齍鵓龏鵗龋龮龪齉齅鵑鼏龋鶣鶡齑齍齉齅鶭

麝龮鸂鵐鷄鵎鵌鵊麎鼇齑齍齉齅鼆鼃鼇鼮鼫鼧鼦鼆龏黠黝黛黙黗黖龏鵈鷖鼮鼫鼧鼦龮龪鷭鷪鷨鹪龏鵆鵹麨鵃黴麎齑齍齉齅龮鼂齨鵂鴿龏鸀drupal8鼠鷡鷷鴻鶃鶁鴸龤龋齑齍鼊麽齨鸴鹪麣麡鸀齉齅鼠龏齱鷪麎齤黓鴵鴳黓鴲齨鴱鴰鴮鴭鷖鶫鶨鼓龪齑齍龏黓黏鹿鹾鴩鴩齑齍齉齅鷥

齤龪齉齅鶏鷉鷈鼊麽鵓鸂黏麣麡齨鼊麽鶏鵑鶣齑齍龏黏鴨鴦鴥黗鴡鴝鴛鸴麘黓鴚鷖麕鴖鴒龜鼊麽鵓鷖鴎鷡鸪龏齤鸪龤麴鷷黭鹻鴍鴌齨鼊麽龏鵆鵹鼧鼦麝齉齅鸂黏龏麸麴齤鸪龤齉齅鴋鴇鼊麽齨鴆鴂鴀鴇鸿鳽黭鹻鴍鶽麆齨鼊麽鷥鸀drupal8鼠鷡鷷鴻龤鵹鳻龏齉齅鼊麽鴋鴇鴆鴂鴀鴇鸀鳷龒麕鳶黭鹻鴍鼋鳵鳱齝鼋齄鳰鳯鳬鳪鷥

黓黏麆鴩齤鴩drupal鹲黄黭鸹齉齅齨黆

齉齅齨鳧鸑龤鸀 \core\lib\Drupal\Core\DrupalKernel 鼠龏龘鴒鼗龜drupal鳓鳐鸪龏鳎黠黝麨鼏龋鴩鶽龏龮龪鸪齨龧龒鷼鷻麨龤鳌鳉齉齅龏鼏鳅齉齅鼗龓龒鷥

鸀黭鳃鲿鹉鸌鶃鼠黆

鵈龤鳧鸑齤龪鲽鲻齉齅龏龮龪齉齅鲹鲶麎 鴀鴇鲴 鼊麽鼃鲳麡鼊麽鹂鲰麜齨齑齍龏龋鲯鵹鲮齉齅鳧鸑鶹麑龏鲫麑龮鼂齨鷭鷪龤黨鶳麇鳅

鵆鵹龤鲪鳉Symfony齉齅龏龮龪龤齉齅鳧鸑齨龧龒鷼鷻龏鳧鸑鵹鸇齉齅鴆鴂鴀鴇鲻鶽龏鲨麣麡麝鲳麡鼠龏黓鲦鲣鲢鸇鵽鲞鳎鲳麡鲝鷀鴆鴂鴀鴇龏鲚鲖麎鷡鲔鷼鷻

鶅鵹龤麑鲒鲐鷒鳧鸑齨齉齅鴆鴂鴀鴇鳌鳉齤龪鶅鲍鶹麑齨drupal齉齅龏龮龪齉齅鵑鶣齭齩麕齉齅Drupal 8 run-time Container 龏龘龤鲊鸌黨鴍齨Symfony齉齅龏鲈鲆麎齤鷌鲃鼋龏鲨鱿鷓麎齤鷌鲿鹉鳵鳱齭齩鱼鱺

龋鱸麨龤齉齅鳧鸑齨鱶鱵鷒鱲龏鲒鲐鷒龤齉齅齨麜鱱齝鳧鸑龏龘鶹麑麎Symfony鼮鼫鼧鼦鼥鼢鶏鲰麜龤鸔鷶鶹麑龏drupal齨 ContainerBuilder 鱬鱪麎Symfony齨 ContainerBuilder 鸪龏黢龮鷌鱨鱧黆鱣鱟鷕齑齍齛齙鹱鵝鱜鴀黠龜鱘龱鱕鸻鱟鷕@=鸴鹪齨鱍鱉鱕鱈鱆鱄麑鱂鰾鱕龜齑齍鷭鰺 _serviceId 麙齝鱕鱟鷕鰲鵂齉齅麕鶹麑 set 鸴鸱鼧鼦麴鷷齑齍鱕鰮麊 __sleep 鸴鸱鱕鹿鳅 Drupal\Core\DependencyInjection\ContainerBuilder 鵓龏鰨龮鷌鸻鼐麴龤鸔鷶鰧齉Symfony齉齅龏龠鰤鷎鷍鸀drupal8鸂黏鴆鴂齑齍鴖龤鰧齉Symfony齑齍鴆鴂齨龏龮龪鸌鶃鴖龤鷼鷻鲔鶅鷡龏鶅鰢鰠齨鸌鶃龏鵞黋麎龘鵹黱鸃鴎鷒麨鼕齉鰝鵞黋麎龏黓黏鷎鷍麨麆鴩鴩Symfony齉齅齨鳧鸑鷥

鵈鰛鰛齑齍齉齅鼠鼊麽齨鴆鴂鴀鴇龏鰘鰘鸀php鼠龒黭鹻鴍齤龪鼊麽鲨鰐龘鼏麑龤鰌麫齤龪鸌鶃鶰黁

鵐鼏龋鸐鸌齤龪鸪鴆鴂鵽鲞黭鹻鴍齤龪鼊麽龏鴖鼏龋麓麑鷼鰋鸴鸱鵃黴齤龪鼊麽鱕鵆鵹龒鼏麑龏鼏鼋鰇鳷龒鸐鸌鸪鰅set鸉add龮鼂齨鸴鸱龜鼊麽鷭鰺齤鷌鰁龒齨麙齝龏鴖鼏鼋龤鸀鲪鯾鯽鴀鸂黏鯹鯶齤鷌鱜鴀鱕齉齅鸂黏鷖鼕鼓龪鼊麽龏鹲鴿鴸鷶鷷黭鹻鴍鵹鯲麣麡鸀齉齅鸂黏龏麬麫鼕鸻鯮龆齝鼋龏鵗龋鲰麜龤麣麡鼊麽鯪鯧鯤鯡龏鸀鲝鷀齨麕鷆鳶黭鹻鴍鱕鷖鷌鼊麽黭鸀龔鯞鷡黬黪鳬鳪鳰鳯龏鼊龆龮鼂齨鼊麽鸀鲝鷀麕鴖鸻黭鹻鴍龏黗龤鸀鯛鯚鶹麑麕鳶黭鹻鴍龏鲝鷀麕鯘麝齨黢龤齤龪鲿鵞黗黖龏龮鼂齨鯕鶒鵑鶣鶡鯔龷麊鴲龏鸉鯑麊鴲鱕鷖鷌齑齍黢鳵鲯鯏齉齅鷺鷷鶹麑龏鸻鼊麴龏龠鰤齑齍鵑鷖鯋鷖鯇鷖龮鼂齨麙齝鱕鸀鸭鲦鲝鷀齑齍齨麕鷆鼏龋鯃鯂龤鼐齤龪鼊麽鰇龤龓鼒黭鹻鴍齤龪龏龠鰤鵑鷖鮾鮽鵝鸻鮾鮽齨麙齝鱕鷖鷌齑齍鶡鸪鰅齨鷼鷻鸉鮹鮶鮾鼐鮳鮯龏鹴鹲鱸鴚鮫鮧齨鹦鹢齅龏鮥鵆龤鸻鼐齨鹦鹢齅龏鹁鴸龤鼊黝鹱鹰鶡鹦鹢鶹麑龏麬麫鳷龒鼊龮鷌齑齍鷓齩鼥鮣齛鮠龏龠鰤麨鶽鸹麎齛鮞齨鮛鮚鱕鸀齉齅鳧鸑麕鼏鼋鳷龒鼊齑齍鼊麽齨鱜鴀麓齔鸉鮖鵞鮹鮶鮔齛鮞齨齑齍龏麨鷖麎齉齅鮑鮏齨鮛鮚鱕齑齍龤麴鷷鼧鼦齨鶰鰇龤齉齅鸿鳽黭鹻鴍齨鶰鴖鳷龒鷓齩齛鮠鱕齑齍鼏鼋鳷龒鱜鴀鴖鼏鼋鵝黱鸃齑齍鮾鮽鱜鴀龏麬麫鳷龒鴆鴂鱜鴀鶚鱆鱕鹲鴿齑齍鳷龒鯽鴀鲴鮎鳷龒麊鴲鯽鴀鲴鴚鼢鱕

齉齅鼊麽齨鴆鴂鴀鴇麨龤鮊鮉龮鷌鷺齉鷓齩齨龏鵈鷖龪鮅麽鼊鵹黏齨鼙鼘麨鮄鮃鷕鼓麎鷥

鸀Symfony鼠鷖龪鴒龜 Definition 齨鸪鲿鮁麎齑齍鼊麽鴆鴂鴀鴇龏龘魽龆 \vendor\symfony\dependency-injection\Definition.php ,鳵鲯麎鶈鷻齑齍鼊麽魴鴀鴇齨鵗鷖鸴鸱龏鱸鴚鰛麎鷡鷷鴻鼊麽鴸龤齉齅鸿鳽黭鹻鴍齨龏龘麨龤鼮鴇龮龪鼊麽麣麡齨鯤鯡麆黭鹻鴍齑齍龏鹲鴿龤麴鷷鼧鼦齨鼊麽龏Symfony鴒龜魳鸑魰龏龮鼂齨鼊麽鸀 Definition 鼊麽鸂黏魯鷖鼓魮齨鴀鴇龏鱣鷖齛齙鹱龏鵝魳鸑魰齛齙鷥

黓黏麆鴩齤鴩Symfony齉齅鳯鲿鹉黆

龘鷍鴸魽龆 \vendor\symfony\dependency-injection 黓龏鳵鲯麎魫龪鲞魧麆魥魣齉齅黆

ContainerInterface 黆鲰麜齉齅鲞魧

IntrospectableContainerInterface 黆鷺鲖齉齅鲞魧龏鱬鱪鸿鲰麜鲞魧龏鵗魡鷺鲖麨龤鴩齑齍龤魠黖鲊鸧鴆鴂魴鴀鴇黭鹻鴍鸑麎鼊麽龏鵎鲞魧鸀Symfony3.0鲨鼦鲰麜鲞魧

ResettableContainerInterface 黆鼏龓鰺齉齅鲞魧龏鱬鱪鸿鲰麜鲞魧龏鳵鲯龓鰺齉齅鲃鼋

TaggedContainerInterface 黆魋齛鮞齉齅鲞魧龏鱬鱪鸿鲰麜鲞魧龏龜齉齅魈麊齛鮞鲃鼋

Symfony鴆鴂麎齤龪鴵鴳齉齅黭鸹鸪黆

Container 黆龤齤龪黨黤齨齉齅龏鳵鲯麎鲞魧龒魄齨鲰麜鲃鼋鷥

鷎鷍鸀鳌鳉齉齅齨麕鷆魀魀鳷龒鷔鼓齨鲃鼋龏鵗龋Symfony鳵鲯麎齤龪 ContainerBuilder 龏龘鱬鱪鸿 Container 齉齅龏鹁鳵鲯麎鬾鬼齨鲃鼋麆麳麯鲪鳉齉齅龏鼏龋鴩鶡龤齤龪鬻魳麎齉齅鷼鰋齨齉齅龏鵗龋龘齨黠黝龤 ContainerBuilder 齉齅鲪鳉龏龮龪齉齅鴖龤龧龒鶹麑齨齉齅鷥

鸀鱸鴚鳵麝齨鱶鱵鷒鱲鼠鲪鳉齉齅龏麨龤麑 ContainerBuilder 鲪鳉齤龪鬸齉齅龏鵆鵹鸇齑齍鴆鴂鴀鴇鰮麊鷓鲈龏鯲鷭鰺鬷鷲鱜鴀鼃魳鸑魰鶅鲍鳧鸑齤龪Symfony齉齅鷥

Symfony齉齅鲪鳉鸑鲃鵹龏鸇鲻鶽鶏 dumper )齉齅鴆鴂鴀鴇龏龮龪鲻鶽鷼鷻龤鸧 \core\lib\Drupal\Component\DependencyInjection\Dumper 鸔鸑齨龏鲻鶽麣麡麝鲳麡龏鲨麑龮龪鴆鴂鴀鴇鳉鬳drupal齉齅龏鴖鶣鷻齭齩麕齉齅龏齳齱鵹鲮麨龤麑鵎齉齅麎龏鰛麝龮鸂鵐鼏鼋鷖齤龪鬯鲢龏龜鬮麫鸻鵽鲞鶹麑Symfony齉齅鶰黁鰇龒鲻鶽鯲鳉鬳麬麫鬫鬧龏鬦鬢龤黆齝鼋鶭鬟鵈鲻鶽齨鴆鴂鴀鴇鶦齔鵞龏鲨鶹麑php鴀鼥鳧鹪龏鯲鳻drupal齉齅鴋鴇鸿鳽鳷龒鲈鲆麎鷕鼓鸻鰁龒齨鲃鼋龏龮鼂鼋鷡鷡鳵鳱鱼鱺鵝鲚鲖鳰鳯龏龮鸂鰛齤龪龦麴鹅黆鷕鼓鼠鬛鲯鷄鬙鴸鷖齤龪鬘鬔龏麨龤麦鵃鬑鶡齨鬎鲔鬋鷡龏鬈鬇鬎鼏鼋鼓齨鳷龒龏黗鸀鶅鲍鵃鬑齨鶹麑鱸鷕鼓鲃鼋鬅龤麑鸻麝齨龏龠鰤鶅鲍鵃鬑鷭鷪鳻鲊黪鳷龒鼊鬂鸑鬑鷓齩髿鹑鴆鱆龏鸻黢龤鷱鼢鷭鷪髼髺龏鸀黴髸鼠黱鸃髼髺鴖鲊黪鴩麝龏鰘鰘龤鸻龤龮鼂黁

Symfony容器和drupal容器的区别

Symfony齉齅鶹麑Definition鼊麽鶡齑齍齨鴆鴂魴鴀鴇龏黗drupal齉齅鶹麑php鴀鼥龏鰘var_dump龮龪鴀鼥鬈鬇黓鴌髶鳐黁鴩鶅鵹齨齉齅髲髯

Symfony齉齅鼠齨龋黓鲃鼋鸀drupal齉齅鼠鴸魯鷖麎黆

addCompilerPass getCompilerPassConfig getCompiler compile 黆鰮麊鮑鮏齅龏鵗龋drupal齉齅髨鸱鯲鮑鮏龏龘龤齤龪黖鲊鮑鮏齨齉齅龏鯧龆鮑鮏黓黏鯲髤

merge 黆魳鲨齉齅

addAliases setAliases setAlias removeAlias hasAlias getAliases getAlias 黆鶈鷻齑齍鱧黠

register 黆鼧髞齑齍鼊麽

addDefinitions removeDefinition getDefinitions setDefinition hasDefinition getDefinition findDefinition 黆鴆鴂鴀鴇鶈鷻

findTaggedServiceIds findTags findUnusedTags 黆齛鮞鶈鷻

龋鱸龮鷌鲃鼋髛鸻鼋鸀drupal齉齅鶏齭齩麕齉齅鵓鼠鶹麑麎

drupal容器不支持的Symfony容器语法

齉齅鴆鴂鴀鴇dumper齨麕鷆鸻鱟鷕decorated鴆鴂 龏drupal 齉齅鸻鱟鷕龮龪龏鵎麙齝鰁髙鸀Symfony齉齅鲪鳉齡齟鴆鴂鮑鮏pass黋高鱕

yaml鴚鼢鸻鱟鷕@=鱍鱉龏龮鼂齨鶐鸱鸀drupal鼠髗麑

什么是容器编译

鷎鷍髕髑齉齅鼠鷖鷌齑齍鼊麽龤鲃鼋鯪鰅齨龏鸃鷍鶦麑齛鮞tags鴻鸑齤鼥龏麀龪鮹髏齨鵛鹸黆鸀鼊鲳麡鷓齩鲣鲢齨麕鷆龏鳷龒髌髋髇鱆龏齤髅髌髋麨龤齤龪齑齍龏drupal鷨髁鼏龋鴆鴂鸿鳽齨髌髋龏黢龒鼊龮龪髌髋齑齍髀鱸髌髋齛鮞鶶鼏龏龮鼂鸀鲣鲢鲳麡齨麕鷆麨鷙麓麑龮龪髌髋龏麬麫鲢龦麆麎龏龤鸀鵴齩鲣鲢骼骻齨麕鷆鳶鲈骻骹龮鷌髌髋骶黁黱黭龤鸀齉齅鳧鸑齨麕鷆麨黖鲊骻骹鶽麎龮鷌髌髋龏鲨麦鸃鷍黀鶡鱜鴀鯹鯏麎鲣鲢髇鱆髌髋鮁鼊麽龏龮龪鷼鷻麨龤齉齅鮑鮏龏骵骳齨鰛齉齅鮑鮏麨龤鴋鴇齛鮞鯤鯡鳉鬳齑齍鼊麽鼗鬛齨鯧齳龏鸉鳻麓齔齤鷌齉齅鼊麽齨鱜鴀龏骲鼗麨龤鼊齉齅鸂黏齨齑齍鼊麽鶡鷌髲髯鷼鷻鷥

在构建容器时,drupal如何给出服务对象的定义数据

鸀鲪鳉齉齅齨麕鷆drupal鸐鸌齑齍骯骫鴆鴂鴚鼢services.yml鴚鼢鵝齑齍鳵鲯齅 ServiceProvider 麆龜齉齅鰮麊齑齍鴆鴂鴚鼢龏鯪鹴services.yml黗鴡齑齍鳵鲯齅鷖鷔鼓齨鸿鸧鱺龏龘黭鸹 ServiceProviderInterface 鲞魧龏鼏龋鸔鸑services.yml齨鵗鷖鷼鷻麴龏鰇鼏龋鶈鷻齉齅鮑鮏鷥黗services.yml鵝 ServiceProvider 龤鰌麫麆齨鶰黁龤鸐鸌 Drupal\Core\Extension\ExtensionDiscovery 鸪骣骡鵗鷖齨鳓鳐齄鱍鱉鷨髁骹鶽麆齨龏龮鸂骠骟齤龪鰐鼕鼓鴱鼙鳻鷨骛齨鮛鮚龏鯧龆鷨髁齨黠黝龏鼕鼓骙骘骔鷨髁鵗鸀鴚鼢骒黠鼃.info.yml鴚鼢黠鼃.info.yml鴚鼢鸂黏齨name骑龏鴩鸔 ExtensionDiscovery 鸪齨黭鸹鵹麨鷙鵌鵊鴚鼢骒黠鵝鷨髁黠髨鯧龏鴚鼢黠鳶龤鷨髁黠龏鸂黏齨 name 骑鱣鱣麑龆鵹鵸骐骎鷥

关于服务容器的补充

1黆鸀骊骉鷭鰺鴚鼢鼠鼏龋鷭鰺齭齩麕齉齅鸪龏鴵鴳龤 \Drupal\Core\DependencyInjection\Container 龏鹭鹪黆 $settings['container_base_class']=“\Drupal\模块名\Container 鼆鱕黀鵐鳷龒鮳驽鲃鼋麕鼏龋鱬鱪鴵鴳齨鸪龏鴆鴂齤鷌鼒鲃鼋龏鸐鸌龮龪鷭鰺齭齩麕齉齅麨鼏龋鸿鴆鴂麎鷥

2黆龒鰘鴩齤鴩齭齩麕齉齅齨鴆鴂鴀鴇龤鬮麫鼂鹸黁drupal8鴸鳵鲯麎驷鷌黪麑齑齍黁驴麑phpMyAdmin髀鴦鴀鴇鲴龏骹麝 cache_container 鴀鴇鮁龏黓鴲鸂黏齨data黝齟鷺齉龏鯘麝齤龪鱍鱉黠龜bin齨鴚鼢龏龘麨龤齉齅鴆鴂鴀鴇齨鲳麡鴚鼢龏鷺齉龤鲊鸌鶁鵛鴍齨龏 unserialize print_r 鶶鼏鴩麝黆

print_r(unserialize(file_get_contents("cache_container-data.bin")));

3黆鸀齉齅鮑鮏齨麕鷆鷖龪鮳驽齨齛鮞黆 { name: service_collector, tag: tags_name, call: add } 龏驘驖龤骻骹鵗鷖齛鮞龜 tags_name 齨齑齍龏鲨麦龘鷍鼮鲦鷻龜驒麓 add 齨鱜鴀龏鸀drupal鼠鷖鷕鼓龮鼂齨麑鸱龏黬黪驐髸鸴麘

4黆齉齅龮麫鴌龏齑齍鼊麽鴸鸀齉齅鸂黏龏鸀鲿鹉鸂黏鰌麫鷀鯘齉齅黁 \Drupal::getContainer(); 鶶鼏龏鸀drupal鳓鳐 DrupalKernel 鳉鬳鸔齭齩麕齉齅鵹龏麨鸇鸃鼧鼦麝麎鷶驋鸪drupal齨骯骫麙齝鸂黏黆 \Drupal::setContainer($this->container); 龏龠鰤鵐鼏龋鸀鸷驘驅鸴鷀麝齉齅龏鲨鶹麑鸂黏齨齑齍龏鹴鹲龒鶈鷻鴀鴇鲴龏鷀麝鴀鴇鲴鼊麽龏鲿鹉鹲黓黆 \Drupal::getContainer()->get('database'); 鷶驋鸪Drupal鴖鳵鲯麎鷕鼓黪麑鸴鸱龏鹴鹲鲝鷀鴀鴇鲴鵑鼏龋龮鼂龱黆 \Drupal::database(); 龏龮鼂齨龱鸱鸀鷺鷷麨龤鸐鸌驃黏齨鸴鸱黭鸹齨龏黢鸻鸌鶡麎鲹鴭龏鷔麊鸴麘鶹麑

5黆鼏龋鸀骊骉騾鰺鴚鼢鼠鰮麊services.yml鴚鼢龏龮鸂鰮麊齨services.yml鴚鼢騼鵈鷈鹴齳齱鳵鲯齨鳱龏鹴鹲 /sites/default/services.yml 麨龤鸀騾鰺鴚鼢鼠鰮麊齨龏龘鼏龋騴騳齳齱鳵鲯齨骑龏龠鰤騲騱騯騭齳齱鳵鲯齨齑齍麕鼏龋鶹麑鰤鸴鸱龏鹭鹪龜黆 $settings['container_yamls'][] = '/services.yml';

本书共78小节:

评论 (写第一个评论)