Check your version

This video covers a topic in Drupal 7 which may or may not be the version you're using. We're keeping this tutorial online as a courtesy to users of Drupal 7, but we consider it archived.

Alternate resources: 

Introduction to Entity Classes

Video loading...

Join Drupalize.Me to watch this video

Join today and gain instant access to our entire video library.

Log in Sign up
  • 0:06
    [Blake Hall] Since the Entity API is object oriented, we'll have to get familiar with a few basic classes in order to understand it.
  • 0:12
    In this lesson we'll take a look at the base entity class that provides a few properties about about entity.
  • 0:18
    We'll also take a look at the controller, which provides some support for creating new entities,
  • 0:23
    reading them from the database, updated them, deleting them, tracking and revisions, and similar operations.
  • 0:30
    We'll also take a look at what's provided by the Entity API module and the default classes,
  • 0:35
    so you know where the behavior you need to override is when it comes time to implement that in your custom entity.
  • 0:42
    Now that we have our basic implementation of hook_entity_info and our custom entity is loading correctly,
  • 0:47
    let's take a little more detailed look at what Entity API is providing us,
  • 0:52
    especially the entity contrib module.
  • 0:54
    In Core, the only entity helper function that's provided is entity_load.

Introduction to Entity Classes

Loading...

This lesson introduces students to Entity classes and illustrates what each of the main Entity classes does, followed by a more in depth look at the CRUD operations provided by the base entity class, and finally demonstrates overriding the default Entity class with our own custom Entity object to define a defaultUrl() for our entities and a new implementation of hook_menu where we can view an entity.

Note: At the end of the this video code is added to hook_entity_info() that references a VideoEntityUIController class, however, the definition of that class is in our sample code, but was not shown being added here. And it is necessary to follow along with the videos. If you're following along you'll want to add the following code to the bottom of your videoasset.module file. If you're curious about what it does it's explained in the last part of this video.


/**
* Our custom controller for the admin ui.
*/
class VideoEntityUIController extends EntityDefaultUIController {}

Downloads: 
Log in or sign up to download companion files.
Additional resources: