Created
March 21, 2012 23:30
-
-
Save chrisjlee/2154141 to your computer and use it in GitHub Desktop.
Drupalcon Denver 2012 - store your data with entities
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Drupal 7 | |
- example bundles | |
- node type | |
- vocabulary | |
What are entities | |
- drupal commerce entity / product display | |
- organic groups | |
- profile2 | |
What is the entity api used for? | |
- unified way to access data | |
- every type of grouping of data is an entity: | |
- profile | |
- product | |
- rules | |
- entity reference | |
- groups | |
- vote | |
- search | |
Interacting with entities | |
- in core there are api functions | |
- entity_get_info() | |
- entity_load() | |
Entity api module | |
- System takes care of language that it provides | |
- entity allows you to save values | |
property info | |
- enables you to validate data | |
Modules currently using entities | |
- entities views creates views output instead of sql query from views | |
creating an entity type | |
- create entity with hook_entitity_info() | |
- specify your controller class | |
- implement hook_schema | |
Example - Profile2 module | |
Entity exportable | |
- entity api allows exportable much like ctools | |
- export into code | |
- entities are automatically exportable just define different controller | |
Integrating exportable entity | |
- property info generated | |
- features takes in info and crud controller | |
Example module - Profile2 | |
- best makes use of most of entities features | |
- adding a new profile type | |
Entities allows different types of storage | |
- entities decouples and allows implementations of database storage | |
- nosql, doctrine, phpcr | |
- remote entities - a good way to integrate data remote server (e.g. contrib module, restWS) | |
how does it integrate with the field api | |
- feeds create and stored in local databaseb | |
- if you just want to implement remote data | |
no-db entities | |
- still allow for integration of contrib modules | |
Advantages | |
- entity cache allows entity storage and caching with memcache | |
Example - google picasa entitites | |
- http://drupal.org/sandbox/fago/1493180 | |
Room for improvement | |
- efq (entity field query) views | |
- read only mode | |
Drupal 8 entity api | |
- use with class entity object | |
- easily get entity type | |
- full storage controller in core | |
- comments moved to comments (see below) | |
comments example | |
- create entity | |
- then use all other methods: save, id, delete, delete multiple | |
- create and extend entityDatabaseStorageController | |
- every entity has to have EntityInterface | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment