SlideShare a Scribd company logo
1 of 35
Download to read offline
Good evening!
Thanks for dinner!
My name is Bart
Among other things, I 
am a Drupal developer.
I have worked on 
Drupal 7 & 8.
I have developed for 
Drupal 5, 6, 7, & 8.
I have organized regional, 
national, and international 
Drupal events since 2008.
Tonight is your first date 
with Drupal 8’s entity API.
Tonight’s schedule 
• What are entities? 
• Major changes since Drupal 7 
• Entities in Drupal 8 
• Content & config entities 
• Creating your own entity type 
• Q&A
What are entities?
Entities are self-contained 
units of complex data
Examples of entity types 
• Users 
• Content (nodes) 
• Taxonomy terms 
• Payments 
• Orders 
• Uploaded files 
• Payment methods 
• User roles 
• Custom blocks 
• Views 
• Menus 
• Image styles
What happened since 
Drupal 7?
Drupal 7 only loaded 
entities 
The Contributed Entity module did everything else.
Drupal 8 supports full 
CRUD
It supports revsions 
and translations too
Entities are interfaced 
They have class too.
Interfaces define what 
your class should do. 
Not how it’s supposed to do it.
Entity handlers 
Define how an entity type interacts with Entity API or 
modules.
Entity handlers 
• Storage 
• Access control (no more user_access() for entities) 
• Forms 
• Views 
• Listing 
• Viewing 
• Translation
Entity query 
Works with any entity storage. If you don’t know the entity 
type(’s storage), don’t use DB queries.
Content entities 
• Fieldable 
• Revisionable by default 
• Stored in the database by default 
• Do not define how a site or application works 
• Class properties are now base fields (typed data)
Config entities 
• Not fieldable 
• Not revisionable by default 
• Stored on file (and serialized in the database for 
performance) 
• Define how a site or application works
Creating your own 
entity type
Why? 
But, node types?
An entity type with its own 
interface can be 
endlessly refactored.
Choosing a base class 
• DrupalCoreEntityContentEntityBase 
• DrupalCoreConfigEntityConfigEntityBase
Choosing base handlers 
• DrupalCoreEntitySqlSqlContentEntityStorage 
• DrupalCoreConfigEntityConfigEntityStorage 
• DrupalCoreEntityEntityAccessControlHandler 
• DrupalCoreEntity(Content)EntityForm 
• DrupalCoreEntityEntityListBuilder
Writing the annotation 
/** 
* Defines a payment entity. 
* 
* @ContentEntityType( 
* field_ui_base_route = “payment.payment_type”, 
* handlers = { 
* "access" = "DrupalpaymentEntityPaymentPaymentAccessControlHandler", 
* "form" = { 
* "edit" = "DrupalpaymentEntityPaymentPaymentEditForm", 
* }, 
* }, 
* id = "payment", 
* label = @Translation("Payment"), 
* ) 
*/
Entity storage 
• Database schema handler 
• Config schema file
Routes can use 
handlers 
payment.payment.edit: 
path: '/payment/{payment}/edit' 
defaults: 
_entity_form: 'payment.edit' 
requirements: 
_entity_access: 'payment.update'
Plugins attached to 
entities
Evaluation
What have you learned? 
• The differences between the entity APIs in Drupal 7 
and 8. 
• The differences between content and config 
entities. 
• How to create a new entity type in Drupal 8 and 
why this is a good thing.
Q&A

More Related Content

What's hot

[Mas 500] Data Basics
[Mas 500] Data Basics[Mas 500] Data Basics
[Mas 500] Data Basics
rahulbot
 
CrossRef Workshops 2012 Small Publisher Tools Karl Ward
CrossRef Workshops 2012 Small Publisher Tools Karl WardCrossRef Workshops 2012 Small Publisher Tools Karl Ward
CrossRef Workshops 2012 Small Publisher Tools Karl Ward
Crossref
 
CrossRef Workshops 2012 Small Publisher Tools Karl Ward
CrossRef Workshops 2012 Small Publisher Tools Karl WardCrossRef Workshops 2012 Small Publisher Tools Karl Ward
CrossRef Workshops 2012 Small Publisher Tools Karl Ward
Crossref
 

What's hot (20)

Yql ans geo
Yql ans geoYql ans geo
Yql ans geo
 
Tech Gupshup Meetup On MongoDB - 24/06/2016
Tech Gupshup Meetup On MongoDB - 24/06/2016Tech Gupshup Meetup On MongoDB - 24/06/2016
Tech Gupshup Meetup On MongoDB - 24/06/2016
 
Why CouchDB
Why CouchDBWhy CouchDB
Why CouchDB
 
Modeling JSON data for NoSQL document databases
Modeling JSON data for NoSQL document databasesModeling JSON data for NoSQL document databases
Modeling JSON data for NoSQL document databases
 
RapidApp presentation for Cincinnati.pm
RapidApp presentation for Cincinnati.pmRapidApp presentation for Cincinnati.pm
RapidApp presentation for Cincinnati.pm
 
[Mas 500] Data Basics
[Mas 500] Data Basics[Mas 500] Data Basics
[Mas 500] Data Basics
 
CrossRef Workshops 2012 Small Publisher Tools Karl Ward
CrossRef Workshops 2012 Small Publisher Tools Karl WardCrossRef Workshops 2012 Small Publisher Tools Karl Ward
CrossRef Workshops 2012 Small Publisher Tools Karl Ward
 
Drupal 8 entities & felds
Drupal 8 entities & feldsDrupal 8 entities & felds
Drupal 8 entities & felds
 
Cassandra java libraries
Cassandra java librariesCassandra java libraries
Cassandra java libraries
 
SQL vs NoSQL, an experiment with MongoDB
SQL vs NoSQL, an experiment with MongoDBSQL vs NoSQL, an experiment with MongoDB
SQL vs NoSQL, an experiment with MongoDB
 
CrossRef Workshops 2012 Small Publisher Tools Karl Ward
CrossRef Workshops 2012 Small Publisher Tools Karl WardCrossRef Workshops 2012 Small Publisher Tools Karl Ward
CrossRef Workshops 2012 Small Publisher Tools Karl Ward
 
Why we love ArangoDB. The hunt for the right NosQL Database
Why we love ArangoDB. The hunt for the right NosQL DatabaseWhy we love ArangoDB. The hunt for the right NosQL Database
Why we love ArangoDB. The hunt for the right NosQL Database
 
Pega test topics - data modeling
Pega  test topics -  data modelingPega  test topics -  data modeling
Pega test topics - data modeling
 
Stupid Index Block Tricks
Stupid Index Block TricksStupid Index Block Tricks
Stupid Index Block Tricks
 
Relate
RelateRelate
Relate
 
Metaandmete haldus - Jüri Harju
Metaandmete haldus -  Jüri HarjuMetaandmete haldus -  Jüri Harju
Metaandmete haldus - Jüri Harju
 
Building a spa_in_30min
Building a spa_in_30minBuilding a spa_in_30min
Building a spa_in_30min
 
Core Data without headaches
Core Data without headachesCore Data without headaches
Core Data without headaches
 
Java script
Java scriptJava script
Java script
 
Suggest.js
Suggest.jsSuggest.js
Suggest.js
 

Similar to Entities in Drupal 8 - Drupal Tech Talk - Bart Feenstra

Hibernate in XPages
Hibernate in XPagesHibernate in XPages
Hibernate in XPages
Toby Samples
 
SharePoint 2014: Where to save my data, for devs!
SharePoint 2014: Where to save my data, for devs!SharePoint 2014: Where to save my data, for devs!
SharePoint 2014: Where to save my data, for devs!
Ben Steinhauser
 
Migrating to Drupal 8
Migrating to Drupal 8Migrating to Drupal 8
Migrating to Drupal 8
Alkuvoima
 

Similar to Entities in Drupal 8 - Drupal Tech Talk - Bart Feenstra (20)

Top 8 Improvements in Drupal 8
Top 8 Improvements in Drupal 8Top 8 Improvements in Drupal 8
Top 8 Improvements in Drupal 8
 
Drupal as a Programmer-Friendly CMS at ConFoo
Drupal as a Programmer-Friendly CMS at ConFooDrupal as a Programmer-Friendly CMS at ConFoo
Drupal as a Programmer-Friendly CMS at ConFoo
 
Drupalcon cph
Drupalcon cphDrupalcon cph
Drupalcon cph
 
Search api d8
Search api d8Search api d8
Search api d8
 
Hibernate in XPages
Hibernate in XPagesHibernate in XPages
Hibernate in XPages
 
Real World MVC
Real World MVCReal World MVC
Real World MVC
 
Drupalize your data use entities
Drupalize your data use entitiesDrupalize your data use entities
Drupalize your data use entities
 
Config management
Config managementConfig management
Config management
 
Drupal 8 Deep Dive: Plugin System
Drupal 8 Deep Dive: Plugin SystemDrupal 8 Deep Dive: Plugin System
Drupal 8 Deep Dive: Plugin System
 
ASP.NET MVC and Entity Framework 4
ASP.NET MVC and Entity Framework 4ASP.NET MVC and Entity Framework 4
ASP.NET MVC and Entity Framework 4
 
SharePoint 2014: Where to save my data, for devs!
SharePoint 2014: Where to save my data, for devs!SharePoint 2014: Where to save my data, for devs!
SharePoint 2014: Where to save my data, for devs!
 
Where to save my data, for devs!
Where to save my data, for devs!Where to save my data, for devs!
Where to save my data, for devs!
 
MVC and Entity Framework 4
MVC and Entity Framework 4MVC and Entity Framework 4
MVC and Entity Framework 4
 
Zero to Sixty with Oracle ApEx
Zero to Sixty with Oracle ApExZero to Sixty with Oracle ApEx
Zero to Sixty with Oracle ApEx
 
Migrate to Drupal 8
Migrate to Drupal 8Migrate to Drupal 8
Migrate to Drupal 8
 
IBM File Net P8
IBM File Net P8IBM File Net P8
IBM File Net P8
 
Drupal 8 Basic Training - DrupalEurope 2018 - Maarten De Block
Drupal 8 Basic Training - DrupalEurope 2018 - Maarten De BlockDrupal 8 Basic Training - DrupalEurope 2018 - Maarten De Block
Drupal 8 Basic Training - DrupalEurope 2018 - Maarten De Block
 
Ready. Set. Drupal! An Intro to Drupal 8, Part 2
Ready. Set. Drupal! An Intro to Drupal 8, Part 2Ready. Set. Drupal! An Intro to Drupal 8, Part 2
Ready. Set. Drupal! An Intro to Drupal 8, Part 2
 
Migrating to Drupal 8
Migrating to Drupal 8Migrating to Drupal 8
Migrating to Drupal 8
 
2010 05-21, object-relational mapping using hibernate v2
2010 05-21, object-relational mapping using hibernate v22010 05-21, object-relational mapping using hibernate v2
2010 05-21, object-relational mapping using hibernate v2
 

More from Triquanta

More from Triquanta (7)

Showcase Joost DrupalCon Vienna
Showcase Joost DrupalCon ViennaShowcase Joost DrupalCon Vienna
Showcase Joost DrupalCon Vienna
 
Hoe CMI in Drupal features overbodig maakt (of toch niet) - Drupal Tech Talk ...
Hoe CMI in Drupal features overbodig maakt (of toch niet) - Drupal Tech Talk ...Hoe CMI in Drupal features overbodig maakt (of toch niet) - Drupal Tech Talk ...
Hoe CMI in Drupal features overbodig maakt (of toch niet) - Drupal Tech Talk ...
 
The backend-of-frontend Drupaljam 2014
The backend-of-frontend Drupaljam 2014The backend-of-frontend Drupaljam 2014
The backend-of-frontend Drupaljam 2014
 
Toegankelijke Data
Toegankelijke DataToegankelijke Data
Toegankelijke Data
 
Search met solr
Search met solrSearch met solr
Search met solr
 
Drupal theming met sass, compass, susy en aurora
Drupal theming met sass, compass, susy en auroraDrupal theming met sass, compass, susy en aurora
Drupal theming met sass, compass, susy en aurora
 
Van adlib naar online collectie
Van adlib naar online collectieVan adlib naar online collectie
Van adlib naar online collectie
 

Recently uploaded

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
sexy 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 Call
shivangimorya083
 
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
soniya singh
 
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
Call Girls In Delhi Whatsup 9873940964 Enjoy Unlimited Pleasure
 
₹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
 
CALL ON ➥8923113531 🔝Call Girls Lucknow Lucknow best sexual service Online
CALL ON ➥8923113531 🔝Call Girls Lucknow Lucknow best sexual service OnlineCALL ON ➥8923113531 🔝Call Girls Lucknow Lucknow best sexual service Online
CALL ON ➥8923113531 🔝Call Girls Lucknow Lucknow best sexual service Online
anilsa9823
 
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
Call Girls In Delhi Whatsup 9873940964 Enjoy Unlimited Pleasure
 
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
soniya singh
 
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
soniya singh
 
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
Call Girls In Delhi Whatsup 9873940964 Enjoy Unlimited Pleasure
 
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝
soniya singh
 

Recently uploaded (20)

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
 
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting High Prof...
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting  High Prof...VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting  High Prof...
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting High Prof...
 
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
 
@9999965857 🫦 Sexy Desi Call Girls Laxmi Nagar 💓 High Profile Escorts Delhi 🫶
@9999965857 🫦 Sexy Desi Call Girls Laxmi Nagar 💓 High Profile Escorts Delhi 🫶@9999965857 🫦 Sexy Desi Call Girls Laxmi Nagar 💓 High Profile Escorts Delhi 🫶
@9999965857 🫦 Sexy Desi Call Girls Laxmi Nagar 💓 High Profile Escorts Delhi 🫶
 
On Starlink, presented by Geoff Huston at NZNOG 2024
On Starlink, presented by Geoff Huston at NZNOG 2024On Starlink, presented by Geoff Huston at NZNOG 2024
On Starlink, presented by Geoff Huston at NZNOG 2024
 
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
 
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
 
₹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...
 
Call Now ☎ 8264348440 !! Call Girls in Sarai Rohilla Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Sarai Rohilla Escort Service Delhi N.C.R.Call Now ☎ 8264348440 !! Call Girls in Sarai Rohilla Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Sarai Rohilla Escort Service Delhi N.C.R.
 
CALL ON ➥8923113531 🔝Call Girls Lucknow Lucknow best sexual service Online
CALL ON ➥8923113531 🔝Call Girls Lucknow Lucknow best sexual service OnlineCALL ON ➥8923113531 🔝Call Girls Lucknow Lucknow best sexual service Online
CALL ON ➥8923113531 🔝Call Girls Lucknow Lucknow best sexual service Online
 
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
 
Networking in the Penumbra presented by Geoff Huston at NZNOG
Networking in the Penumbra presented by Geoff Huston at NZNOGNetworking in the Penumbra presented by Geoff Huston at NZNOG
Networking in the Penumbra presented by Geoff Huston at NZNOG
 
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service AvailableCall Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
 
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
 
Russian Call Girls in %(+971524965298 )# Call Girls in Dubai
Russian Call Girls in %(+971524965298  )#  Call Girls in DubaiRussian Call Girls in %(+971524965298  )#  Call Girls in Dubai
Russian Call Girls in %(+971524965298 )# Call Girls in Dubai
 
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
 
Call Now ☎ 8264348440 !! Call Girls in Green Park Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Green Park Escort Service Delhi N.C.R.Call Now ☎ 8264348440 !! Call Girls in Green Park Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Green Park Escort Service Delhi N.C.R.
 
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
 
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝
 
Top Rated Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...
Top Rated  Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...Top Rated  Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...
Top Rated Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...
 

Entities in Drupal 8 - Drupal Tech Talk - Bart Feenstra

  • 3. My name is Bart
  • 4. Among other things, I am a Drupal developer.
  • 5. I have worked on Drupal 7 & 8.
  • 6. I have developed for Drupal 5, 6, 7, & 8.
  • 7. I have organized regional, national, and international Drupal events since 2008.
  • 8. Tonight is your first date with Drupal 8’s entity API.
  • 9. Tonight’s schedule • What are entities? • Major changes since Drupal 7 • Entities in Drupal 8 • Content & config entities • Creating your own entity type • Q&A
  • 11. Entities are self-contained units of complex data
  • 12. Examples of entity types • Users • Content (nodes) • Taxonomy terms • Payments • Orders • Uploaded files • Payment methods • User roles • Custom blocks • Views • Menus • Image styles
  • 13. What happened since Drupal 7?
  • 14. Drupal 7 only loaded entities The Contributed Entity module did everything else.
  • 15. Drupal 8 supports full CRUD
  • 16. It supports revsions and translations too
  • 17. Entities are interfaced They have class too.
  • 18. Interfaces define what your class should do. Not how it’s supposed to do it.
  • 19. Entity handlers Define how an entity type interacts with Entity API or modules.
  • 20. Entity handlers • Storage • Access control (no more user_access() for entities) • Forms • Views • Listing • Viewing • Translation
  • 21. Entity query Works with any entity storage. If you don’t know the entity type(’s storage), don’t use DB queries.
  • 22. Content entities • Fieldable • Revisionable by default • Stored in the database by default • Do not define how a site or application works • Class properties are now base fields (typed data)
  • 23. Config entities • Not fieldable • Not revisionable by default • Stored on file (and serialized in the database for performance) • Define how a site or application works
  • 24. Creating your own entity type
  • 25. Why? But, node types?
  • 26. An entity type with its own interface can be endlessly refactored.
  • 27. Choosing a base class • DrupalCoreEntityContentEntityBase • DrupalCoreConfigEntityConfigEntityBase
  • 28. Choosing base handlers • DrupalCoreEntitySqlSqlContentEntityStorage • DrupalCoreConfigEntityConfigEntityStorage • DrupalCoreEntityEntityAccessControlHandler • DrupalCoreEntity(Content)EntityForm • DrupalCoreEntityEntityListBuilder
  • 29. Writing the annotation /** * Defines a payment entity. * * @ContentEntityType( * field_ui_base_route = “payment.payment_type”, * handlers = { * "access" = "DrupalpaymentEntityPaymentPaymentAccessControlHandler", * "form" = { * "edit" = "DrupalpaymentEntityPaymentPaymentEditForm", * }, * }, * id = "payment", * label = @Translation("Payment"), * ) */
  • 30. Entity storage • Database schema handler • Config schema file
  • 31. Routes can use handlers payment.payment.edit: path: '/payment/{payment}/edit' defaults: _entity_form: 'payment.edit' requirements: _entity_access: 'payment.update'
  • 34. What have you learned? • The differences between the entity APIs in Drupal 7 and 8. • The differences between content and config entities. • How to create a new entity type in Drupal 8 and why this is a good thing.
  • 35. Q&A