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
kazukomurata
January 26, 2017
Programming
0
270
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
Migrate Drupal7 to Drpual8
kazukomurata
0
240
Drupal8 Migrate API
kazukomurata
0
310
Drupal8 Problem of multilingualization of contents
kazukomurata
0
86
Drupalのデモサイト作って明日までに!と言われたら
kazukomurata
0
730
Drupal8 CKEditor TIps
kazukomurata
0
410
Drupal7 & 8 翻訳コンテンツの罠
kazukomurata
0
260
Drupal7×Cloudfront×SSL
kazukomurata
0
250
Drupal8 2016/11
kazukomurata
0
68
Other Decks in Programming
See All in Programming
Amazon S3 NYJavaSIG 2024-12-12
sullis
0
110
[JAWS-UG横浜 #76] イケてるアップデートを宇宙いち早く紹介するよ!
maroon1st
0
510
生成AIでGitHubソースコード取得して仕様書を作成
shukob
0
530
CloudflareStack でRAGに入門
asahiiwm
0
100
ブラウザ単体でmp4書き出すまで - muddy-web - 2024-12
yue4u
3
490
数十万行のプロジェクトを Scala 2から3に完全移行した
xuwei_k
0
350
情報漏洩させないための設計
kubotak
4
840
AppRouterを用いた大規模サービス開発におけるディレクトリ構成の変遷と問題点
eiganken
1
160
Scalaから始めるOpenFeature入門 / Scalaわいわい勉強会 #4
arthur1
1
340
Stackless и stackful? Корутины и асинхронность в Go
lamodatech
0
960
PHPとAPI Platformで作る本格的なWeb APIアプリケーション(入門編) / phpcon 2024 Intro to API Platform
ttskch
0
300
103 Early Hints
sugi_0000
1
260
Featured
See All Featured
Rebuilding a faster, lazier Slack
samanthasiow
79
8.7k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.2k
BBQ
matthewcrist
85
9.4k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
229
52k
Building an army of robots
kneath
302
44k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
8
1.2k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
33
2k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
365
25k
A designer walks into a library…
pauljervisheath
205
24k
[RailsConf 2023] Rails as a piece of cake
palkan
53
5.1k
How to train your dragon (web standard)
notwaldorf
88
5.7k
Learning to Love Humans: Emotional Interface Design
aarron
274
40k
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!! ͝੩ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠ɻ