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
310
Drupal8 Problem of multilingualization of contents
kazukomurata
0
81
Drupalのデモサイト作って明日までに!と言われたら
kazukomurata
0
720
Drupal8 CKEditor TIps
kazukomurata
0
400
Drupal7 & 8 翻訳コンテンツの罠
kazukomurata
0
260
Drupal7×Cloudfront×SSL
kazukomurata
0
250
Drupal8 2016/11
kazukomurata
0
67
Other Decks in Programming
See All in Programming
Quine, Polyglot, 良いコード
qnighy
4
650
OSSで起業してもうすぐ10年 / Open Source Conference 2024 Shimane
furukawayasuto
0
110
TypeScript Graph でコードレビューの心理的障壁を乗り越える
ysk8hori
3
1.2k
as(型アサーション)を書く前にできること
marokanatani
10
2.7k
イベント駆動で成長して委員会
happymana
1
340
カンファレンスの「アレ」Webでなんとかしませんか? / Conference “thing” Why don't you do something about it on the Web?
dero1to
1
110
Arm移行タイムアタック
qnighy
0
340
TypeScriptでライブラリとの依存を限定的にする方法
tutinoko
3
700
Jakarta EE meets AI
ivargrimstad
0
710
ECS Service Connectのこれまでのアップデートと今後のRoadmapを見てみる
tkikuc
2
260
PHP でアセンブリ言語のように書く技術
memory1994
PRO
1
170
Better Code Design in PHP
afilina
PRO
0
130
Featured
See All Featured
Testing 201, or: Great Expectations
jmmastey
38
7.1k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
31
2.7k
The World Runs on Bad Software
bkeepers
PRO
65
11k
10 Git Anti Patterns You Should be Aware of
lemiorhan
655
59k
Building a Scalable Design System with Sketch
lauravandoore
459
33k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
48k
Site-Speed That Sticks
csswizardry
0
33
The Cult of Friendly URLs
andyhume
78
6k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
665
120k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
329
21k
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
Fontdeck: Realign not Redesign
paulrobertlloyd
82
5.2k
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!! ͝੩ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠ɻ