Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Drupal モジュール開発入門講座 第9回 構成

Drupal モジュール開発入門講座 第9回 構成

More Decks by アクイアジャパン Acquia Japan

Other Decks in Programming

Transcript

  1. ୈ9ճ ߏ੒ Drupal Ϟδϡʔϧ ։ൃೖ໳ߨ࠲

  2. Drupal Ϟδϡʔϧ։ൃೖ໳ߨ࠲γϦʔζ – DrupalͰ͸ʮϞδϡʔϧʯͱݺ͹ΕΔɺখ͞ͳιϑτ΢ΣΞΛ࣮૷͢Δ͜ͱͰػೳ֦ுΛߦ ͍·͢ɻຊ΢ΣϏφʔγϦʔζͰ͸ɺDrupalͷϞδϡʔϧ։ൃʹؔ͢Δجૅ஌ࣝΛղઆ͠· ͢ɻ – DrupalͷόοΫΤϯυपΓʹ͍ͭͯମܥతʹֶͼ͍ͨํɺࣗ෼ͰΧελϜϞδϡʔϧΛ࡞Ε ΔΑ͏ʹͳΓ͍ͨํɺΞΫΠΞೝఆσϕϩούʔࢼݧΛ໨ࢦ͢ํʹ͓͢͢ΊͰ͢ɻ –

    DrupalΛҰ௨Γૢ࡞ͨ͜͠ͱ͕͋ΔํΛର৅ͱ͍ͯ͠·͢ɻ·ͩDrupalΛ৮ͬͨ͜ͱ͕ແ͍ ํ͸ɺॳ৺ऀ޲͚DrupalνϡʔτϦΞϧಈըʢ೔ຊޠʣΛઌʹݟ͓ͯ͘ͱΑΓཧղ͕ਂ·Γ ·͢ɻ
  3. ΞδΣϯμ 1. ߏ੒ͱ͸ 2. Configuration APIͰ؆қߏ੒Λૢ࡞͢Δ 3. ϑΥʔϜͰߏ੒Λૢ࡞͢Δ 4. ߏ੒ͷ্ॻ͖

    5. ࿅श໰୊
  4. ߏ੒ͱ͸

  5. Drupalͷઃఆ εςʔδϯάαΠτɺຊ ൪αΠτͳͲෳ਺؀ڥ༻ ҙͯ͠Δ৔߹΍ɺνʔϜͰ ։ൃΛߦ͍ͬͯΔ৔߹ɺ Ͳ͏΍ͬͯͦͷઃఆ಺༰ Λڞ༗͢Δʁ

  6. Drupalͷσʔλͷछྨ DrupalαΠτͰѻΘΕΔσʔλ͸ओʹ4छྨʹ෼ྨ – ContentɿαΠτ๚໰ऀʹදࣔ͢Δ͜ͱΛ໨తͱͨ͠ςΩ ετɺը૾ͳͲͷ৘ใɻ – ConfigurationɿαΠτͷಈ࡞ɺදࣔํ๏ͳͲΛఆٛ͢Δ ৘ใɻ௨ৗ͸খ͞ͳςΩετͰදݱ͞ΕΔ܏޲ɻ – Stateɿcronδϣϒ͕࠷ޙʹ࣮ߦ͞Εͨ࣌ࠁͳͲɺαΠτ

    ͷݱࡏͷঢ়ଶʹؔ͢ΔҰ࣌తͳੑ࣭ͷ৘ใɻ – SessionɿϩάΠϯ͍ͯ͠Δ͔Ͳ͏͔΍CookieͳͲɺݸʑ ͷαΠτ๚໰ऀͷαΠτͱͷ΍ΓऔΓʹؔ͢Δ৘ใɻ https://api.drupal.org/api/drupal/core%21core.api.php/group/info_types/
  7. Drupalͷσʔλͷछྨ DrupalαΠτͰѻΘΕΔσʔλ͸ओʹ4छྨʹ෼ྨ – ContentɿαΠτ๚໰ऀʹදࣔ͢Δ͜ͱΛ໨తͱͨ͠ςΩ ετɺը૾ͳͲͷ৘ใɻ – ConfigurationɿαΠτͷಈ࡞ɺදࣔํ๏ͳͲΛఆٛ͢Δ ৘ใɻ௨ৗ͸খ͞ͳςΩετͰදݱ͞ΕΔ܏޲ɻ – Stateɿcronδϣϒ͕࠷ޙʹ࣮ߦ͞Εͨ࣌ࠁͳͲɺαΠτ

    ͷݱࡏͷঢ়ଶʹؔ͢ΔҰ࣌తͳੑ࣭ͷ৘ใɻ – SessionɿϩάΠϯ͍ͯ͠Δ͔Ͳ͏͔΍CookieͳͲɺݸʑ ͷαΠτ๚໰ऀͷαΠτͱͷ΍ΓऔΓʹؔ͢Δ৘ใɻ https://api.drupal.org/api/drupal/core%21core.api.php/group/info_types/
  8. ߏ੒ͱ͸ – ߏ੒ͱ͸ɺαΠτͷಈ࡞ɺදࣔํ ๏ͳͲΛఆٛ͢Δ৘ใΛද·͢ɻ – DrupalͰ͸ߏ੒ΛҰ؏ͨ͠ํ๏Ͱ ѻ͏͜ͱ͕Ͱ͖·͢ɻ – ίΞͷConfiguration ManagerϞ

    δϡʔϧ΍DrushίϚϯυΛ࢖༻ ͯ͠ߏ੒ΛΠϯϙʔτɾΤΫε ϙʔτͰ͖·͢ɻ – ͜ΕʹΑΓ؀ڥؒͰߏ੒ΛಉظͰ ͖·͢ɻ _core: default_config_hash: VDJxTZtQR21qB4l langcode: en uuid: 5a62ea13-3cb0-4db7-9 name: 'λϐΦΧ٤஡ళ ·Δ஡' mail: [email protected] slogan: '' page: 403: '' 404: '' front: /node admin_compact_mode: false weight_select_max: 100 default_langcode: en system.site.yml
  9. ߏ੒؅ཧΛ࢖͍࢝ΊΔखॱ 1. ߏ੒ϑΝΠϧΛ഑ஔ͢ΔಉظσΟϨΫτϦͷ࡞੒ – ϓϩδΣΫτϧʔτ௚Լʹ config/default σΟϨΫτϦΛ࡞੒͠· ͢ɻʢσΟϨΫτϦ໊͸ͳΜͰ΋OKʣ
 2. ಉظσΟϨΫτϦΛDrupalଆʹೝࣝͤ͞ΔઃఆΛ௥Ճ

    – settings.phpʹ 
 $settings['config_sync_directory'] = '../config/default'; 
 ͷߦΛ௥Ճ͠·͢ɻ
 3. ؔ࿈Ϟδϡʔϧͷ༗ޮԽ – ؅ཧը໘͔Βߏ੒ΛΠϯϙʔτɾΤΫεϙʔτ͍ͨ͠৔߹͸ ʮConfiguration ManagerʯϞδϡʔϧΛ༗ޮԽ͠·͢ɻ·ͨ͸ DrushίϚϯυ͔Β΋ૢ࡞Ͱ͖·͢ɻ 
 ಉظσΟϨΫτϦ͸Ͳ͜ʹ഑ஔ͢Δ΂͖ʁ • ΢Σϒ͔ΒΞΫηεͰ͖ͳ͍Α͏ʹ
 υΩϡϝϯτϧʔτͷ֎ʹ഑ஔ͢Δ͜ ͱ͕ଟ͍ • υΩϡϝϯτϧʔτҎԼʹ഑ஔ͢Δ৔ ߹͸σΟϨΫτϦ໊ʹϋογϡ஋ͳͲ Λར༻ͯ͠ਪଌ͞Εͳ͍Α͏ʹ͢Δɺ ΋͘͠͸ΞΫηεͰ͖ͳ͍Α͏ʹ apacheͳͲͰઃఆ͢Δ

  10. ߏ੒؅ཧͷओͳૢ࡞ – DrupalαΠτͷߏ੒ΛYAMLϑΝΠϧͱͯ͠ΤΫεϙʔτ͢Δ
 $ drush config:export
 – YAMLϑΝΠϧ͔Βߏ੒ΛDrupalαΠτʹΠϯϙʔτ͢Δ
 $ drush

    config:import
 – YAMLϑΝΠϧͱσʔλϕʔεͷɺߏ੒ઃఆͷࠩ෼֬ೝ
 $ drush config:status
 – ߏ੒ઃఆΛίϚϯυϥΠϯ͔Β௚઀ઃఆ͢Δ
 $ drush config:set system.site name 'λϐΦΧ٤஡ళ ·Δ஡' ؅ཧը໘΋͘͠͸DrushίϚϯυͰૢ࡞͕ߦ͑·͢ɻԼه͸DrushίϚϯυͰͷྫͰ͢ɻ YAML ϑΝΠϧ ίʔυϕʔε σʔλ ϕʔε Πϯϙʔτ ΤΫεϙʔτ DrupalαΠτ
  11. ߏ੒ͷछྨ – ؆қߏ੒ɿओʹਅِ஋ɺ੔਺ɺจࣈྻͳͲͷ஋͕֨ೲ͞ΕΔγϯ ϓϧͳߏ੒Ͱ͢ɻͦΕΛఏڙ͢ΔϞδϡʔϧʹͷΈґଘͰ͖·͢ɻ
 ྫɿsystem.siteɺdblog.settings ͳͲ – ߏ੒ΤϯςΟςΟɿϢʔβʔ͕࡞੒ɺ࡟আͰ͖Δ৘ใͷϦετΛ֨ ೲ͠·͢ɻߏ੒ΤϯςΟςΟ͸ಈతͳґଘؔ܎Λ࣋ͭ͜ͱ͕Ͱ͖· ͢ɻґଘؔ܎͸ɺϞδϡʔϧɺςʔϚɺ·ͨ͸ΤϯςΟςΟʹ͢Δ

    ͜ͱ͕Ͱ͖·͢ɻ
 ྫɿnode.type.articleɺimage.style.wide ͳͲ ࠓ೔͸ओʹ؆ қߏ੒ʹ͍ͭ ͯղઆ͠· ͢ɻ
  12. ؆қߏ੒ͱߏ੒ΤϯςΟςΟͷݟ෼͚ํ system.site: type: config_object label: 'Site information' mapping: uuid: type:

    uuid label: 'Site UUID' ...লུ... system.menu.*: type: config_entity label: 'Menu' mapping: id: type: string label: 'ID' ...লུ... – ֤ϞδϡʔϧͰఆٛ͞Ε͍ͯΔεΩʔϚϑΝ Πϧ(*.schema.yml)ͷத਎Λ֬ೝͯ͠ɺτο ϓΩʔͷ௚Լͷtypeͷ஋Λ֬ೝ͠·͢ɻ – typeͷ஋͕
 config_objectͷ৔߹͸؆қߏ੒ɺ config_entityͷ৔߹͸ߏ੒ΤϯςΟςΟ 
 ͱ൑அͰ͖·͢ɻ system.site͸؆ қߏ੒Ͱ͋Δ system.menu.*͸ ߏ੒ΤϯςΟ ςΟͰ͋Δ system.schema.yml
  13. ߏ੒ͷ֨ೲʹ͍ͭͯ – Drupalʹ͸ΞΫςΟϒͳߏ੒ͱ͍͏֓೦͕͋Γ·͢ɻ͜Ε͸αΠτ Ͱݱࡏ࢖༻͞Ε͍ͯΔઃఆͷ͜ͱͰ͢ɻ – ߏ੒৘ใ͸σϑΥϧτͰ͸σʔλϕʔε(configςʔϒϧ)ʹอଘ͞Ε ·͕͢ɺϩʔΧϧϑΝΠϧ΍ଞͷόοΫΤϯυʹ֨ೲ͞ΕΔ͜ͱ΋ ͋Γ·͢ɻ – ͔͠͠ͳ͕Βɺߏ੒͕Ͳ͜ʹͲͷΑ͏ʹ֨ೲ͞Ε͍ͯΔ͔Λؾʹ͢

    Δඞཁ͸͋Γ·ͤΜɻ։ൃऀ͸ৗʹConfiguration APIΛհͯ͠ΞΫ ςΟϒͳߏ੒ʹΞΫηε͢Δඞཁ͕͋Γ·͢ɻ
  14. – ߏ੒৘ใͷϑΝΠϧܗࣜ͸YAMLͰ͢ɻ – 1ͭͷYAMLϑΝΠϧ = 1ͭͷߏ੒ΦϒδΣΫτ
 ͱͳΓ·͢ɻ – ߏ੒ϑΝΠϧ໊͸΄ͱΜͲ͕ 


    ϞδϡʔϧͷϚγϯ໊.೚ҙͷจࣈྻ.yml 
 ͱͳ͍ͬͯ·͢ɻʢྫɿsystem.site.ymlʣ – ϑΝΠϧ໊ͷ ϞδϡʔϧͷϚγϯ໊.೚ҙͷจࣈྻ ෦෼͕ߏ੒Φ ϒδΣΫτͷ໊લʹͳΓ·͢ɻ ߏ੒ϑΝΠϧͱߏ੒ΦϒδΣΫτ SystemϞδϡʔϧͷ ߏ੒ϑΝΠϧʢҰ෦ʣ ϑΝΠϧͷ1 ͭ1͕ͭߏ੒ ΦϒδΣΫτ ͱͯ͠ѻΘΕ Δɻ
  15. ߏ੒εΩʔϚ system.site: type: config_object label: 'Site information' mapping: uuid: type:

    uuid label: 'Site UUID' constraints: Uuid: [] NotNull: [] name: type: label ...লུ... system.maintenance: type: config_object label: 'Maintenance mode' mapping: ...লུ... system.cron: type: config_object ...লུ... system.date: type: config_object label: 'Date settings' mapping: first_day: ...লུ... – Ϟδϡʔϧ͸ಠࣗͷߏ੒σʔλΛ༻ҙ͢Δ ͜ͱ͕Ͱ͖ɺσʔλܕΛఆٛ͢ΔͨΊͷ εΩʔϚϑΝΠϧΛ༻ҙ͢Δ͜ͱ͕Ͱ͖· ͢ɻ – ϞδϡʔϧσΟϨΫτϦͷ config/schema/ *.schema.yml ͱ͍͏ϑΝΠϧΛ༻ҙ͠ ͯɺYAMLܗࣜͰϧʔϧΛهड़͠·͢ɻ – 1ͭͷϞδϡʔϧʹෳ਺ͷߏ੒ϑΝΠϧ͕ ༻ҙ͞Ε͍ͯΔ৔߹Ͱ΋ɺ1ͭͷεΩʔϚ ϑΝΠϧʹશͯهड़͠·͢ɻ system.schema.yml SystemϞδϡʔϧ ͸ෳ਺ͷߏ੒ϑΝ ΠϧΛ͕࣋ͭɺε ΩʔϚ৘ใ͸શͯ system.schema.y mlʹهड़͞ΕΔɻ
  16. ϞδϡʔϧΠϯετʔϧ࣌ʹॳظ஋Ληοτ͢Δ – Ϟδϡʔϧઃఆʹ͸ɺॳظ஋Λઃఆ͢ Δ͜ͱ͕ՄೳͰ͢ɻ – ϞδϡʔϧσΟϨΫτϦʹ config/ install/*.೚ҙͷจࣈྻ.yml ϑΝΠϧΛ࡞ ੒͠ɺ͜ͷதͰ௥Ճ͢Δॳظ஋ΛΩʔ

    όϦϡʔܗࣜͰηοτ͠·͢ɻ – ͜ͷॳظ஋͸ϞδϡʔϧͷΠϯετʔϧ ࣌ʹ൓ө͞Ε·͢ɻ langcode: en uuid: '' name: '' mail: '' slogan: '' page: 403: '' 404: '' front: /user/login admin_compact_mode: false weight_select_max: 100 default_langcode: en system/config/install/system.site.yml
  17. ߏ੒ͱ͸ ·ͱΊ – ߏ੒ͱ͸ɺDrupalαΠτͷઃఆ৘ใΛද͢σʔλͰ͢ɻ – YAMLϑΝΠϧͰΠϯϙʔτɾΤΫεϙʔτ͕ՄೳͰɺ؀ڥؒͰߏ੒ΛಉظͰ͖· ͢ɻ – ߏ੒ʹ͸؆қߏ੒ͱߏ੒ΤϯςΟςΟͷ2छྨ͕ଘࡏ͠·͢ɻ –

    جຊతʹߏ੒σʔλ͸σʔλϕʔεʹ֨ೲ͞Ε·͕͢ɺ։ൃऀ͸Configuration API Λհͯ͠ΞΫςΟϒͳߏ੒ʹΞΫηεͰ͖·͢ɻ – 1ͭͷߏ੒ϑΝΠϧ͕1ͭͷߏ੒ΦϒδΣΫτͱͯ͠ѻΘΕ·͢ɻ – ߏ੒ͷεΩʔϚϑΝΠϧΛ༻ҙͨ͠ΓɺϞδϡʔϧΠϯετʔϧ࣌ͷॳظ஋Ληο τͨ͠ΓͰ͖·͢ɻ
  18. Configuration APIͰ ؆қߏ੒Λૢ࡞͢Δ

  19. – config.factoryαʔϏεΛհͯ͠ɺߏ੒ͷಡΈࠐΈɺ
 ࡞੒ɺ࡟আͳͲͷૢ࡞͕ߦ͑·͢ɻ
 ྫɿ\Drupal::service('config.factory' ) – ੩తϝιου΋2ͭ༻ҙ͞Ε͍ͯ·͢ɻ – \Drupal::confi g

    – \Drupal::configFactory config.factoryαʔϏε Կ͕ҧ͏ʁͲ͏ ࢖͍෼͚Δʁ
  20. config.factoryαʔϏε ImmutableConfig ΦϒδΣΫτͷΈฦ ٫͞ΕΔɻ mutableConfigΦϒδΣΫτ ͱImmutableConfigΦϒδΣ Ϋτͷ྆ํʹରԠ͍ͯ͠Δɻ ʢɹෆɹมɹʣ ʢɹՄɹมɹʣ –

    \Drupal::configɿಡΈࠐΈͷΈߦ͑Δɻ – \Drupal::configFactoryɿಡΈࠐΈˍॻ͖ࠐΈ
 ͕ߦ͑Δɻ
  21. ߏ੒ͷओͳૢ࡞ ʔ ಡΈࠐΈ – 1ͭͷߏ੒ΦϒδΣΫτΛಡΈࠐΉ – ΩʔΛࢦఆͯ͠஋Λऔಘ͢Δ $config = \Drupal::service('config.factory')->get('system.site')

    $config = \Drupal::config('system.site') $config = \Drupal::configFactory()->get('system.site') ͜ͷ3ͭͷߦ͸
 ಉ͜͡ͱΛߦͬͯ ͍·͢ʂ͍ͣΕ͔ ͷํ๏Ͱߦͬͯ͘ ͍ͩ͞ɻ $config->get('name'); ɹ// "λϐΦΧ٤஡ళ ·Δ஡" $config->get('page.front'); ɹ// "/node"
  22. ߏ੒ͷओͳૢ࡞ ʔ ॻ͖ࠐΈ – mutableConfigΦϒδΣΫτ͕ฦ٫͞ΕΔΑ͏ʹ
 getEditableؔ਺Λ༻͍ͯ1ͭͷߏ੒ΦϒδΣΫτΛಡΈࠐΉ
 – ஋Ληοτͯ͠อଘ $config =

    \Drupal::service('config.factory')->getEditable('system.site') $config = \Drupal::configFactory()->getEditable('system.site') ͜ͷ2ͭͷߦ͸
 ಉ͜͡ͱΛߦͬͯ ͍·͢ʂ͍ͣΕ͔ ͷํ๏Ͱߦͬͯ͘ ͍ͩ͞ɻ $config->set('name', 'όϒϧςΟʔ ·Δ஡'); $config->save();
  23. ԋश Configuration APIͰߏ੒ʹΞΫηεͯ͠ΈΑ͏ʂ 1. ߏ੒ΦϒδΣΫτͷಡΈࠐΈ 2. ߏ੒ΦϒδΣΫτͷ೚ҙͷΩʔͷ஋Λऔಘ 3. ߏ੒ͷอଘ

  24. ϑΥʔϜͰߏ੒Λૢ࡞͢Δ

  25. ϑΥʔϜͷछྨ ϑΥʔϜΛ࡞੒͢Δʹ͸ \Drupal\Core\Form\FormInterface Λ࣮૷ͨ͠ ϑΥʔϜΫϥε͕ඞཁͰ͢ɻ௚઀FormInterfaceΛ࣮૷͢Δ͜ͱ΋Ͱ͖ ·͕͢ɺForm APIͰ͸ศརͳجఈΫϥε͕3ͭ༻ҙ͞Ε͍ͯ·͢ɻ – FormBas e

    – ConfigFormBas e – ConfirmFormBase ࡞੒͢ΔϑΥʔϜͷ༻్ʹ Ԡͯ͡ɺ͜ΕΒͷجఈΫϥ εΛ֦ுͯ͠ϑΥʔϜΫϥ εΛ࡞੒Ͱ͖·͢ɻ
  26. ϑΥʔϜͷछྨ - ConfigFormBase – ConfigFormBaseΫϥε͸ɺγεςϜ ઃఆΛߦ͏ϑΥʔϜΛ࡞੒͢Δࡍʹ ར༻Ͱ͖·͢ɻ – ྫɿαΠτͷجຊઃఆ –

    ConfigFormBaseΫϥε͸
 FormBaseΫϥεΛ֦ு͍ͯ͠·͢ɻ
  27. ϑΥʔϜͷछྨ ϑΥʔϜΛ࡞੒͢Δʹ͸ \Drupal\Core\Form\FormInterface Λ࣮૷ͨ͠ ϑΥʔϜΫϥε͕ඞཁͰ͢ɻ௚઀FormInterfaceΛ࣮૷͢Δ͜ͱ΋Ͱ͖ ·͕͢ɺForm APIͰ͸ศརͳجఈΫϥε͕3ͭ༻ҙ͞Ε͍ͯ·͢ɻ – FormBas e

    – ConfigFormBase – ConfirmFormBase ࠓճ͸ConfigFormBaseΛ ࢖ͬͯϑΥʔϜΛ࡞੒͢Δ ྫΛ͝঺հ͠·͢ɻ
  28. ConfigFormBaseͰ࣮૷͢Δϝιου – getFormId( ) – getEditableConfigNames( ) – buildForm( )

    – validateForm() ※೚ҙ – submitForm()
  29. ԋश ઃఆϑΥʔϜΛ࡞੒ͯ͠ΈΑ͏ʂ 1. ϞδϡʔϧͷσΟϨΫτϦ௚Լʹsrc/Form/MaruchaConfigForm.php ϑΝΠϧΛ࡞੒ͯ͠ɺϑΥʔϜΫϥεΛ࡞੒͢Δ 2. ඞཁͳϝιουΛ࣮૷͢Δ 3. marucha.routing.ymlϑΝΠϧ಺ʹϧʔςΟϯάΛઃఆ͢Δ ίʔυ͸ͪ͜Βˠ

    https://github.com/hmaruyama/my-drupal9-module/compare/vol9
  30. ߏ੒ͷ্ॻ͖

  31. – ಛఆͷ໨తͷͨΊʹɺߏ੒Λ্ॻ͖͍ͨ͠έʔε͕ଘ ࡏ͠·͢ɻ – ϩʔΧϧ؀ڥͷΈͱ͋ΔઃఆΛมߋ͍ͨ͠ – ؀ڥ͝ͱʹAPIΩʔΛมߋ͍ͨ͠ɺͳͲ ߏ੒Λ্ॻ͖͢Δ

  32. settings.phpͰߏ੒Λ্ॻ͖͢Δ – settings.phpͰάϩʔόϧ$configม਺Λར༻͢Δ͜ͱͰɺߏ ੒Λ্ॻ͖Ͱ͖·͢ɻ $config['system.site']['name'] = 'settings.phpͰ্ॻ͖ͨ͠αΠτ໊';

  33. ্ॻ͖͞Εͨ஋͸Drupal؅ཧը໘ʹ൓ө͞Εͳ͍͜ͱʹ஫ҙ ͍ͯͩ͘͠͞ɻ ߏ੒Λ্ॻ͖͢Δͱɾɾɾ Drupal؅ཧը໘Ͱ ͸ɺ্ॻ͖લͷ஋ ͕දࣔ͞Ε͍ͯ Δʂ

  34. – Drushͷconfig:getίϚϯυͷ৔߹ – ্ॻ͖ͳ͠ͷ஋ΛݟΔɿ
 $ drush config:get system.sit e –

    ্ॻ͖͞Εͨ஋ΛݟΔɿ
 $ drush config:get system.site --include-overridden – PHPίʔυͷ৔߹ – ্ॻ͖ͳ͠ͷ஋ΛݟΔɿ
 
 
 – ্ॻ͖͞Εͨ஋ΛݟΔɿ ্ॻ͖͋Γɺͳ͠ͷ஋Λ֬ೝ͢Δํ๏ \Drupal::config('system.site')->get('name'); \Drupal::config('system.site')->getOriginal('name', FALSE); \Drupal::configFactory()->getEditable('system.site')->get('name'); MutableConfigΦ ϒδΣΫτ͸ৗʹ ্ॻ͖ͳ͠ͷ஋͕ ฦ٫͞ΕΔɻ
  35. settings.phpͰߏ੒Λ্ॻ͖ͯ͠ΈΑ͏ʂ 1. settings.phpͰ$configม਺Λ༻͍ͯߏ੒Λ্ॻ͖͢Δ 2. Drupalͷ؅ཧը໘͔Βର৅ͷઃఆϑΥʔϜΛ೷͍ͯΈΑ͏ 3. DrushίϚϯυͰ্ॻ͖͞Εͨ஋Λ֬ೝͯ͠ΈΑ͏ ԋश

  36. ࿅श໰୊

  37. ࿅श໰୊1 Drupalͷʮߏ੒ʯʹ͍ͭͯਖ਼͍͠هड़Λબ୒͍ͯͩ͘͠͞ɻ 1. αΠτͷݱࡏͷঢ়ଶʹؔ͢ΔҰ࣌తͳੑ࣭ͷ৘ใΛѻ͏σʔλɻ 2. αΠτͷઃఆ৘ใΛද͢σʔλɻ 3. ݸʑͷαΠτ๚໰ऀͷαΠτͱͷ΍ΓऔΓʹؔ͢Δσʔλɻ 4. αΠτ๚໰ऀʹදࣔ͢Δ͜ͱΛ໨తͱͨ͠ςΩετɺը૾ͳͲͷ

    σʔλɻ
  38. ࿅श໰୊1 Drupalͷʮߏ੒ʯʹ͍ͭͯਖ਼͍͠هड़Λબ୒͍ͯͩ͘͠͞ɻ 1. αΠτͷݱࡏͷঢ়ଶʹؔ͢ΔҰ࣌తͳੑ࣭ͷ৘ใΛѻ͏σʔλɻ 2. αΠτͷઃఆ৘ใΛද͢σʔλɻ 3. ݸʑͷαΠτ๚໰ऀͷαΠτͱͷ΍ΓऔΓʹؔ͢Δσʔλɻ 4. αΠτ๚໰ऀʹදࣔ͢Δ͜ͱΛ໨తͱͨ͠ςΩετɺը૾ͳͲͷ

    σʔλɻ
  39. ࿅श໰୊2 Drupalͷʮ؆қߏ੒ʯʹ͍ͭͯਖ਼͍͠هड़Λબ୒͍ͯͩ͘͠͞ɻ 1. ωετͰߏ੒σʔλΛදݱ͢Δ͜ͱ͕Մೳɻ 2. Ϟδϡʔϧ΍ςʔϚɺΤϯςΟςΟʹରͯ͠ґଘؔ܎Λ࣋ͭ͜ͱ͕Ͱ͖ Δɻ 3. ؆қߏ੒͸ɺ1ͭͷϞδϡʔϧʹରͯ͠1ͭͷߏ੒ϑΝΠϧʹ·ͱΊͳ͚ Ε͹ͳΒͳ͍ɻ

  40. ࿅श໰୊2 Drupalͷʮ؆қߏ੒ʯʹ͍ͭͯਖ਼͍͠هड़Λબ୒͍ͯͩ͘͠͞ɻ 1. ωετͰߏ੒σʔλΛදݱ͢Δ͜ͱ͕Մೳɻ 2. Ϟδϡʔϧ΍ςʔϚɺΤϯςΟςΟʹରͯ͠ґଘؔ܎Λ࣋ͭ͜ͱ͕Ͱ͖ Δɻ 3. ؆қߏ੒͸ɺ1ͭͷϞδϡʔϧʹରͯ͠1ͭͷߏ੒ϑΝΠϧʹ·ͱΊͳ͚ Ε͹ͳΒͳ͍ɻ

  41. ࿅श໰୊3 PHPίʔυͰ͋Δߏ੒ΦϒδΣΫτ(marucha.settings)ͷΩʔʹ஋Ληοτ͠ ͍ͨͰ͢ɻ͜ΕΛ࣮ݱ͢Δʹ͸ɺͲͷํ๏Ͱߏ੒ΦϒδΣΫτΛಡΈࠐΉ΂͖ Ͱ͔͢ʁ 1. \Drupal::configFactory()->get('system.site' ) 2. \Drupal::configFactory()->getEditable('marucha.settings' )

    3. \Drupal::config('marucha.settings' ) 4. \Drupal::service('config.factory')->get('marucha.settings')
  42. ࿅श໰୊3 PHPίʔυͰ͋Δߏ੒ΦϒδΣΫτ(marucha.settings)ͷΩʔʹ஋Ληοτ͠ ͍ͨͰ͢ɻ͜ΕΛ࣮ݱ͢Δʹ͸ɺͲͷํ๏Ͱߏ੒ΦϒδΣΫτΛಡΈࠐΉ΂͖ Ͱ͔͢ʁ 1. \Drupal::configFactory()->get('system.site' ) 2. \Drupal::configFactory()->getEditable('marucha.settings') 3.

    \Drupal::config('marucha.settings' ) 4. \Drupal::service('config.factory')->get('marucha.settings')
  43. ࿅श໰୊4 settings.phpͰ࣍ͷߦΛ௥Ճ͠·ͨ͠ɻ $config['system.logging']['error_level'] = 'all' ; ίʔυ͔Β্ॻ͖͞Εͯͳ͍஋ʹΞΫηε͢Δʹ͸Ͳ͏͢Ε͹ྑ͍Ͱ͔͢ʁ2ͭબ୒ͯ͠ ͍ͩ͘͞ɻ 1. \Drupal::configFactory()->get('system.logging')->get('error_level')

    ; 2. \Drupal::config('system.logging')->getOriginal('error_level', FALSE) ; 3. \Drupal::config('system.logging')->get('error_level') ; 4. \Drupal::configFactory()->getEditable('system.logging')->get('error_level');
  44. ࿅श໰୊4 settings.phpͰ࣍ͷߦΛ௥Ճ͠·ͨ͠ɻ $config['system.logging']['error_level'] = 'all' ; ίʔυ͔Β্ॻ͖͞Εͯͳ͍஋ʹΞΫηε͢Δʹ͸Ͳ͏͢Ε͹ྑ͍Ͱ͔͢ʁ2ͭબ୒͠ ͍ͯͩ͘͞ɻ 1. \Drupal::configFactory()->get('system.logging')->get('error_level')

    ; 2. \Drupal::config('system.logging')->getOriginal('error_level', FALSE); 3. \Drupal::config('system.logging')->get('error_level') ; 4. \Drupal::configFactory()->getEditable('system.logging')->get('error_level');
  45. ຊ೔ͷΞδΣϯμ͸ऴྃ

  46. ΞδΣϯμ 1. ߏ੒ͱ͸ 2. Configuration APIͰ؆қߏ੒Λૢ࡞͢Δ 3. ϑΥʔϜͰߏ੒Λૢ࡞͢Δ 4. ߏ੒ͷ্ॻ͖

    5. ࿅श໰୊
  47. ࠷ޙʹ – Ξϯέʔτͷ͝ڠྗΑΖ͓͘͠ئ͍͠·͢ʂ
 ʢ΢ΣϏφʔऴྃޙʹURL͕ڞ༗͞Ε·͢ʣ – ࣍ճͷ์ૹ͸ͪ͜Β
 2/8(ਫ) ࠷ऴճʂDrupalϞδϡʔϧ։ൃೖ໳ߨ࠲ ୈ10ճ ࣗಈςετ

    
 https://www.acquia.com/jp/events/webinars/drupal-module-development-vol10
  48. None