Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Drupal8 State API と Configuration API
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
kazukomurata
January 26, 2017
Programming
0
290
Drupal8 State API と Configuration API
Drupal8のVariables~State API と Configuration API ~
kazukomurata
January 26, 2017
Tweet
Share
More Decks by kazukomurata
See All by kazukomurata
長期運用のためのDrupal開発入門
kazukomurata
0
61
Migrate Drupal7 to Drpual8
kazukomurata
0
280
Drupal8 Migrate API
kazukomurata
0
350
Drupal8 Problem of multilingualization of contents
kazukomurata
0
140
Drupalのデモサイト作って明日までに!と言われたら
kazukomurata
0
860
Drupal8 CKEditor TIps
kazukomurata
0
440
Drupal7 & 8 翻訳コンテンツの罠
kazukomurata
0
280
Drupal7×Cloudfront×SSL
kazukomurata
0
280
Drupal8 2016/11
kazukomurata
0
79
Other Decks in Programming
See All in Programming
エージェント開発初心者の僕がエージェントを作った話と今後やりたいこと
thasu0123
0
240
守る「だけ」の優しいEMを抜けて、 事業とチームを両方見る視点を身につけた話
maroon8021
3
660
手戻りゼロ? Spec Driven Developmentとは@KAG AI week
tmhirai
1
190
株式会社 Sun terras カンパニーデック
sunterras
0
2.1k
ふつうの Rubyist、ちいさなデバイス、大きな一年
bash0c7
0
800
Unity6.3 AudioUpdate
cova8bitdots
0
120
Swift ConcurrencyでよりSwiftyに
yuukiw00w
0
250
メタプログラミングで実現する「コードを仕様にする」仕組み/nikkei-tech-talk43
nikkei_engineer_recruiting
0
170
今更考える「単一責任原則」 / Thinking about the Single Responsibility Principle
tooppoo
3
1.6k
Vuetify 3 → 4 何が変わった?差分と移行ポイント10分まとめ
koukimiura
0
110
go directiveを最新にしすぎないで欲しい話──あるいは、Go 1.26からgo mod initで作られるgo directiveの値が変わる話 / Go 1.26 リリースパーティ
arthur1
2
530
Windows on Ryzen and I
seosoft
0
240
Featured
See All Featured
The Art of Programming - Codeland 2020
erikaheidi
57
14k
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
630
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
1.9k
AI: The stuff that nobody shows you
jnunemaker
PRO
3
370
How to make the Groovebox
asonas
2
2k
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
200
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.1k
The #1 spot is gone: here's how to win anyway
tamaranovitovic
2
980
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.4k
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
5
760
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
1
1.4k
Exploring anti-patterns in Rails
aemeredith
2
290
Transcript
Drupal8ͷVariables ~State API ͱ Configuration API ~ MURATA Kazuko
Variables ͱ DrupalͷઃఆkeyͱvalueͰఆٛ͞ΕΔ Variablesʹू͞Ε͍ͯΔɻ
Drupal8ͰVariables ແ͍ɾɾɾʂ Drupal8ͰҎԼͷ2ͭʹ͠·ͨ͠ɻ ɾঢ়ଶΛอ࣋͢ΔState ɾઃఆΛอ࣋͢ΔConfiguration
State API ؆қతʹอ࣋͢ΔState APIΛར༻͢Δɻ ɾCSS,JSѹॖϑΝΠϧύεʹͭ͘จࣈྻ →/sites/default/files/css/css_lqq6XNouNM84HMTnOnigWo9qb1k.css?ok2ccv ɾCron࣮ߦͷ࠷ऴ࣌ ɾΠϯετʔϧ࣌
Configuration API ΞϓϦέʔγϣϯͱͯ͠ఆ͍ٛͨ͠ͷ͢ ͯConfiguration APIΛར༻͢Δɻ ɾ͋Γͱ͋ΒΏΔઃఆ ɾCIMͰग़ྗ͞ΕΔͷͰڥݻ༗ͷidΛอ ଘ͢Δͱ௧͍͋͏ɻ
෮श : D7ͷVariables // Set. variable_set('key', value); // Get. variable_get('key',
σϑΥϧτ); // Delete. variable_del(‘key');
State API ίʔυྫ // Set. \Drupal::state()->set('key', value); ※keyϞδϡʔϧ໊ͱkey໊শΛ ʮ.ʯͰͭͳ͛ͯࢦఆ͢Δ(ex. system.css_js_query_string)
// Get. \Drupal::state()->get('key'); // Delete. \Drupal::state()->delete(‘key'); Service ͰDI͢Δͱ͖ʮStateInterfaceʯͰड͚ࢭΊΔͷ͕ਖ਼ղ(ͨͿΜ)
Configuration API ίʔυྫ // Set. $config = \Drupal::service(‘config.factory') ->getEditable('system.performance'); $config->set('cache.page.enabled',
1); // Get. $config = \Drupal::config('system.maintenance'); $message = $config->get('message'); // Delete. \Drupal::service(‘config.factory’)->getEditable('key')->delete();
Configuration API ิ ɾઃఆͷొը໘ConfigFormBaseΛܧঝָͯ͠͠·͠ΐ ͏ɻ ྫ : core/modules/system/src/Form/SiteInformationForm.php ɾServiceར༻ͷ࣌ɺState APIಉ༷ɺConfigFactoryInterfaceͰ
ड͚ࢭΊͭͭɺconstractͷதͰɺඞཁͳΛget͠ͱ͘ͷ͕҆શ ͔ɻ public function __construct(ConfigFactoryInterface $config { $this->config = $config->get('key'); }
Thank you!! ͝੩ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠ɻ