You are here

function rb_views_create_view_representation in Rules Bonus Pack 7

Creates a new view representation array from a given view object.

This object is used to avoid having Rules copying the quite large view data object when doing different operations. And also to make a few view properties easier to access.

Parameters

$view: The full view object. (This is passed by reference to avoid copying the actual view just for creating a light-weight representation.)

Return value

An array with a few view properties relevant for Rules.

3 calls to rb_views_create_view_representation()
rb_views_views_post_render in ./rb_views.module
Implements of hook_views_post_render().
rb_views_views_pre_build in ./rb_views.module
Implements of hook_views_pre_execute().
rb_views_views_pre_render in ./rb_views.module
Implements of hook_views_pre_render().

File

./rb_views.module, line 68
Globally available functions for Rules' Views integration.

Code

function rb_views_create_view_representation(view $view) {
  $view_representation = new stdClass();

  // Set all simple non-writable properties.
  foreach (rb_views_get_nonwritable_representation_properties() as $representation_property => $view_property) {
    $view_representation->{$representation_property} = $view->{$view_property};
  }

  // Set all simple writable properties, too.
  foreach (rb_views_get_writable_representation_properties() as $representation_property => $view_property) {
    $view_representation->{$representation_property} = $view->{$view_property};
  }

  // Set the handler properties.
  foreach (rb_views_get_views_handlers() as $handler_type => $handler_label) {
    if (isset($view->{$handler_type})) {
      $view_representation->{$handler_type} = array_keys($view->{$handler_type});
    }
  }
  return $view_representation;
}