You are here

function opening_hours_instance_prepare in Opening hours 7

Same name and namespace in other branches
  1. 6 opening_hours.module \opening_hours_instance_prepare()

Prepare an instance object loaded from the database for use with Backbone.

2 calls to opening_hours_instance_prepare()
opening_hours_instance_load in ./opening_hours.module
Load opening hours instance by id.
opening_hours_instance_load_multiple in ./opening_hours.module
Load opening hours instances by nid and date.

File

./opening_hours.module, line 357
Opening hours module.

Code

function opening_hours_instance_prepare($instance) {

  // Cast integers to the correct type.
  $instance->instance_id = (int) $instance->instance_id;
  $instance->nid = (int) $instance->nid;
  $instance->category_tid = !empty($instance->category_tid) ? (int) $instance->category_tid : NULL;
  $instance->original_instance_id = !empty($instance->original_instance_id) ? (int) $instance->original_instance_id : NULL;

  // Backbone expects the primary key to be named `id`. Let's not disappoint.
  $instance->id = $instance->instance_id;
  $instance->start_time = opening_hours_format_time($instance->start_time);
  $instance->end_time = opening_hours_format_time($instance->end_time);
  return $instance;
}