SlideShare a Scribd company logo
Drupalize your data use entities
Codinganddevelopment
DrupalizeYour Data:
UseEntities!
PresentedbyWolfgangZiegler // fago
Wolfgang Ziegler // fago
• from Vienna, Austria
• studied at the TU Vienna
• Drupal since 2005.
wolfgangziegler.net
twitter.com/the_real_fago
gplus.to/fago
Outline
• Introduction
• Interact with entities
• Providing a new entity type
• Expose non-DB entities
• Outlook
Drupal 7:
Fields everywhere!
Bundles
Entity type ↔ Node
Bundle ↔ Node type
Entity type ↔ Taxonomy term
Bundle ↔ Vocabulary
Entity type ↔ User
Bundle ↔ {}
Which entities are there?
• Core
• Modules:
• Drupal commerce
• Organic groups
• Profile2
• Heartbeat and Message
• File entity
Node modules
Entity modules
Entity API - What for?
Unified way to access data.
User
Node
Comment
Profile
Product
Search
Vote
Groups
Entity
reference
Rules
Entity
Interacting with entities
Entity API module
Assists you with
• interacting with entities
• and providing new entity types
Entity API Functions
Drupal Core
Entity API module
entity_save()
entity_load()
entity_get_info()
entity_metadata_wrapper()
entity_view()
entity_access()
entity_create()
entity_id()
entity_get_property_info()
entity_delete()
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');
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');
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',
);
Property info?
• Unified access to entity data
• Validation
• Access information
How modules use it
• Drupal Commerce, VBO, OG
• Rules, Search API
• Microdata
• RestWS, WSClient
• Entity tokens
• Entity Views
Providing an entity type
• Implement hook_entity_info()
• Specify your 'controller class'
• Implement hook_schema()
Entity API module
$profile = entity_create('profile2', array(
  'type' => 'main',
  'user'=> $account,
));
$profile­>save();
$profile­>delete();
entity_delete_multiple('profile2', array(1, 2, 3));
Integrating your entity type
TokensViews Rules
Property
Info
Field API
Schema
CRUD
controller
Info
XY
Exportable entities
similar to CTools exportables, but...
• unified CRUD interface
• synced to the DB
• regular CRUD hooks
• Views, Tokens, Features, i18n, ...
Integrating your exportable entity
Schema
CRUD
controller
Info
Tokens
Property
Info
Views i18nFeatures
Admin
UI
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?
Module developers: Think
• what makes it applicable?
• label, URI?
• field?
• custom on,off
• example: no display,no page → no
metadata tags
Drupalize your data use entities
Example: Profile2
Profile2:
• Entity type
Profile2 types:
• Entity type
• Bundle of Profile2
• Exportable
Profile2 torn apart
• CRUD, Field API
• Permissions, Access
• Profile form, display
• Admin UI, I18n
• Views, CTools, Rules, Tokens,
Features, Search API
Your job
homework done,
let's enjoy it.
• NoSQL, Doctrine, PHPCR
• Remote entities
• Data integration
Non-DB entities
+
Fields?
Non-DB entities
Field
storage
Info
Property
Info
Field API
SchemaControllerInfo TokensRulesViews XY
CRUD
controller
Non-DB entities
CRUD
controller
Info
Property
Info
SchemaControllerInfo TokensRulesViews XY
What does it buy us?
• Classed CRUD API
• CRUD Hooks
• Tokens
• Entity reference
• Rules, Rules Links
• Search API, Views integration, RestWS
• …
Drupalize your data!
howto slide?
Example...
Google Picasa entities
http://drupal.org/sandbox/fago/1493180
Drupalize your data use entities
Drupalize your data use entities
Room for improvements
• EFQ Views
• Ready-only mode
• Generated display
• Generated form
Drupal 8
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));
Comments in Drupal 8
class CommentStorageController extends 
EntityDatabaseStorageController {
…
}
class Comment extends Entity {
 …
}
class Entity implements EntityInterface {
 …
}
Questions?
What didyouthink?
Locatethissessiononthe
DrupalConDenver website
http://denver2012.drupal.org/program
Clickthe“TaketheSurvey” link.
ThankYou!

More Related Content

PDF
Tutorial dekho queries
PDF
Search api d8
PDF
Drupal Commerce 2014
PDF
Concurrency: Rubies, plural
PDF
Drupal Commerce contributed modules overview
PPTX
Drupal 7 entities & TextbookMadness.com
PDF
Entity api
PDF
Drupal 7 Entity & Entity API
Tutorial dekho queries
Search api d8
Drupal Commerce 2014
Concurrency: Rubies, plural
Drupal Commerce contributed modules overview
Drupal 7 entities & TextbookMadness.com
Entity api
Drupal 7 Entity & Entity API

Similar to Drupalize your data use entities (20)

