public static function SocialContent::getObjectFromInstance in Social Content 7.2
Utility static function to get a global object from instance id.
Parameters
array $classes: The classes which the instance could belong to.
int $instance_id: The id of the instance to which to create an object for
Return value
array Instances.
1 call to SocialContent::getObjectFromInstance()
- social_content_load in ./
social_content.module  - Implements hook_load().
 
File
- ./
social_content.class.inc, line 967  - Social Content class.
 
Class
- SocialContent
 - TODO: Table names should be a property for ease of change Separate this class into smaller classes.
 
Code
public static function getObjectFromInstance($classes, $instance_id) {
  $global = db_select('social_content_instances', 'social_content_instances')
    ->fields('social_content_instances', array(
    'global',
  ))
    ->condition('id', $instance_id)
    ->execute()
    ->fetchField();
  if ($global) {
    return new $classes[$global](array(
      'id' => $instance_id,
    ));
  }
  else {
    return NULL;
  }
}