Loading presentation...

Present Remotely

Send the link below via email or IM

Copy

Present to your audience

Start remote presentation

  • Invited audience members will follow you as you navigate and present
  • People invited to a presentation do not need a Prezi account
  • This link expires 10 minutes after you close the presentation
  • A maximum of 30 users can follow your presentation
  • Learn more about this feature in our knowledge base article

Do you really want to delete this prezi?

Neither you, nor the coeditors you shared it with will be able to recover it again.

DeleteCancel

Make your likes visible on Facebook?

Connect your Facebook account to Prezi and let your likes appear on your timeline.
You can change this under Settings & Account at any time.

No, thanks

Drupal and Entity Construction Kit

No description
by

Dallas Despain

on 13 January 2015

Comments (0)

Please log in to add your comment.

Report abuse

Transcript of Drupal and Entity Construction Kit

Metadata Wrappers
A tool provided by Drupal core to facilitate querying for entities based on fields
Drupal and Custom Data
Drive
Free Views Integration
reporting
views joy
Free CRUD Admin UI
make the content editor deal with all that content entry junk.
Free caching (via entities)
Rules Integration
Extensible (via fields) possibly by client.
Core
Entity Construction Kit (eck)

Demo the UI now.
Example Applications
Statistics
Achievements
Plan Pdf's
Affiliates
Stories
EntityFieldQueries
Foundation
What is an entity anyway?
Define entity: a thing with distinct and independent existence.
Some Drupal Vocabulary
Entity Types
Properties
Bundles
Fields
Entities
A OOP metaphor (not strictly true)
Base class
Members
Extended class
Members
Instances
Entity type
Properties
Bundle
Fields
Entities
Blame https://drupal.org/node/1261744
Built-in Examples
Node
Taxonomy
User
Comment
Built-in entity types
Node
User
Taxonomy
Comment
Built-in properties
node.nid, node.title
user.uid, user.name
taxonomy.tid
comment.cid
Built-in bundles
Nodes call bundles content types (article, basic page)
Taxonomies call bundles vocabularies (tags)
Users don't allow you to add more bundles (I assume the built in one is called user or account)
Comments?
Fields on built-in bundles
Nodes have content type fields
admin/structure/types/manage/
article
/fields
Taxonomies have vocabulary fields
admin/structure/taxonomy/
tags
/fields
Users have account fields
admin/config/people/accounts/fields
Comments have comment fields
admin/structure/types/manage/
article
/comment/fields
Built-in entities
Node - Nodes
Taxonomy - Terms
User - Users
Comment - Comments
Almost Everything in Drupal is an Entity
Mommy make me an entity!
hook_entity_info
examples module entity
entity api module
model
Why is everybody so happy?
Pros
I like it better for data modeling
it's quick and easy
easy for content editors to use
Cons
I assume there must be some performance overhead involved.
for your super duper custom module you might want to roll your own entity the hard way
Entity Construction Kit (eck)
Funkiness
Admin interface lacks bulk crud operations features (fix with views or patch?)
Behaviors are a bit wonky
Drupal Custom Data Options
Custom Table
implement hook_schema
design your tables
not fieldable
extra work to get views integration
custom code/queries to perform crud on this table
custom caching logic required
extra work to add an admin ui
Custom Entity
hook_schema
design tables
fieldable
need entity api to get views integration for free
need entity api to make crud easier
Caching provided by core
extra work to get admin ui
Nodes!
I know! Everything is a node!
Entities huh?
Just make your custom tables into entities and you can have:
free caching
free fieldable
free views integration
Custom Tables!
hook_schema
you write all this code to get data into and out of your tables
custom caching code
We want reporting/export
No Views (without extra work)
We want a crud ui (extra work)
We want more columns!
No Fields?
So you want custom data - a progression
My entity journey
Examples Module
comments rave about entity api
hook_entity_info + hook_shema
dang... I have to write my own pager
dang... no views integration
635 lines of code and what have I got?

Entity API
d7 entities were a late addition
https://drupal.org/developing/api/entity
they only provided entity_load
enter entity api (by fago of rules fame) which fills out core functionality
buys me the views integration and CUD
check out the examples!

Model
drush dl model - 9 files + views directory - 5 files
~1832 loc and I have one entity with everything I want
what if I want more than one?
what if I want to rename it?
copy/paste find/replace hell

Are you discouraged yet?
The crud UI for example_entity
Provided by entity api module
make life easy
Which would you rather write?
EFQ Options
->entityCondition($name, $value, $operator = NULL)
->propertyCondition($name, $value, $operator = NULL)
->fieldCondition($field, $column = NULL, $value = NULL, $operator = NULL, $delta_group = NULL, $language_group = NULL)
->propertyOrderBy($column, $direction = 'ASC')
->fieldOrderBy($field, $column, $direction = 'ASC')
->range($start = NULL, $length = NULL)
->count()
->addMetaData($key, $object)

Creating a new entity
More info
read this:
https://drupal.org/node/1021556
Full transcript