d r u p a l i z e y o u r d a t a u s e e n t i t i e s
play

D r u p a l i z e Y o u r D a t a : U s e E n - PowerPoint PPT Presentation

D r u p a l i z e Y o u r D a t a : U s e E n t i t i e s ! Drupal Dev Days Barcelona 2012 by Wolfgang Ziegler // fago Wo l f g a n g Z i e g l e r / / f a g o from Vienna, Austria studied


  1. D r u p a l i z e Y o u r D a t a : U s e E n t i t i e s ! Drupal Dev Days Barcelona 2012 by Wolfgang Ziegler // fago

  2. Wo l f g a n g Z i e g l e r / / f a g o • from Vienna, Austria • studied at the TU Vienna • Drupal since 2005. wolfgangziegler.net twitter.com/the_real_fago gplus.to/fago

  3. O u t l i n e • Introduction • Interact with entities • Providing a new entity type • Expose non-DB entities • Outlook

  4. D r u p a l 7 : F i e l d s e v e r y wh e r e !

  5. B u n d l e s Entity type ↔ Node Bundle ↔ Node type Entity type ↔ Taxonomy term Bundle ↔ Vocabulary Entity type ↔ User Bundle ↔ {}

  6. Wh i c h e n t i t i e s a r e t h e r e ? • Core • Modules: • Drupal commerce • Organic groups • Profile2 • Heartbeat and Message • File entity

  7. N o d e mo d u l e s E n t i t y mo d u l e s

  8. E n t i t y A P I - Wh a t f o r ? Unified way to access data.

  9. User Search Node Vote Comment Entity Groups Entity Profile reference Product Rules

  10. I n t e r a c t i n g wi t h e n t i t i e s

  11. E n t i t y A P I mo d u l e Assists you with • interacting with entities • and providing new entity types

  12. E n t i t y A P I F u n c t i o n s Entity API module entity_get_property_info() entity_id() Drupal Core entity_view() entity_get_info() entity_save() entity_load() entity_create() entity_delete() entity_access() entity_metadata_wrapper()

  13. Me t a d a t a Wr a p p e r $wrapper = entity_metadata_wrapper('node', $nid); $mail = $wrapper->author->mail->value(); $wrapper->author->mail->set('fago@example.com'); $text = $wrapper->field_text->value(); $wrapper->language('de')->field_text->value(); $terms = $wrapper->field_tags->value(); $wrapper->field_tags[] = $term; $options = $wrapper->field_tags->optionsList(); $label = $wrapper->field_tags[0]->label(); $access = $wrapper->field_tags->access('edit');

  14. E n t i t y p r o p e r t y i n f o $properties['mail'] = array( 'label' => t("Email"), 'type' => 'text', 'description' => t("The email address of ..."), 'setter callback' => 'entity_property_verbatim_set', 'validation callback' => 'valid_email_address', 'required' => TRUE, 'access callback' => 'user_properties_access', 'schema field' => 'mail', );

  15. P r o p e r t y i n f o ? • Unified access to entity data • Validation • Access information

  16. H o w mo d u l e s u s e i t • Drupal Commerce, VBO, OG • Rules, Search API • RestWS, WSClient • Microdata, RDFx • Entity tokens • Entity Views (Search API, EFQ views)

  17. P r o v i d i n g a n e n t i t y t y p e • Implement hook_entity_info() • Specify your ' controller class' • Implement hook_schema()

  18. E n t i t y A P I mo d u l e $profile = entity_create('profile2', array( 'type' => 'main', 'user'=> $account, )); $profile->save(); $profile->delete(); entity_delete_multiple('profile2', array(1, 2, 3));

  19. I n t e g r a t i n g y o u r e n t i t y t y p e Tokens Views Rules XY Property Field API Info CRUD Info Schema controller

  20. E x p o r t a b l e e n t i t i e s similar to CTools exportables, but... • unified CRUD interface • regular CRUD hooks • synced to the DB • Admin UI, Features, i18n, Views, Tokens,...

  21. I n t e g r a t i n g y o u r e x p o r t a b l e e n t i t y Admin Features Views i18n Tokens UI Property Info CRUD Info Schema controller

  22. E x a mp l e : P r o f i l e 2 Profile2: • Entity type Profile2 types: • Entity type • Bundle of Profile2 • Exportable

  23. P r o f i l e 2 t o r n a p a r t Y o u r j o b • CRUD, Field API • Permissions, Access • Profile form, display • Admin UI, I18n • Views, CTools, Rules, Tokens, Features, Search API

  24. h o me wo r k d o n e , l e t ' s e n j o y i t .

  25. • NoSQL, Doctrine, PHPCR • Remote entities • Data integration

  26. N o n - D B e n t i t i e s + F i e l d s ?

  27. N o n - D B e n t i t i e s Views Info Controller Rules Schema Tokens XY CRUD Property Info controller Info

  28. Wh a t d o e s i t b u y u s ? • Classed CRUD API • CRUD Hooks • Tokens • Entity reference • Rules, Rules Links • Search API, Views integration, RestWS • …

  29. D r u p a l i z e y o u r d a t a !

  30. E x a mp l e . . .

  31. G o o g l e P i c a s a e n t i t i e s http://drupal.org/sandbox/fago/1493180

  32. R o o m f o r i mp r o v e me n t s • Generate display • Generate form • Ready-only mode

  33. D r u p a l 8

  34. C l a s s e d o b j e c t s . . . ! $comment = entity_create('comment', array( 'nid' => $node->nid, )); $comment->save(); echo $comment->id(); $comment->delete(); entity_delete_multiple('comment', array(1, 2, 3));

  35. C o mme n t s i n D r u p a l 8 class CommentStorageController extends EntityDatabaseStorageController { … } class Comment extends Entity { … } class Entity implements EntityInterface { … }

  36. E n t i t y P r o p e r t y A P I • Similar to the entity metadata wrappers, but improved and built-in! • Unified API for properties and fields • Property definitions / metadata • D8MI, WSCCI, Content staging, ... • Improved DX!

  37. WS C C I We b S e r v i c e s F o r ma t R e p o r t http://groups.drupal.org/node/237443

  38. Q u e s t i o n s ?

  39. T h a n k y o u !

Recommend


More recommend