Your SlideShare is downloading. ×
  • Like
Drupalize your data use entities
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Now you can save presentations on your phone or tablet

Available for both IPhone and Android

Text the download link to your phone

Standard text messaging rates apply

Drupalize your data use entities

  • 286 views
Published

Drupalize your data use entities …

Drupalize your data use entities
Druapl 7

Published in Technology , Education
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
286
On SlideShare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
5
Comments
0
Likes
1

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. CodinganddevelopmentDrupalizeYour Data:UseEntities!PresentedbyWolfgangZiegler // fago
  • 2. Wolfgang Ziegler // fago• from Vienna, Austria• studied at the TU Vienna• Drupal since 2005.wolfgangziegler.nettwitter.com/the_real_fagogplus.to/fago
  • 3. Outline• Introduction• Interact with entities• Providing a new entity type• Expose non-DB entities• Outlook
  • 4. Drupal 7:Fields everywhere!
  • 5. BundlesEntity type ↔ NodeBundle ↔ Node typeEntity type ↔ Taxonomy termBundle ↔ VocabularyEntity type ↔ UserBundle ↔ {}
  • 6. Which entities are there?• Core• Modules:• Drupal commerce• Organic groups• Profile2• Heartbeat and Message• File entity
  • 7. Node modulesEntity modules
  • 8. Entity API - What for?Unified way to access data.
  • 9. UserNodeCommentProfileProductSearchVoteGroupsEntityreferenceRulesEntity
  • 10. Interacting with entities
  • 11. Entity API moduleAssists you with• interacting with entities• and providing new entity types
  • 12. Entity API FunctionsDrupal CoreEntity API moduleentity_save()entity_load()entity_get_info()entity_metadata_wrapper()entity_view()entity_access()entity_create()entity_id()entity_get_property_info()entity_delete()
  • 13. Metadata Wrapper$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. Metadata Wrapper$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);
  • 15. Entity property info$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,);
  • 16. Property info?• Unified access to entity data• Validation• Access information
  • 17. How modules use it• Drupal Commerce, VBO, OG• Rules, Search API• Microdata• RestWS, WSClient• Entity tokens• Entity Views
  • 18. Providing an entity type• Implement hook_entity_info()• Specify your controller class• Implement hook_schema()
  • 19. Entity API module$profile = entity_create(profile2, array(  type => main,  user=> $account,));$profile­>save();$profile­>delete();entity_delete_multiple(profile2, array(1, 2, 3));
  • 20. Integrating your entity typeTokensViews RulesPropertyInfoField APISchemaCRUDcontrollerInfoXY
  • 21. Exportable entitiessimilar to CTools exportables, but...• unified CRUD interface• synced to the DB• regular CRUD hooks• Views, Tokens, Features, i18n, ...
  • 22. Integrating your exportable entitySchemaCRUDcontrollerInfoTokensPropertyInfoViews i18nFeaturesAdminUI
  • 23. Apocalypse now?• Provide an entity• get a bullshit of not fitting stuff•• Find a good metafa, or cite for it.• is it an elephant or moskito?
  • 24. Module developers: Think• what makes it applicable?• label, URI?• field?• custom on,off• example: no display,no page → nometadata tags
  • 25. Example: Profile2Profile2:• Entity typeProfile2 types:• Entity type• Bundle of Profile2• Exportable
  • 26. Profile2 torn apart• CRUD, Field API• Permissions, Access• Profile form, display• Admin UI, I18n• Views, CTools, Rules, Tokens,Features, Search APIYour job
  • 27. homework done,lets enjoy it.
  • 28. • NoSQL, Doctrine, PHPCR• Remote entities• Data integration
  • 29. Non-DB entities+Fields?
  • 30. Non-DB entitiesFieldstorageInfoPropertyInfoField APISchemaControllerInfo TokensRulesViews XYCRUDcontroller
  • 31. Non-DB entitiesCRUDcontrollerInfoPropertyInfoSchemaControllerInfo TokensRulesViews XY
  • 32. What does it buy us?• Classed CRUD API• CRUD Hooks• Tokens• Entity reference• Rules, Rules Links• Search API, Views integration, RestWS• …
  • 33. Drupalize your data!
  • 34. howto slide?
  • 35. Example...
  • 36. Google Picasa entitieshttp://drupal.org/sandbox/fago/1493180
  • 37. Room for improvements• EFQ Views• Ready-only mode• Generated display• Generated form
  • 38. Drupal 8
  • 39. Comments in Drupal 8$comment = entity_create(comment, array(  nid => $node­>nid,));$comment­>save();echo $comment­>id();$comment­>delete();entity_delete_multiple(comment, array(1, 2, 3));
  • 40. Comments in Drupal 8class CommentStorageController extends EntityDatabaseStorageController {…}class Comment extends Entity { …}class Entity implements EntityInterface { …}
  • 41. Questions?
  • 42. What didyouthink?LocatethissessionontheDrupalConDenver websitehttp://denver2012.drupal.org/programClickthe“TaketheSurvey” link.ThankYou!