D7 Entities

1,477 views

Published on

Drupal 7 Entities was delivered by Tomi Mikola of Mearra

Published in: Technology, News & Politics
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,477
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
24
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

D7 Entities

  1. 1. Drupal 7 Entities DrupalCamp Helsinki 27.9.2011 Tomi Mikolabusiness of open technology
  2. 2. About me • Working at Mearra • Architect, senior developer, project mgr, salesman, co-founder, Drupal evangelist • Drupal as the primary platform since 2006business of open technology
  3. 3. What are entities?business of open technology
  4. 4. Concept of Entity • Generalization of something that can be stored in Drupal • Standardized set of how data structures are represented • In D6 nodes were considered as the main abstraction pointbusiness of open technology
  5. 5. Concept of Entity • Type of objects which Drupal is aware of • Something unique, relevant to the application • "The new Node" • D7: Nodes, Users, Files, Comments, Terms, ...business of open technology
  6. 6. Fields and entitiesbusiness of open technology
  7. 7. Fields • Data types which can be attached to any kind of entity • Widgets & formatters • Field instancesbusiness of open technology
  8. 8. Bundles • Entity + field (*n) = Bundle • Node (entity), Article (bundle) • User (entity), User (bundle)business of open technology
  9. 9. business of open technology Entity API
  10. 10. Entity API • Contrib module (drupal.org/project/entity) • Completes what Drupal core entities should be • Full CRUD operationsbusiness of open technology
  11. 11. business of open technology Entity?
  12. 12. Entities or Nodes? • “I created a draft using Word” • Translations, versioning? • End-user’s point of view: “Content!”business of open technology
  13. 13. How to begin?business of open technology
  14. 14. How to begin with entities? • No UI • Write code • hook_schema() • hook_entity_info() • Label • Base table • Fieldablebusiness of open technology
  15. 15. How to begin with entities? function node_entity_info() { $return = array( node => array( label => t(Node), controller class => NodeController, base table => node, revision table => node_revision, uri callback => node_uri, fieldable => TRUE, entity keys => array( id => nid, revision => vid, bundle => type, label => title, ), bundles => array(), //...business of open technology
  16. 16. business of open technology Prove it!
  17. 17. Poll Improved (demo) • Drupal core Poll doesn’t take advantage of entities • Started new project to test Entity API • Model (contrib module) as basis • Flexibility by using Field APIbusiness of open technology
  18. 18. Thank you!business of open technology
  19. 19. business of open technology Photos © Tomi Mikola

×