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';

本书共63小节:

评论 (写第一个评论)