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
260
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
280
Drupal8 Problem of multilingualization of contents
kazukomurata
0
79
Drupalのデモサイト作って明日までに!と言われたら
kazukomurata
0
640
Drupal8 CKEditor TIps
kazukomurata
0
370
Drupal7 & 8 翻訳コンテンツの罠
kazukomurata
0
250
Drupal7×Cloudfront×SSL
kazukomurata
0
240
Drupal8 2016/11
kazukomurata
0
65
Other Decks in Programming
See All in Programming
日付と正規化
megmogmog1965
0
140
Google's Recipe for Scaling (Web) Security – LocoMocoSec 2024
lweichselbaum
0
170
Introduction of Happy Eyeballs Version 2 (RFC8305) to the Socket library
coe401_
1
220
3 Effective Rules for Success with Signals in Angular
manfredsteyer
PRO
0
120
Architectures with Lightweight Stores: New Rules and Options
manfredsteyer
PRO
0
100
CSC307 Lecture 10
javiergs
PRO
0
310
社内 LT 会を発足し、アウトプット文化を醸成させるために考えたこと・やったこと / Starting internal LT meetings and fostering an output culture
mackey0225
3
120
しくじり先生 Image Matching Challenge 2024 編
goosehaaan
0
810
【Go言語】golangci-lintの使い方
tomo1227
0
270
君たちはどうコードをレビューする (される) か / 大吉祥寺.pm
utgwkk
15
8.5k
ぼっちを避けて楽しむためのアノテコノテ / Various Tips and Tricks to Avoid Loneliness and Have Fun
nrslib
3
1.7k
Webエディタライブラリ 「CodeMirror」から学ぶ Webアプリ開発のテクニック
ryosukeigarashi
0
250
Featured
See All Featured
How to Think Like a Performance Engineer
csswizardry
4
590
Mobile First: as difficult as doing things right
swwweet
219
8.8k
Automating Front-end Workflow
addyosmani
1362
200k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
24
1.8k
Teambox: Starting and Learning
jrom
130
8.6k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
34
1.9k
Building Better People: How to give real-time feedback that sticks.
wjessup
357
18k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
18
1.2k
What's new in Ruby 2.0
geeforr
338
31k
Robots, Beer and Maslow
schacon
PRO
157
8.1k
10 Git Anti Patterns You Should be Aware of
lemiorhan
652
58k
Visualization
eitanlees
139
14k
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!! ͝੩ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠ɻ