Drupal 7 Entity API Matthew Radcliffe mradcliffe@kosada.com - - PowerPoint PPT Presentation

drupal 7 entity api
SMART_READER_LITE
LIVE PREVIEW

Drupal 7 Entity API Matthew Radcliffe mradcliffe@kosada.com - - PowerPoint PPT Presentation

Drupal 7 Entity API Matthew Radcliffe mradcliffe@kosada.com Wednesday, December 7, 2011 Some basic concepts Architecture, engineering, and building Drupal Core and Contrib modules Nodes Wednesday, December 7, 2011 Some basic


slide-1
SLIDE 1

Drupal 7 Entity API

Matthew Radcliffe mradcliffe@kosada.com

Wednesday, December 7, 2011

slide-2
SLIDE 2

Some basic concepts

  • Architecture, engineering, and building
  • Drupal
  • Core and Contrib modules
  • Nodes

Wednesday, December 7, 2011

slide-3
SLIDE 3

Some basic concepts

  • Drupal
  • Core and Contrib modules
  • Nodes
  • Content (a post with comments, maybe)
  • A collection of metadata (i.e. fields).
  • Contain revisions and access rules about

itself.

Wednesday, December 7, 2011

slide-4
SLIDE 4

All nodes all the time

  • Ancient History - Why Nodes?
  • Tired of all the work behind custom

schemas.

  • Drupal 5/6
  • Node access
  • Node forms
  • CCK (node fields)

Wednesday, December 7, 2011

slide-5
SLIDE 5

All nodes all the time

  • Ancient History - Why Nodes?
  • Tired of all the work behind custom

schemas.

  • Drupal 5/6
  • Node access
  • Node forms
  • CCK (node fields)

All nodes of any type are visible to users with “access content”. Node access and content access modules are necessary for fine- grained control on a node type and per node basis to hide various functionality you need hidden.

Wednesday, December 7, 2011

slide-6
SLIDE 6

All nodes all the time

  • Ancient History - Why Nodes?
  • Tired of all the work behind custom

schemas.

  • Drupal 5/6
  • Node access
  • Node forms
  • Everything is a node

You get everything. Hiding interfaces that aren’t necessary in your use case is a non-trivial amount of time.

Wednesday, December 7, 2011

slide-7
SLIDE 7

All nodes all the time

  • Ancient History - Why Nodes?
  • Tired of all the work behind custom

schemas.

  • Drupal 5/6
  • Node access
  • Node forms
  • Everything is a node

Nodes are robust pieces of content able to handle comments, revisions, fields, etc...

Wednesday, December 7, 2011

slide-8
SLIDE 8

All nodes all the time

  • Ancient History - Why Nodes?
  • Tired of all the work behind custom

schemas.

  • Drupal 5/6
  • Node access
  • Node forms
  • CCK (node fields)
  • Drupal 7: Entities!

Wednesday, December 7, 2011

slide-9
SLIDE 9

What is an entity?

  • An entity is an abstract object.
  • node, taxonomy, comment, user.
  • An entity type may do all of what a node did in

Drupal 5 and Drupal 6.

  • Revisions
  • Fields
  • Bundles
  • Access, URI, Theming,

View Modes

Wednesday, December 7, 2011

slide-10
SLIDE 10

What is an entity?

  • An entity is an abstract object.
  • node, taxonomy, comment, user.
  • An entity type may do all of what a node did in

Drupal 5 and Drupal 6.

  • Revisions
  • Fields
  • Bundles
  • Access, URI, Theming,

View Modes

Entity controller classes can have public methods such as load() and delete(). Additionally, most entities define global methods using their standard Drupal namespace (module name) to allow

  • ther modules to use something not-object based:

node_save(), node_load().

Wednesday, December 7, 2011

slide-11
SLIDE 11

What is an entity?

  • An entity is an abstract object.
  • node, taxonomy, comment, user.
  • An entity type may do all of what a node did in

Drupal 5 and Drupal 6.

  • Revisions
  • Fields
  • Bundles
  • Access, URI, Theming,

View Modes

You can define your own revision table for your custom entity, which you would need to save data in as well when you call your entity’s save method.

Wednesday, December 7, 2011

slide-12
SLIDE 12

What is an entity?

  • An entity is an abstract object.
  • node, taxonomy, comment, user.
  • An entity type may do all of what a node did in

Drupal 5 and Drupal 6.

  • Revisions
  • Fields
  • Bundles
  • Access, URI, Theming,

View Modes

The Drupal 5 and 6 concept of “CCK” or custom fields was pushed into Drupal core, which means that all entities may contain fields. Good bye, Content Profile. Hello, Profile2!

Wednesday, December 7, 2011

slide-13
SLIDE 13

What is an entity?

  • An entity is an abstract object.
  • node, taxonomy, comment, user.
  • An entity type may do all of what a node did in

Drupal 5 and Drupal 6.

  • Revisions
  • Fields
  • Bundles
  • Access, URI, Theming,

View Modes

Entities may have an associated “bundle” or type like the Drupal node type, but some entities may not want to allow types like the user entity.

Wednesday, December 7, 2011

slide-14
SLIDE 14

What is an entity?

  • An entity is an abstract object.
  • node, taxonomy, comment, user.
  • An entity type may do all of what a node did in

Drupal 5 and Drupal 6.

  • Revisions
  • Fields
  • Bundles
  • Access, URI, Theming,

View Modes

And yet it’s still a pain...

Wednesday, December 7, 2011

slide-15
SLIDE 15

Entity API

  • http://drupal.org/project/entity
  • EntityAPIController
  • EntityAPIControllerExportable
  • EntityTypeUIController
  • Entity Properties
  • Examples: Profile2, Organic Groups,

Commerce, Media

Wednesday, December 7, 2011

slide-16
SLIDE 16

Entity API

  • http://drupal.org/project/entity
  • EntityAPIController
  • EntityAPIControllerExportable
  • EntityTypeUIController
  • Entity Properties
  • Examples: Profile2, Organic Groups,

Commerce, Media

Better public methods

Wednesday, December 7, 2011

slide-17
SLIDE 17

Entity API

  • http://drupal.org/project/entity
  • EntityAPIController
  • EntityAPIControllerExportable
  • EntityTypeUIController
  • Entity Properties
  • Examples: Profile2, Organic Groups,

Commerce, Media

Exportable bundles (features!)

Wednesday, December 7, 2011

slide-18
SLIDE 18

Entity API

  • http://drupal.org/project/entity
  • EntityAPIController
  • EntityAPIControllerExportable
  • EntityTypeUIController
  • Entity Properties
  • Examples: Profile2, Organic Groups,

Commerce, Media

Clone, Delete admin ui for free

Wednesday, December 7, 2011

slide-19
SLIDE 19

Entity API

  • http://drupal.org/project/entity
  • EntityAPIController
  • EntityAPIControllerExportable
  • EntityTypeUIController
  • Entity Properties
  • Examples: Profile2, Organic Groups,

Commerce, Media

Clone, Delete admin ui for free

Wednesday, December 7, 2011

slide-20
SLIDE 20

Entity API

  • http://drupal.org/project/entity
  • EntityAPIController
  • EntityAPIControllerExportable
  • EntityTypeUIController
  • Entity Properties
  • Examples: Profile2, Organic Groups,

Commerce, Media

Clone, Delete admin ui for free

Wednesday, December 7, 2011

slide-21
SLIDE 21

Entity API

  • http://drupal.org/project/entity
  • EntityAPIController
  • EntityAPIControllerExportable
  • EntityTypeUIController
  • Entity Properties
  • Examples: Profile2, Organic Groups,

Commerce, Media

Views and Rules support for free

Wednesday, December 7, 2011

slide-22
SLIDE 22

Entity API

  • http://drupal.org/project/entity
  • EntityAPIController
  • EntityAPIControllerExportable
  • EntityTypeUIController
  • Entity Properties
  • Examples: Profile2, Organic Groups,

Commerce, Media

Views and Rules support for free

Wednesday, December 7, 2011

slide-23
SLIDE 23

Entity API

  • http://drupal.org/project/entity
  • EntityAPIController
  • EntityAPIControllerExportable
  • EntityTypeUIController
  • Entity Properties
  • Examples: Profile2, Organic Groups,

Commerce, Media

Views and Rules support for free

Wednesday, December 7, 2011

slide-24
SLIDE 24

Drupal Site Architecture

  • Entities will change how you architect,

engineer, and build Drupal web sites.

  • Architect - plan flexible and unique data

types.

  • Engineer - develop re-usable code.
  • Builder - utilize the tools that Entity API and

the developer provides to make quick changes to Views, Rules, Themes, etc...

Wednesday, December 7, 2011

slide-25
SLIDE 25

Questions / Example

  • Example - Show me the code!
  • Questions?
  • Views API
  • Drush
  • Rules
  • Field / Field Attach API

Wednesday, December 7, 2011