PDF
Understanding the Entity API Module
PDF
ознакомления с модулем Entity api
PDF
Entities 101: Understanding Data Structures in Drupal
PDF
Entities, Bundles, and Fields: You need to understand this!
PDF
Fields, entities, lists, oh my!
PDF
Entities in drupal 7
PDF
What's New in Drupal 8: Entity Field API
PDF
Entities in Drupal 8 - Drupal Tech Talk - Bart Feenstra
PDF
Entity API in Drupal 8 (Drupal Tech Talk October 2014)
PPT
Synapse india reviews on drupal 7 entities (stanford)
ODP
Создание собственных сущностей с использованием Entity API
PDF
Drupal 8: Entities
ODP
DrupalCafe Kyiv EntityAPI
ODP
Drupal 7 field API
ODP
Drupal 8 entities & felds
PDF
How to Make Entities and Influence Drupal - Emerging Patterns from Drupal Con...
PDF
Your Entity, Your Code
PDF
Your Entity, Your Code
PDF
Entity api and field api 2
KEY
Drupalcon cph
Understanding the Entity API Module
ознакомления с модулем Entity api
Entities 101: Understanding Data Structures in Drupal
Entities, Bundles, and Fields: You need to understand this!
Fields, entities, lists, oh my!
Entities in drupal 7
What's New in Drupal 8: Entity Field API
Entities in Drupal 8 - Drupal Tech Talk - Bart Feenstra
Entity API in Drupal 8 (Drupal Tech Talk October 2014)
Synapse india reviews on drupal 7 entities (stanford)
Создание собственных сущностей с использованием Entity API
Drupal 8: Entities
DrupalCafe Kyiv EntityAPI
Drupal 7 field API
Drupal 8 entities & felds
How to Make Entities and Influence Drupal - Emerging Patterns from Drupal Con...
Your Entity, Your Code
Your Entity, Your Code
Entity api and field api 2
Drupalcon cph
Ad

More from 均民 戴 (15)

PDF
CKmates - AWS 三大 AI 解決方案:應用影像辨識、聊天機器人與語音轉換以及 Serverless 應用
PDF
CKmates - AWS 雲端運算 基礎服務介紹
PDF
COSCUP 2016 Workshop: 用 Docker 架設班級 git-it 練習環境
PDF
寫程式?那些老師沒教的事 (Git 部分節錄)
PDF
在 DigitalOcean 架設 Gitlab
PDF
Bootstrap個人網站 20141117
PDF
Bootstrap個人網站 20141027
PDF
資訊創意課程 - Create A Personal Website 1
PDF
MIS MySQL 入門
PDF
SITCON 2014 - Regular Expression Introduce
PDF
興大資訊社 CPE 訓練宣傳
PDF
20130706閃電秀
PDF
植基於個人本體論的新聞推薦系統
PDF
JSON 和 Android 的火花
PDF
寫程式?那些老師沒教的事
CKmates - AWS 三大 AI 解決方案:應用影像辨識、聊天機器人與語音轉換以及 Serverless 應用
CKmates - AWS 雲端運算 基礎服務介紹
COSCUP 2016 Workshop: 用 Docker 架設班級 git-it 練習環境
寫程式?那些老師沒教的事 (Git 部分節錄)
在 DigitalOcean 架設 Gitlab
Bootstrap個人網站 20141117
Bootstrap個人網站 20141027
資訊創意課程 - Create A Personal Website 1
MIS MySQL 入門
SITCON 2014 - Regular Expression Introduce
興大資訊社 CPE 訓練宣傳
20130706閃電秀
植基於個人本體論的新聞推薦系統
JSON 和 Android 的火花
寫程式?那些老師沒教的事
Ad

Recently uploaded (20)

PDF
Empathic Computing: Creating Shared Understanding
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Transforming Manufacturing operations through Intelligent Integrations
PDF
madgavkar20181017ppt McKinsey Presentation.pdf
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PPTX
Big Data Technologies - Introduction.pptx
PDF
cuic standard and advanced reporting.pdf
PDF
Modernizing your data center with Dell and AMD
PPT
Teaching material agriculture food technology
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
GamePlan Trading System Review: Professional Trader's Honest Take
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Sensors and Actuators in IoT Systems using pdf
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPTX
breach-and-attack-simulation-cybersecurity-india-chennai-defenderrabbit-2025....
Empathic Computing: Creating Shared Understanding
Chapter 3 Spatial Domain Image Processing.pdf
20250228 LYD VKU AI Blended-Learning.pptx
Transforming Manufacturing operations through Intelligent Integrations
madgavkar20181017ppt McKinsey Presentation.pdf
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Big Data Technologies - Introduction.pptx
cuic standard and advanced reporting.pdf
Modernizing your data center with Dell and AMD
Teaching material agriculture food technology
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
“AI and Expert System Decision Support & Business Intelligence Systems”
GamePlan Trading System Review: Professional Trader's Honest Take
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Sensors and Actuators in IoT Systems using pdf
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Advanced methodologies resolving dimensionality complications for autism neur...
breach-and-attack-simulation-cybersecurity-india-chennai-defenderrabbit-2025....

Drupalize your data use entities