SlideShare a Scribd company logo
1 of 24
Download to read offline
Configuration entities
in Drupal 8.
Eugene Kulishov Adyax 2015
What we will speak about?
●
Innovations in Entity Api.
●
Configuration manager in Drupal 8
●
Examples of use of configuration entities
●
Creation of custom Config Entity on the
example of Config Pages module
Types of information in Drupal 8
Content State Session Configuration
Config API Configuration Entity API
Status of modules
Site name
Content types
Image styles
Configuration entities in Drupal 8
●
Views
●
Fields
●
Content types
●
Image styles
●
Display settings
●
Blocks
●
Role
●
Taxonomy vocabulary
●
Date format
●
Comment type
●
Text format
●
Date format
Configuration Manager interface
Configuration Manager interface
YAML format structure
node.type.page.yml
uuid: a0025874-17ec-4ad2-a300-0af31a8a462b
langcode: en
status: true
dependencies: { }
name: 'Basic page'
type: page
description: 'Use <em>basic pages</em> for your static
content, such as an ''About us'' page.'
help: ''
new_revision: false
preview_mode: 1
display_submitted: false
Configuration installation
File:
core.entity_view_mode.comment.simple_comment.yml
langcode: en
status: false
dependencies:
module:
- comment
id: comment.simple_comment
label: 'My simple comment'
targetEntityType: comment
cache: true
Config API code examples
<?php
// Get data from config.
$config = Drupal::config('system.site');
// Instance of DrupalCoreConfigImmutableConfig
$front_page = $config->get('page.front');
// /user/login
$front_page = Drupal::config('system.site')->get('page.front');
// /user/login
// Save data to config.
$config = Drupal::service('config.factory')
->getEditable('system.site');
// Instance of DrupalCoreConfigConfig
$config->set('page.front', 'new-front-page');
$config->save();
Main stages of creation
●
Definition of scheme and interface
●
Basic defenition of the class
●
We expand opportunities: add listing of
object, add CRUD forms
●
Removing of configuration entity
Schema of Configuration entity
File: config_pages.schema.yml
config_pages.type.*:
type: config_entity
label: 'Config page type settings'
mapping:
id:
type: string
label: 'ID'
label:
type: label
label: 'Label'
Basic definition of the class
File: ConfigPagesType.php
namespace Drupalconfig_pagesEntity;
use DrupalCoreConfigEntityConfigEntityBundleBase;
/**
* @ConfigEntityType(
* id = "config_pages_type",
* admin_permission = "administer config_pages types",
* label = @Translation("Config page type"),
* config_prefix = "type",
* entity_keys = {
* "id" = "id",
* "label" = "label",
* "context" = "context",
* "menu" = "menu"
* },
* )
*/
class ConfigPagesType extends ConfigEntityBundleBase implements ConfigPagesTypeInterface {
/**
* The config page type ID.
*/
protected $id;
/**
* The config page type label.
*/
protected $label;
}
Listing of Config Entity
File: ConfigPagesType.php
* handlers = {
* "list_builder" =
* "Drupalconfig_pagesConfigPagesTypeListBuilder"
* },
File: config_pages.routing.yml
entity.config_pages_type.collection:
path: '/admin/structure/config_pages/types'
defaults:
_entity_list: 'config_pages_type'
_title: 'Config Pages Types'
requirements:
_permission: 'administer config_pages entity'
ConfigPagesTypeListBuilder class
<?php
namespace Drupalconfig_pages;
use DrupalCoreConfigEntityConfigEntityListBuilder;
use DrupalCoreEntityEntityInterface;
/**
* Defines a class to build a listing of custom config page type entities.
*/
class ConfigPagesTypeListBuilder extends ConfigEntityListBuilder {
/**
* Changes list of operation.
*/
public function getDefaultOperations(EntityInterface $entity) {...}
/**
* Changes for header
*/
public function buildHeader() {...}
/**
* Changes for row.
*/
public function buildRow(EntityInterface $entity) {...}
/**
* {@inheritdoc}
*/
protected function getTitle() {...}
}
Listing of ConfigPagesType objects
Path: /admin/structure/config_pages/types
Management forms of Config Entity
●
Creating a new class ConfigPagesTypeForm,
describing the form
●
Add class to definition of Configuration Entity
●
Add new route to config_pages.routing.yml
●
Add new local action for adding new Configuration
object
ConfigPagesTypeForm class
File: ConfigPagesTypeForm.php
namespace Drupalconfig_pages;
use DrupalCoreEntityEntityForm;
use DrupalCoreEntityEntityTypeInterface;
use DrupalCoreFormFormStateInterface;
/**
* Base form for config_pages edit forms.
*/
class ConfigPagesTypeForm extends EntityForm {
/**
* Required routes rebuild.
*/
protected $routesRebuildRequired = FALSE;
/**
* Form definition.
*/
public function form(array $form, FormStateInterface $form_state) {...}
/**
* Form validation.
*/
public function validateForm(array &$form, FormStateInterface $form_state) {...}
/**
* Form save.
*/
public function save(array $form, FormStateInterface $form_state) {...}
}
Annotation of Configuration Entity
* handlers = {
* "form" = {
* "default" = "Drupalconfig_pagesConfigPagesTypeForm",
* "add" = "Drupalconfig_pagesConfigPagesTypeForm",
* "edit" = "Drupalconfig_pagesConfigPagesTypeForm",
* "delete" =
* "Drupalconfig_pagesFormConfigPagesTypeDeleteForm"
* },
* "list_builder" =
* "Drupalconfig_pagesConfigPagesTypeListBuilder"
* },
Routes with forms
File: config_pages.routing.yml
entity.config_pages_type.edit_form:
path: '/admin/structure/config_pages/types/manage/{config_pages_type}'
defaults:
_entity_form: 'config_pages_type.edit'
_title: 'Edit'
requirements:
_entity_access: 'config_pages_type.update'
options:
_admin_route: TRUE
entity.config_pages_type.delete_form:
path: '/admin/structure/config_pages/types/manage/{config_pages_type}/delete'
defaults:
_entity_form: 'config_pages_type.delete'
_title: 'Delete'
requirements:
_entity_access: 'config_pages_type.delete'
options:
_admin_route: TRUE
Edit Form example
Path: admin/structure/config_pages/types/manage/my_custom_page
Local action add
File: config_pages.links.action.yml
config_pages_type_add:
route_name: config_pages.type_add
title: 'Add config page'
appears_on:
- entity.config_pages_type.collection
Listing of configuration objects
Path: /admin/structure/config_pages/types
Configuration API Code examples
<?php
$config_name = 'config_pages.type.my_custom_page';
$config = Drupal::service('config.factory')
->getEditable($config_name);
// Instance of DrupalCoreConfigConfig
$config = Drupal::config($config_name);
// Instance of DrupalCoreConfigImmutableConfig
$object =
Drupalconfig_pagesEntityConfigPagesType::load('my_custom
_page');
Thanks!

More Related Content

What's hot

Migrating to-Drupal-8 by Bryan Manalo
Migrating to-Drupal-8 by Bryan ManaloMigrating to-Drupal-8 by Bryan Manalo
Migrating to-Drupal-8 by Bryan ManaloPromet Source
 
Drupal 8: Entities
Drupal 8: EntitiesDrupal 8: Entities
Drupal 8: Entitiesdrubb
 
[FEConf Korea 2017]Angular 컴포넌트 대화법
[FEConf Korea 2017]Angular 컴포넌트 대화법[FEConf Korea 2017]Angular 컴포넌트 대화법
[FEConf Korea 2017]Angular 컴포넌트 대화법Jeado Ko
 
Introduction to ZendX jQuery
Introduction to ZendX jQueryIntroduction to ZendX jQuery
Introduction to ZendX jQuerydennisdc
 
Web internship Yii Framework
Web internship  Yii FrameworkWeb internship  Yii Framework
Web internship Yii FrameworkNoveo
 
Intro to IndexedDB (Beta)
Intro to IndexedDB (Beta)Intro to IndexedDB (Beta)
Intro to IndexedDB (Beta)Mike West
 
Twitter bootstrap
Twitter bootstrapTwitter bootstrap
Twitter bootstrapdennisdc
 
Angular Restmod (english version)
Angular Restmod (english version)Angular Restmod (english version)
Angular Restmod (english version)Marcin Gajda
 
Drupal Field API. Practical usage
Drupal Field API. Practical usageDrupal Field API. Practical usage
Drupal Field API. Practical usagePavel Makhrinsky
 
Drupal Development
Drupal DevelopmentDrupal Development
Drupal DevelopmentJeff Eaton
 
Yii in action
Yii in actionYii in action
Yii in actionKeaNy Chu
 
Drupal 8: Forms
Drupal 8: FormsDrupal 8: Forms
Drupal 8: Formsdrubb
 
AngularJS Directives
AngularJS DirectivesAngularJS Directives
AngularJS DirectivesEyal Vardi
 
"Android Data Binding в массы" Михаил Анохин
"Android Data Binding в массы" Михаил Анохин"Android Data Binding в массы" Михаил Анохин
"Android Data Binding в массы" Михаил АнохинFwdays
 

What's hot (20)

Migrating to-Drupal-8 by Bryan Manalo
Migrating to-Drupal-8 by Bryan ManaloMigrating to-Drupal-8 by Bryan Manalo
Migrating to-Drupal-8 by Bryan Manalo
 
Drupal 8: Entities
Drupal 8: EntitiesDrupal 8: Entities
Drupal 8: Entities
 
Introducing jQuery
Introducing jQueryIntroducing jQuery
Introducing jQuery
 
JQuery
JQueryJQuery
JQuery
 
[FEConf Korea 2017]Angular 컴포넌트 대화법
[FEConf Korea 2017]Angular 컴포넌트 대화법[FEConf Korea 2017]Angular 컴포넌트 대화법
[FEConf Korea 2017]Angular 컴포넌트 대화법
 
Introduction to ZendX jQuery
Introduction to ZendX jQueryIntroduction to ZendX jQuery
Introduction to ZendX jQuery
 
Css Selectors
Css SelectorsCss Selectors
Css Selectors
 
Web internship Yii Framework
Web internship  Yii FrameworkWeb internship  Yii Framework
Web internship Yii Framework
 
Intro to IndexedDB (Beta)
Intro to IndexedDB (Beta)Intro to IndexedDB (Beta)
Intro to IndexedDB (Beta)
 
Twitter bootstrap
Twitter bootstrapTwitter bootstrap
Twitter bootstrap
 
Angular Restmod (english version)
Angular Restmod (english version)Angular Restmod (english version)
Angular Restmod (english version)
 
Jquery Basics
Jquery BasicsJquery Basics
Jquery Basics
 
Drupal Field API. Practical usage
Drupal Field API. Practical usageDrupal Field API. Practical usage
Drupal Field API. Practical usage
 
Field api.From d7 to d8
Field api.From d7 to d8Field api.From d7 to d8
Field api.From d7 to d8
 
Drupal Development
Drupal DevelopmentDrupal Development
Drupal Development
 
Yii in action
Yii in actionYii in action
Yii in action
 
Java script
Java scriptJava script
Java script
 
Drupal 8: Forms
Drupal 8: FormsDrupal 8: Forms
Drupal 8: Forms
 
AngularJS Directives
AngularJS DirectivesAngularJS Directives
AngularJS Directives
 
"Android Data Binding в массы" Михаил Анохин
"Android Data Binding в массы" Михаил Анохин"Android Data Binding в массы" Михаил Анохин
"Android Data Binding в массы" Михаил Анохин
 

Similar to Configuration Entities in Drupal 8

Config management
Config managementConfig management
Config managementAlexei Goja
 
Webform and Drupal 8
Webform and Drupal 8Webform and Drupal 8
Webform and Drupal 8Philip Norton
 
C# .NET Developer Portfolio
C# .NET Developer PortfolioC# .NET Developer Portfolio
C# .NET Developer Portfoliocummings49
 
DrupalJam 2018 - Maintaining a Drupal Module: Keep It Small and Simple
DrupalJam 2018 - Maintaining a Drupal Module: Keep It Small and SimpleDrupalJam 2018 - Maintaining a Drupal Module: Keep It Small and Simple
DrupalJam 2018 - Maintaining a Drupal Module: Keep It Small and SimpleAlexander Varwijk
 
Олексій Калініченко — Configuration Management in Drupal8
Олексій Калініченко — Configuration Management in Drupal8Олексій Калініченко — Configuration Management in Drupal8
Олексій Калініченко — Configuration Management in Drupal8LEDC 2016
 
Drupal 7 entities & TextbookMadness.com
Drupal 7 entities & TextbookMadness.comDrupal 7 entities & TextbookMadness.com
Drupal 7 entities & TextbookMadness.comJD Leonard
 
8 things to know about theming in drupal 8
8 things to know about theming in drupal 88 things to know about theming in drupal 8
8 things to know about theming in drupal 8Logan Farr
 
Odoo Experience 2018 - Develop an App with the Odoo Framework
Odoo Experience 2018 - Develop an App with the Odoo FrameworkOdoo Experience 2018 - Develop an App with the Odoo Framework
Odoo Experience 2018 - Develop an App with the Odoo FrameworkElínAnna Jónasdóttir
 
Drupal 7 Theming - Behind the scenes
Drupal 7 Theming - Behind the scenes Drupal 7 Theming - Behind the scenes
Drupal 7 Theming - Behind the scenes ramakesavan
 
Your Entity, Your Code
Your Entity, Your CodeYour Entity, Your Code
Your Entity, Your CodeDrupalDay
 
Drupal 8 configuration management
Drupal 8 configuration managementDrupal 8 configuration management
Drupal 8 configuration managementAlexander Tkachev
 
Rapid Prototyping with PEAR
Rapid Prototyping with PEARRapid Prototyping with PEAR
Rapid Prototyping with PEARMarkus Wolff
 
Asp Net Advance Topics
Asp Net Advance TopicsAsp Net Advance Topics
Asp Net Advance TopicsAli Taki
 
Django cheat sheet
Django cheat sheetDjango cheat sheet
Django cheat sheetLam Hoang
 

Similar to Configuration Entities in Drupal 8 (20)

Config management
Config managementConfig management
Config management
 
Webform and Drupal 8
Webform and Drupal 8Webform and Drupal 8
Webform and Drupal 8
 
C# .NET Developer Portfolio
C# .NET Developer PortfolioC# .NET Developer Portfolio
C# .NET Developer Portfolio
 
Django Vs Rails
Django Vs RailsDjango Vs Rails
Django Vs Rails
 
KAAccessControl
KAAccessControlKAAccessControl
KAAccessControl
 
DrupalJam 2018 - Maintaining a Drupal Module: Keep It Small and Simple
DrupalJam 2018 - Maintaining a Drupal Module: Keep It Small and SimpleDrupalJam 2018 - Maintaining a Drupal Module: Keep It Small and Simple
DrupalJam 2018 - Maintaining a Drupal Module: Keep It Small and Simple
 
Олексій Калініченко — Configuration Management in Drupal8
Олексій Калініченко — Configuration Management in Drupal8Олексій Калініченко — Configuration Management in Drupal8
Олексій Калініченко — Configuration Management in Drupal8
 
Drupal 7 entities & TextbookMadness.com
Drupal 7 entities & TextbookMadness.comDrupal 7 entities & TextbookMadness.com
Drupal 7 entities & TextbookMadness.com
 
8 things to know about theming in drupal 8
8 things to know about theming in drupal 88 things to know about theming in drupal 8
8 things to know about theming in drupal 8
 
Odoo Experience 2018 - Develop an App with the Odoo Framework
Odoo Experience 2018 - Develop an App with the Odoo FrameworkOdoo Experience 2018 - Develop an App with the Odoo Framework
Odoo Experience 2018 - Develop an App with the Odoo Framework
 
Customizing User Profiles
Customizing User ProfilesCustomizing User Profiles
Customizing User Profiles
 
Drupal 7 Theming - Behind the scenes
Drupal 7 Theming - Behind the scenes Drupal 7 Theming - Behind the scenes
Drupal 7 Theming - Behind the scenes
 
Drupal 8 Hooks
Drupal 8 HooksDrupal 8 Hooks
Drupal 8 Hooks
 
Your Entity, Your Code
Your Entity, Your CodeYour Entity, Your Code
Your Entity, Your Code
 
Your Entity, Your Code
Your Entity, Your CodeYour Entity, Your Code
Your Entity, Your Code
 
Drupal 8 configuration management
Drupal 8 configuration managementDrupal 8 configuration management
Drupal 8 configuration management
 
Rapid Prototyping with PEAR
Rapid Prototyping with PEARRapid Prototyping with PEAR
Rapid Prototyping with PEAR
 
Asp Net Advance Topics
Asp Net Advance TopicsAsp Net Advance Topics
Asp Net Advance Topics
 
Drupal 8 Services
Drupal 8 ServicesDrupal 8 Services
Drupal 8 Services
 
Django cheat sheet
Django cheat sheetDjango cheat sheet
Django cheat sheet
 

Recently uploaded

Gram Darshan PPT cyber rural in villages of india
Gram Darshan PPT cyber rural  in villages of indiaGram Darshan PPT cyber rural  in villages of india
Gram Darshan PPT cyber rural in villages of indiaimessage0108
 
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012rehmti665
 
Russian Call Girls in Kolkata Samaira 🤌 8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Samaira 🤌  8250192130 🚀 Vip Call Girls KolkataRussian Call Girls in Kolkata Samaira 🤌  8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Samaira 🤌 8250192130 🚀 Vip Call Girls Kolkataanamikaraghav4
 
Russian Call Girls in Kolkata Ishita 🤌 8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Ishita 🤌  8250192130 🚀 Vip Call Girls KolkataRussian Call Girls in Kolkata Ishita 🤌  8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Ishita 🤌 8250192130 🚀 Vip Call Girls Kolkataanamikaraghav4
 
AlbaniaDreamin24 - How to easily use an API with Flows
AlbaniaDreamin24 - How to easily use an API with FlowsAlbaniaDreamin24 - How to easily use an API with Flows
AlbaniaDreamin24 - How to easily use an API with FlowsThierry TROUIN ☁
 
AWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptxAWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptxellan12
 
VIP Kolkata Call Girl Salt Lake 👉 8250192130 Available With Room
VIP Kolkata Call Girl Salt Lake 👉 8250192130  Available With RoomVIP Kolkata Call Girl Salt Lake 👉 8250192130  Available With Room
VIP Kolkata Call Girl Salt Lake 👉 8250192130 Available With Roomishabajaj13
 
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts serviceChennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts servicevipmodelshub1
 
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...SofiyaSharma5
 
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark WebGDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark WebJames Anderson
 
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...Sheetaleventcompany
 
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...Diya Sharma
 
Hot Service (+9316020077 ) Goa Call Girls Real Photos and Genuine Service
Hot Service (+9316020077 ) Goa  Call Girls Real Photos and Genuine ServiceHot Service (+9316020077 ) Goa  Call Girls Real Photos and Genuine Service
Hot Service (+9316020077 ) Goa Call Girls Real Photos and Genuine Servicesexy call girls service in goa
 
Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Callshivangimorya083
 
VIP Kolkata Call Girls Salt Lake 8250192130 Available With Room
VIP Kolkata Call Girls Salt Lake 8250192130 Available With RoomVIP Kolkata Call Girls Salt Lake 8250192130 Available With Room
VIP Kolkata Call Girls Salt Lake 8250192130 Available With Roomgirls4nights
 
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779Delhi Call girls
 
Russian Call girls in Dubai +971563133746 Dubai Call girls
Russian  Call girls in Dubai +971563133746 Dubai  Call girlsRussian  Call girls in Dubai +971563133746 Dubai  Call girls
Russian Call girls in Dubai +971563133746 Dubai Call girlsstephieert
 
VIP Call Girls Kolkata Ananya 🤌 8250192130 🚀 Vip Call Girls Kolkata
VIP Call Girls Kolkata Ananya 🤌  8250192130 🚀 Vip Call Girls KolkataVIP Call Girls Kolkata Ananya 🤌  8250192130 🚀 Vip Call Girls Kolkata
VIP Call Girls Kolkata Ananya 🤌 8250192130 🚀 Vip Call Girls Kolkataanamikaraghav4
 

Recently uploaded (20)

Gram Darshan PPT cyber rural in villages of india
Gram Darshan PPT cyber rural  in villages of indiaGram Darshan PPT cyber rural  in villages of india
Gram Darshan PPT cyber rural in villages of india
 
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
 
Russian Call Girls in Kolkata Samaira 🤌 8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Samaira 🤌  8250192130 🚀 Vip Call Girls KolkataRussian Call Girls in Kolkata Samaira 🤌  8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Samaira 🤌 8250192130 🚀 Vip Call Girls Kolkata
 
Russian Call Girls in Kolkata Ishita 🤌 8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Ishita 🤌  8250192130 🚀 Vip Call Girls KolkataRussian Call Girls in Kolkata Ishita 🤌  8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Ishita 🤌 8250192130 🚀 Vip Call Girls Kolkata
 
AlbaniaDreamin24 - How to easily use an API with Flows
AlbaniaDreamin24 - How to easily use an API with FlowsAlbaniaDreamin24 - How to easily use an API with Flows
AlbaniaDreamin24 - How to easily use an API with Flows
 
AWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptxAWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptx
 
VIP Kolkata Call Girl Salt Lake 👉 8250192130 Available With Room
VIP Kolkata Call Girl Salt Lake 👉 8250192130  Available With RoomVIP Kolkata Call Girl Salt Lake 👉 8250192130  Available With Room
VIP Kolkata Call Girl Salt Lake 👉 8250192130 Available With Room
 
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts serviceChennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
 
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
 
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark WebGDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
 
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
 
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
 
Rohini Sector 6 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 6 Call Girls Delhi 9999965857 @Sabina Saikh No AdvanceRohini Sector 6 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 6 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
 
Hot Service (+9316020077 ) Goa Call Girls Real Photos and Genuine Service
Hot Service (+9316020077 ) Goa  Call Girls Real Photos and Genuine ServiceHot Service (+9316020077 ) Goa  Call Girls Real Photos and Genuine Service
Hot Service (+9316020077 ) Goa Call Girls Real Photos and Genuine Service
 
Rohini Sector 26 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 26 Call Girls Delhi 9999965857 @Sabina Saikh No AdvanceRohini Sector 26 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 26 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
 
Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
 
VIP Kolkata Call Girls Salt Lake 8250192130 Available With Room
VIP Kolkata Call Girls Salt Lake 8250192130 Available With RoomVIP Kolkata Call Girls Salt Lake 8250192130 Available With Room
VIP Kolkata Call Girls Salt Lake 8250192130 Available With Room
 
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
 
Russian Call girls in Dubai +971563133746 Dubai Call girls
Russian  Call girls in Dubai +971563133746 Dubai  Call girlsRussian  Call girls in Dubai +971563133746 Dubai  Call girls
Russian Call girls in Dubai +971563133746 Dubai Call girls
 
VIP Call Girls Kolkata Ananya 🤌 8250192130 🚀 Vip Call Girls Kolkata
VIP Call Girls Kolkata Ananya 🤌  8250192130 🚀 Vip Call Girls KolkataVIP Call Girls Kolkata Ananya 🤌  8250192130 🚀 Vip Call Girls Kolkata
VIP Call Girls Kolkata Ananya 🤌 8250192130 🚀 Vip Call Girls Kolkata
 

Configuration Entities in Drupal 8

  • 1. Configuration entities in Drupal 8. Eugene Kulishov Adyax 2015
  • 2. What we will speak about? ● Innovations in Entity Api. ● Configuration manager in Drupal 8 ● Examples of use of configuration entities ● Creation of custom Config Entity on the example of Config Pages module
  • 3. Types of information in Drupal 8 Content State Session Configuration Config API Configuration Entity API Status of modules Site name Content types Image styles
  • 4. Configuration entities in Drupal 8 ● Views ● Fields ● Content types ● Image styles ● Display settings ● Blocks ● Role ● Taxonomy vocabulary ● Date format ● Comment type ● Text format ● Date format
  • 7. YAML format structure node.type.page.yml uuid: a0025874-17ec-4ad2-a300-0af31a8a462b langcode: en status: true dependencies: { } name: 'Basic page' type: page description: 'Use <em>basic pages</em> for your static content, such as an ''About us'' page.' help: '' new_revision: false preview_mode: 1 display_submitted: false
  • 8. Configuration installation File: core.entity_view_mode.comment.simple_comment.yml langcode: en status: false dependencies: module: - comment id: comment.simple_comment label: 'My simple comment' targetEntityType: comment cache: true
  • 9. Config API code examples <?php // Get data from config. $config = Drupal::config('system.site'); // Instance of DrupalCoreConfigImmutableConfig $front_page = $config->get('page.front'); // /user/login $front_page = Drupal::config('system.site')->get('page.front'); // /user/login // Save data to config. $config = Drupal::service('config.factory') ->getEditable('system.site'); // Instance of DrupalCoreConfigConfig $config->set('page.front', 'new-front-page'); $config->save();
  • 10. Main stages of creation ● Definition of scheme and interface ● Basic defenition of the class ● We expand opportunities: add listing of object, add CRUD forms ● Removing of configuration entity
  • 11. Schema of Configuration entity File: config_pages.schema.yml config_pages.type.*: type: config_entity label: 'Config page type settings' mapping: id: type: string label: 'ID' label: type: label label: 'Label'
  • 12. Basic definition of the class File: ConfigPagesType.php namespace Drupalconfig_pagesEntity; use DrupalCoreConfigEntityConfigEntityBundleBase; /** * @ConfigEntityType( * id = "config_pages_type", * admin_permission = "administer config_pages types", * label = @Translation("Config page type"), * config_prefix = "type", * entity_keys = { * "id" = "id", * "label" = "label", * "context" = "context", * "menu" = "menu" * }, * ) */ class ConfigPagesType extends ConfigEntityBundleBase implements ConfigPagesTypeInterface { /** * The config page type ID. */ protected $id; /** * The config page type label. */ protected $label; }
  • 13. Listing of Config Entity File: ConfigPagesType.php * handlers = { * "list_builder" = * "Drupalconfig_pagesConfigPagesTypeListBuilder" * }, File: config_pages.routing.yml entity.config_pages_type.collection: path: '/admin/structure/config_pages/types' defaults: _entity_list: 'config_pages_type' _title: 'Config Pages Types' requirements: _permission: 'administer config_pages entity'
  • 14. ConfigPagesTypeListBuilder class <?php namespace Drupalconfig_pages; use DrupalCoreConfigEntityConfigEntityListBuilder; use DrupalCoreEntityEntityInterface; /** * Defines a class to build a listing of custom config page type entities. */ class ConfigPagesTypeListBuilder extends ConfigEntityListBuilder { /** * Changes list of operation. */ public function getDefaultOperations(EntityInterface $entity) {...} /** * Changes for header */ public function buildHeader() {...} /** * Changes for row. */ public function buildRow(EntityInterface $entity) {...} /** * {@inheritdoc} */ protected function getTitle() {...} }
  • 15. Listing of ConfigPagesType objects Path: /admin/structure/config_pages/types
  • 16. Management forms of Config Entity ● Creating a new class ConfigPagesTypeForm, describing the form ● Add class to definition of Configuration Entity ● Add new route to config_pages.routing.yml ● Add new local action for adding new Configuration object
  • 17. ConfigPagesTypeForm class File: ConfigPagesTypeForm.php namespace Drupalconfig_pages; use DrupalCoreEntityEntityForm; use DrupalCoreEntityEntityTypeInterface; use DrupalCoreFormFormStateInterface; /** * Base form for config_pages edit forms. */ class ConfigPagesTypeForm extends EntityForm { /** * Required routes rebuild. */ protected $routesRebuildRequired = FALSE; /** * Form definition. */ public function form(array $form, FormStateInterface $form_state) {...} /** * Form validation. */ public function validateForm(array &$form, FormStateInterface $form_state) {...} /** * Form save. */ public function save(array $form, FormStateInterface $form_state) {...} }
  • 18. Annotation of Configuration Entity * handlers = { * "form" = { * "default" = "Drupalconfig_pagesConfigPagesTypeForm", * "add" = "Drupalconfig_pagesConfigPagesTypeForm", * "edit" = "Drupalconfig_pagesConfigPagesTypeForm", * "delete" = * "Drupalconfig_pagesFormConfigPagesTypeDeleteForm" * }, * "list_builder" = * "Drupalconfig_pagesConfigPagesTypeListBuilder" * },
  • 19. Routes with forms File: config_pages.routing.yml entity.config_pages_type.edit_form: path: '/admin/structure/config_pages/types/manage/{config_pages_type}' defaults: _entity_form: 'config_pages_type.edit' _title: 'Edit' requirements: _entity_access: 'config_pages_type.update' options: _admin_route: TRUE entity.config_pages_type.delete_form: path: '/admin/structure/config_pages/types/manage/{config_pages_type}/delete' defaults: _entity_form: 'config_pages_type.delete' _title: 'Delete' requirements: _entity_access: 'config_pages_type.delete' options: _admin_route: TRUE
  • 20. Edit Form example Path: admin/structure/config_pages/types/manage/my_custom_page
  • 21. Local action add File: config_pages.links.action.yml config_pages_type_add: route_name: config_pages.type_add title: 'Add config page' appears_on: - entity.config_pages_type.collection
  • 22. Listing of configuration objects Path: /admin/structure/config_pages/types
  • 23. Configuration API Code examples <?php $config_name = 'config_pages.type.my_custom_page'; $config = Drupal::service('config.factory') ->getEditable($config_name); // Instance of DrupalCoreConfigConfig $config = Drupal::config($config_name); // Instance of DrupalCoreConfigImmutableConfig $object = Drupalconfig_pagesEntityConfigPagesType::load('my_custom _page');