SlideShare una empresa de Scribd logo
1 de 46
Descargar para leer sin conexión
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
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
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!

Más contenido relacionado

Similar a Drupalize your data use entities

Entities, Bundles, and Fields: You need to understand this!
Entities, Bundles, and Fields: You need to understand this!Entities, Bundles, and Fields: You need to understand this!
Entities, Bundles, and Fields: You need to understand this!
tedbow
 
Semantically Enabled Personal Information Management with Cluug.com
Semantically Enabled Personal Information Management with Cluug.comSemantically Enabled Personal Information Management with Cluug.com
Semantically Enabled Personal Information Management with Cluug.com
Bernhard Schandl
 

Similar a Drupalize your data use entities (20)

Drupal as a Programmer-Friendly CMS at ConFoo
Drupal as a Programmer-Friendly CMS at ConFooDrupal as a Programmer-Friendly CMS at ConFoo
Drupal as a Programmer-Friendly CMS at ConFoo
 
Entities, Bundles, and Fields: You need to understand this!
Entities, Bundles, and Fields: You need to understand this!Entities, Bundles, and Fields: You need to understand this!
Entities, Bundles, and Fields: You need to understand this!
 
DACS - The Internet of Things (IoT)
DACS - The Internet of Things (IoT)DACS - The Internet of Things (IoT)
DACS - The Internet of Things (IoT)
 
FIWARE IoT Introduction 1
FIWARE IoT Introduction 1FIWARE IoT Introduction 1
FIWARE IoT Introduction 1
 
Solid OOPS
Solid OOPSSolid OOPS
Solid OOPS
 
OOP, API Design and MVP
OOP, API Design and MVPOOP, API Design and MVP
OOP, API Design and MVP
 
Synapse india reviews on drupal 7 entities (stanford)
Synapse india reviews on drupal 7 entities (stanford)Synapse india reviews on drupal 7 entities (stanford)
Synapse india reviews on drupal 7 entities (stanford)
 
Killing Shark-Riding Dinosaurs with ORM
Killing Shark-Riding Dinosaurs with ORMKilling Shark-Riding Dinosaurs with ORM
Killing Shark-Riding Dinosaurs with ORM
 
DataSploit - Tool Demo at Null Bangalore - March Meet.
DataSploit - Tool Demo at Null Bangalore - March Meet. DataSploit - Tool Demo at Null Bangalore - March Meet.
DataSploit - Tool Demo at Null Bangalore - March Meet.
 
D7 Entities
D7 EntitiesD7 Entities
D7 Entities
 
Lightning connect london'15
Lightning connect london'15Lightning connect london'15
Lightning connect london'15
 
Integrating the Solr search engine
Integrating the Solr search engineIntegrating the Solr search engine
Integrating the Solr search engine
 
Drupal In 1 Hour
Drupal In 1 HourDrupal In 1 Hour
Drupal In 1 Hour
 
Entities 101: Understanding Data Structures in Drupal
Entities 101: Understanding Data Structures in DrupalEntities 101: Understanding Data Structures in Drupal
Entities 101: Understanding Data Structures in Drupal
 
Basic PowerShell Toolmaking - Spiceworld 2016 session
Basic PowerShell Toolmaking - Spiceworld 2016 sessionBasic PowerShell Toolmaking - Spiceworld 2016 session
Basic PowerShell Toolmaking - Spiceworld 2016 session
 
Semantically Enabled Personal Information Management with Cluug.com
Semantically Enabled Personal Information Management with Cluug.comSemantically Enabled Personal Information Management with Cluug.com
Semantically Enabled Personal Information Management with Cluug.com
 
Extending Zend_Tool
Extending Zend_ToolExtending Zend_Tool
Extending Zend_Tool
 
Drupal 8 Basic Training - DrupalEurope 2018 - Maarten De Block
Drupal 8 Basic Training - DrupalEurope 2018 - Maarten De BlockDrupal 8 Basic Training - DrupalEurope 2018 - Maarten De Block
Drupal 8 Basic Training - DrupalEurope 2018 - Maarten De Block
 
Searchlight + Horizon - Mitaka march 2016
Searchlight  + Horizon - Mitaka march 2016Searchlight  + Horizon - Mitaka march 2016
Searchlight + Horizon - Mitaka march 2016
 
The Hacking Game - Think Like a Hacker Meetup 12072023.pptx
The Hacking Game - Think Like a Hacker Meetup 12072023.pptxThe Hacking Game - Think Like a Hacker Meetup 12072023.pptx
The Hacking Game - Think Like a Hacker Meetup 12072023.pptx
 

Más de 均民 戴

寫程式?那些老師沒教的事 (Git 部分節錄)
寫程式?那些老師沒教的事 (Git 部分節錄)寫程式?那些老師沒教的事 (Git 部分節錄)
寫程式?那些老師沒教的事 (Git 部分節錄)
均民 戴
 
興大資訊社 CPE 訓練宣傳
興大資訊社 CPE 訓練宣傳興大資訊社 CPE 訓練宣傳
興大資訊社 CPE 訓練宣傳
均民 戴
 

Más de 均民 戴 (16)

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

Último

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 

Último (20)

2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 

Drupalize your data use entities