1 contextual_links_example.module contextual_links_example_object_load($id)

Menu loader callback for the object defined by this module.

Parameters

int $id: The ID of the object to load.

Return value

object|FALSE: A fully loaded object, or FALSE if the object does not exist.

Related topics

File

modules/examples/contextual_links_example/contextual_links_example.module, line 155
Hooks implementations for the Contextual Links Example module.

Code

function contextual_links_example_object_load($id) {
  // In a real use case, this function might load an object from the database.
  // For the sake of this example, we just define a stub object with a basic
  // title and content for any numeric ID that is passed in.
  if (is_numeric($id)) {
    $object = new stdClass();
    $object->id = $id;
    $object->title = t('Title for example object @id', array('@id' => $id));
    $object->content = t('This is the content of example object @id.', array('@id' => $id));
    return $object;
  }
  else {
    return FALSE;
  }
}