SlideShare une entreprise Scribd logo
1  sur  25
Drupal 8 Entities
Content vs Configuration
Andy Postnikov, 2013
Entity? Node != Content?
Drupal 7 entities
● Node
● Comment
● User
● Term
● Vocabulary
●
● Contrib … Commerce, Message, ECK, ...
●
● Entity API, Rules, DS
Drupal 8 entities
Ctools + Entity API + DS + Rules
EntityInterface
ContentEntityInterface
ConfigEntityInterface
Entity
Taxonomy vocabulary
D8 entity - taxonomy_vocabulary
core/profiles/standard/config/taxonomy.vocabulary.tags.yml
● vid: tags
● name: Tags
● description: 'Use tags to group articles on similar topics into categories.'
● hierarchy: '0'
● weight: '0'
● status: '1'
● langcode: en
Role — Drupal 8 changes!
Role = user_role config
/core/profiles/standard
/config/user.role.administrator.yml
● id: administrator
● label: Administrator
● weight: 2
● langcode: en
Node & NodeType
type: article
name: Article
base: node_content
module: node
disabled: '0'
locked: '0'
custom: '1'
status: '1'
langcode: und
description: 'Use
<em>articles</em> for
time-sensitive content like
news, press releases or
blog posts.'
help: ''
has_title: '1'
title_label: Title
settings:
node:
preview: '1'
options:
status: status
promote: promote
sticky: '0'
revision: '0'
submitted: '1'
Node = nid, uuid, vid, type, langcode [tnid, translate]
{node_field_data} + {node_field_revision} = title, uid...
NodeType http://dgo.to/111715 - conversion
Content vs Config
● Contact
● Vocabulary
● View
● Custom block
● Role
● Menu
Block config vs Block content → Content
ContentEntityInterface
ConfigEntityInterface
getOriginalID() + setStatus()
Language Entity or Class
● Each entity contains
– UUID - Universally unique identifier for this entity. (128)
– LANGCODE - varchar(12)
● Modules:
– Locale
– language
– translation @deprecated
– translation_entity
Entity translation in core
Entity = Plugin (wtf)
DrupaluserPluginCoreEntityUser
/**
* Defines the user entity class.
*
* @EntityType(
* id = "user",
* label = @Translation("User"),
* module = "user",
* controllers = {
* "storage" =
"DrupaluserUserStorageController",
* "access" =
"DrupaluserUserAccessController",
* "render" =
"DrupalCoreEntityEntityRenderController",
* "form" = {
* "profile" =
"DrupaluserProfileFormController",
* "register" =
"DrupaluserRegisterFormController"
* },
* "translation" =
"DrupaluserProfileTranslationController"
* },
* default_operation = "profile",
* base_table = "users",
* uri_callback = "user_uri",
* route_base_path =
"admin/config/people/accounts",
* label_callback = "user_label",
* fieldable = TRUE,
* translatable = TRUE,
* entity_keys = {
* "id" = "uid",
* "uuid" = "uuid"
* }
* )
*/
class User extends EntityNG implements
UserInterface {
…
interface UserInterface extends
EntityInterface {}
class Entity implements
IteratorAggregate, EntityInterface {}
class EntityNG extends Entity {}
Entity API
● Definition:
– Annotation @EntityType
– hook_entity_info(&$entity_info) +
hook_entity_info_alter(&$entity_info)
– hook_entity_bundle_info() +
hook_entity_bundle_info_alter(&$bundles)
– Display entity via RenderController
● ViewMode
● EntityDisplay
● EntityFormDisplay
Entity API
● Controllers:
– EntityStorageControllerInterface
– EntityAccessControllerInterface
– EntityRenderControllerInterface
– EntityFormControllerInterface — many
– EntityTranslationControllerInterface
Entity NG
● Why Drupal 8 slow (x4) => entityBCdecorator
<?php
/**
* @file
* Contains DrupalCoreEntityEntity.
*/
/**
* Implements DrupalCoreEntityEntityInterface::getBCEntity().
*/
public function getBCEntity() {
return $this;
}
/**
* Implements DrupalCoreEntityEntityInterface::getNGEntity().
*/
public function getNGEntity() {
return $this;
}
Entity NG - BC
● Magic methods vs native properties
<?php
/**
* @file
* Contains DrupalCoreEntityEntityNG.
*/
/**
* Overrides Entity::getBCEntity().
*/
public function getBCEntity() {
if (!isset($this->bcEntity)) {
// Initialize field definitions so that we can pass them by reference.
$this->getPropertyDefinitions();
$this->bcEntity = new EntityBCDecorator($this, $this->fieldDefinitions);
}
return $this->bcEntity;
}
Fields NG
● Bundles are separated from entity definition
● Field and Field instance are config objects
● Todo:
– Replace most field-hooks with TypedData
– Review mega patches in sandboxes
– Allow use widgets and formatters for any data
object (none-configurable field)
Fields for menu links
● * @EntityType(
● * id = "menu",
● * label = @Translation("Menu"),
● * module = "system",
● * controllers = {
● * "storage" = "DrupalCoreConfigEntityConfigStorageController"
● * },
● * config_prefix = "menu.menu",
● * entity_keys = {
● * "id" = "id",
● * "label" = "label",
● * "uuid" = "uuid"
● * }
TypedData
Validation
● #2002152 by fago, amateescu: Implement
entity validation based on symfony validator.
●
● Make formatters and widgets work on
nonconfigurable fields
https://drupal.org/node/1950632
Todo
● [meta] Unified Entity Field API
– https://drupal.org/node/1346214
● Move entity-type specific storage logic into
entity classes
– https://drupal.org/node/1893772
● [META] Unify entity fields and field API
– https://drupal.org/node/1949932
Questions
● http://entity.worldempire.ch
● http://realize.be/field-api/
● http://buytaert.net/want-more-features-in-drupal-8-h

Contenu connexe

Tendances

Jquery Plugin
Jquery PluginJquery Plugin
Jquery PluginRavi Mone
 
Filtering data with D2W
Filtering data with D2W Filtering data with D2W
Filtering data with D2W WO Community
 
Drupal Field API. Practical usage
Drupal Field API. Practical usageDrupal Field API. Practical usage
Drupal Field API. Practical usagePavel Makhrinsky
 
Domain-driven Design in PHP and Symfony - Drupal Camp Wroclaw!
Domain-driven Design in PHP and Symfony - Drupal Camp Wroclaw!Domain-driven Design in PHP and Symfony - Drupal Camp Wroclaw!
Domain-driven Design in PHP and Symfony - Drupal Camp Wroclaw!Kacper Gunia
 
Drupal 8: Forms
Drupal 8: FormsDrupal 8: Forms
Drupal 8: Formsdrubb
 
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
 
Migrating Drupal 7 to Drupal 8
Migrating Drupal 7 to Drupal 8Migrating Drupal 7 to Drupal 8
Migrating Drupal 7 to Drupal 8Promet Source
 
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
 
Introduction to hibernate
Introduction to hibernateIntroduction to hibernate
Introduction to hibernatehr1383
 
Intro To Hibernate
Intro To HibernateIntro To Hibernate
Intro To HibernateAmit Himani
 
Hibernate Tutorial
Hibernate TutorialHibernate Tutorial
Hibernate TutorialRam132
 
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
 
Java Persistence API (JPA) Step By Step
Java Persistence API (JPA) Step By StepJava Persistence API (JPA) Step By Step
Java Persistence API (JPA) Step By StepGuo Albert
 
Scorware - Spring Introduction
Scorware - Spring IntroductionScorware - Spring Introduction
Scorware - Spring Introductionvschiavoni
 
Meet Magento Sweden - Magento 2 Layout and Code Compilation for Performance
Meet Magento Sweden - Magento 2 Layout and Code Compilation for PerformanceMeet Magento Sweden - Magento 2 Layout and Code Compilation for Performance
Meet Magento Sweden - Magento 2 Layout and Code Compilation for PerformanceIvan Chepurnyi
 

Tendances (20)

Field api.From d7 to d8
Field api.From d7 to d8Field api.From d7 to d8
Field api.From d7 to d8
 
Jquery Plugin
Jquery PluginJquery Plugin
Jquery Plugin
 
Filtering data with D2W
Filtering data with D2W Filtering data with D2W
Filtering data with D2W
 
Drupal Field API. Practical usage
Drupal Field API. Practical usageDrupal Field API. Practical usage
Drupal Field API. Practical usage
 
Domain-driven Design in PHP and Symfony - Drupal Camp Wroclaw!
Domain-driven Design in PHP and Symfony - Drupal Camp Wroclaw!Domain-driven Design in PHP and Symfony - Drupal Camp Wroclaw!
Domain-driven Design in PHP and Symfony - Drupal Camp Wroclaw!
 
Drupal 8: Forms
Drupal 8: FormsDrupal 8: Forms
Drupal 8: Forms
 
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
 
Migrating Drupal 7 to Drupal 8
Migrating Drupal 7 to Drupal 8Migrating Drupal 7 to Drupal 8
Migrating Drupal 7 to Drupal 8
 
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
 
Handlebars.js
Handlebars.jsHandlebars.js
Handlebars.js
 
Introduction to hibernate
Introduction to hibernateIntroduction to hibernate
Introduction to hibernate
 
Intro To Hibernate
Intro To HibernateIntro To Hibernate
Intro To Hibernate
 
Hibernate Tutorial
Hibernate TutorialHibernate Tutorial
Hibernate Tutorial
 
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)
 
Java Persistence API (JPA) Step By Step
Java Persistence API (JPA) Step By StepJava Persistence API (JPA) Step By Step
Java Persistence API (JPA) Step By Step
 
Scorware - Spring Introduction
Scorware - Spring IntroductionScorware - Spring Introduction
Scorware - Spring Introduction
 
Java persistence api 2.1
Java persistence api 2.1Java persistence api 2.1
Java persistence api 2.1
 
Multilingual drupal 7
Multilingual drupal 7Multilingual drupal 7
Multilingual drupal 7
 
Meet Magento Sweden - Magento 2 Layout and Code Compilation for Performance
Meet Magento Sweden - Magento 2 Layout and Code Compilation for PerformanceMeet Magento Sweden - Magento 2 Layout and Code Compilation for Performance
Meet Magento Sweden - Magento 2 Layout and Code Compilation for Performance
 

Similaire à Drupal 8 entities & felds

TangoWithDjango - ch8
TangoWithDjango - ch8TangoWithDjango - ch8
TangoWithDjango - ch8Asika Kuo
 
Writing Gadgets with the WSO2 Gadget Server
Writing Gadgets with the WSO2 Gadget ServerWriting Gadgets with the WSO2 Gadget Server
Writing Gadgets with the WSO2 Gadget ServerWSO2
 
Thinking in Components
Thinking in ComponentsThinking in Components
Thinking in ComponentsAnton Ivanov
 
Entities in drupal 7
Entities in drupal 7Entities in drupal 7
Entities in drupal 7Zsolt Tasnadi
 
Java on Google App engine
Java on Google App engineJava on Google App engine
Java on Google App engineMichael Parker
 
Dgeni documentation generator
Dgeni   documentation generatorDgeni   documentation generator
Dgeni documentation generatorPeter Darwin
 
2016 stop writing javascript frameworks by Joe Gregorio
2016 stop writing javascript frameworks by Joe Gregorio2016 stop writing javascript frameworks by Joe Gregorio
2016 stop writing javascript frameworks by Joe GregorioDavid Zapateria Besteiro
 
Understanding the Entity API Module
Understanding the Entity API ModuleUnderstanding the Entity API Module
Understanding the Entity API ModuleSergiu Savva
 
PhpStorm: Symfony2 Plugin
PhpStorm: Symfony2 PluginPhpStorm: Symfony2 Plugin
PhpStorm: Symfony2 PluginHaehnchen
 
Utilising the data attribute
Utilising the data attributeUtilising the data attribute
Utilising the data attributeRichard Martens
 
Practical JavaScript Programming - Session 4/8
Practical JavaScript Programming - Session 4/8Practical JavaScript Programming - Session 4/8
Practical JavaScript Programming - Session 4/8Wilson Su
 
Modern frontend development with VueJs
Modern frontend development with VueJsModern frontend development with VueJs
Modern frontend development with VueJsTudor Barbu
 
Five android architecture
Five android architectureFive android architecture
Five android architectureTomislav Homan
 
[Srijan Wednesday Webinars] Ruling Drupal 8 with #d8rules
[Srijan Wednesday Webinars] Ruling Drupal 8 with #d8rules[Srijan Wednesday Webinars] Ruling Drupal 8 with #d8rules
[Srijan Wednesday Webinars] Ruling Drupal 8 with #d8rulesSrijan Technologies
 

Similaire à Drupal 8 entities & felds (20)

TangoWithDjango - ch8
TangoWithDjango - ch8TangoWithDjango - ch8
TangoWithDjango - ch8
 
Entity api
Entity apiEntity api
Entity api
 
Writing Gadgets with the WSO2 Gadget Server
Writing Gadgets with the WSO2 Gadget ServerWriting Gadgets with the WSO2 Gadget Server
Writing Gadgets with the WSO2 Gadget Server
 
Thinking in Components
Thinking in ComponentsThinking in Components
Thinking in Components
 
Entities in drupal 7
Entities in drupal 7Entities in drupal 7
Entities in drupal 7
 
Java on Google App engine
Java on Google App engineJava on Google App engine
Java on Google App engine
 
Rest application
Rest applicationRest application
Rest application
 
Dgeni documentation generator
Dgeni   documentation generatorDgeni   documentation generator
Dgeni documentation generator
 
.Net template solution architecture
.Net template solution architecture.Net template solution architecture
.Net template solution architecture
 
Angular js-crash-course
Angular js-crash-courseAngular js-crash-course
Angular js-crash-course
 
2016 stop writing javascript frameworks by Joe Gregorio
2016 stop writing javascript frameworks by Joe Gregorio2016 stop writing javascript frameworks by Joe Gregorio
2016 stop writing javascript frameworks by Joe Gregorio
 
Understanding the Entity API Module
Understanding the Entity API ModuleUnderstanding the Entity API Module
Understanding the Entity API Module
 
PhpStorm: Symfony2 Plugin
PhpStorm: Symfony2 PluginPhpStorm: Symfony2 Plugin
PhpStorm: Symfony2 Plugin
 
Utilising the data attribute
Utilising the data attributeUtilising the data attribute
Utilising the data attribute
 
Practical JavaScript Programming - Session 4/8
Practical JavaScript Programming - Session 4/8Practical JavaScript Programming - Session 4/8
Practical JavaScript Programming - Session 4/8
 
Modern frontend development with VueJs
Modern frontend development with VueJsModern frontend development with VueJs
Modern frontend development with VueJs
 
Test02
Test02Test02
Test02
 
Five android architecture
Five android architectureFive android architecture
Five android architecture
 
[Srijan Wednesday Webinars] Ruling Drupal 8 with #d8rules
[Srijan Wednesday Webinars] Ruling Drupal 8 with #d8rules[Srijan Wednesday Webinars] Ruling Drupal 8 with #d8rules
[Srijan Wednesday Webinars] Ruling Drupal 8 with #d8rules
 
08ui.pptx
08ui.pptx08ui.pptx
08ui.pptx
 

Dernier

Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 

Dernier (20)

Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 

Drupal 8 entities & felds

  • 1. Drupal 8 Entities Content vs Configuration Andy Postnikov, 2013
  • 2. Entity? Node != Content?
  • 3. Drupal 7 entities ● Node ● Comment ● User ● Term ● Vocabulary ● ● Contrib … Commerce, Message, ECK, ... ● ● Entity API, Rules, DS
  • 4. Drupal 8 entities Ctools + Entity API + DS + Rules EntityInterface ContentEntityInterface ConfigEntityInterface Entity
  • 6. D8 entity - taxonomy_vocabulary core/profiles/standard/config/taxonomy.vocabulary.tags.yml ● vid: tags ● name: Tags ● description: 'Use tags to group articles on similar topics into categories.' ● hierarchy: '0' ● weight: '0' ● status: '1' ● langcode: en
  • 7. Role — Drupal 8 changes!
  • 8. Role = user_role config /core/profiles/standard /config/user.role.administrator.yml ● id: administrator ● label: Administrator ● weight: 2 ● langcode: en
  • 9. Node & NodeType type: article name: Article base: node_content module: node disabled: '0' locked: '0' custom: '1' status: '1' langcode: und description: 'Use <em>articles</em> for time-sensitive content like news, press releases or blog posts.' help: '' has_title: '1' title_label: Title settings: node: preview: '1' options: status: status promote: promote sticky: '0' revision: '0' submitted: '1' Node = nid, uuid, vid, type, langcode [tnid, translate] {node_field_data} + {node_field_revision} = title, uid... NodeType http://dgo.to/111715 - conversion
  • 10. Content vs Config ● Contact ● Vocabulary ● View ● Custom block ● Role ● Menu Block config vs Block content → Content
  • 13. Language Entity or Class ● Each entity contains – UUID - Universally unique identifier for this entity. (128) – LANGCODE - varchar(12) ● Modules: – Locale – language – translation @deprecated – translation_entity
  • 15. Entity = Plugin (wtf) DrupaluserPluginCoreEntityUser /** * Defines the user entity class. * * @EntityType( * id = "user", * label = @Translation("User"), * module = "user", * controllers = { * "storage" = "DrupaluserUserStorageController", * "access" = "DrupaluserUserAccessController", * "render" = "DrupalCoreEntityEntityRenderController", * "form" = { * "profile" = "DrupaluserProfileFormController", * "register" = "DrupaluserRegisterFormController" * }, * "translation" = "DrupaluserProfileTranslationController" * }, * default_operation = "profile", * base_table = "users", * uri_callback = "user_uri", * route_base_path = "admin/config/people/accounts", * label_callback = "user_label", * fieldable = TRUE, * translatable = TRUE, * entity_keys = { * "id" = "uid", * "uuid" = "uuid" * } * ) */ class User extends EntityNG implements UserInterface { … interface UserInterface extends EntityInterface {} class Entity implements IteratorAggregate, EntityInterface {} class EntityNG extends Entity {}
  • 16. Entity API ● Definition: – Annotation @EntityType – hook_entity_info(&$entity_info) + hook_entity_info_alter(&$entity_info) – hook_entity_bundle_info() + hook_entity_bundle_info_alter(&$bundles) – Display entity via RenderController ● ViewMode ● EntityDisplay ● EntityFormDisplay
  • 17. Entity API ● Controllers: – EntityStorageControllerInterface – EntityAccessControllerInterface – EntityRenderControllerInterface – EntityFormControllerInterface — many – EntityTranslationControllerInterface
  • 18. Entity NG ● Why Drupal 8 slow (x4) => entityBCdecorator <?php /** * @file * Contains DrupalCoreEntityEntity. */ /** * Implements DrupalCoreEntityEntityInterface::getBCEntity(). */ public function getBCEntity() { return $this; } /** * Implements DrupalCoreEntityEntityInterface::getNGEntity(). */ public function getNGEntity() { return $this; }
  • 19. Entity NG - BC ● Magic methods vs native properties <?php /** * @file * Contains DrupalCoreEntityEntityNG. */ /** * Overrides Entity::getBCEntity(). */ public function getBCEntity() { if (!isset($this->bcEntity)) { // Initialize field definitions so that we can pass them by reference. $this->getPropertyDefinitions(); $this->bcEntity = new EntityBCDecorator($this, $this->fieldDefinitions); } return $this->bcEntity; }
  • 20. Fields NG ● Bundles are separated from entity definition ● Field and Field instance are config objects ● Todo: – Replace most field-hooks with TypedData – Review mega patches in sandboxes – Allow use widgets and formatters for any data object (none-configurable field)
  • 21. Fields for menu links ● * @EntityType( ● * id = "menu", ● * label = @Translation("Menu"), ● * module = "system", ● * controllers = { ● * "storage" = "DrupalCoreConfigEntityConfigStorageController" ● * }, ● * config_prefix = "menu.menu", ● * entity_keys = { ● * "id" = "id", ● * "label" = "label", ● * "uuid" = "uuid" ● * }
  • 23. Validation ● #2002152 by fago, amateescu: Implement entity validation based on symfony validator. ● ● Make formatters and widgets work on nonconfigurable fields https://drupal.org/node/1950632
  • 24. Todo ● [meta] Unified Entity Field API – https://drupal.org/node/1346214 ● Move entity-type specific storage logic into entity classes – https://drupal.org/node/1893772 ● [META] Unify entity fields and field API – https://drupal.org/node/1949932
  • 25. Questions ● http://entity.worldempire.ch ● http://realize.be/field-api/ ● http://buytaert.net/want-more-features-in-drupal-8-h