function ctools_entity_from_query_string_context

Return a new context based on an existing context.

1 string reference to 'ctools_entity_from_query_string_context'
entity_from_query_string.inc in plugins/relationships/entity_from_query_string.inc
Plugin to provide an relationship handler for entities from query string.

File

plugins/relationships/entity_from_query_string.inc, line 24

Code

function ctools_entity_from_query_string_context($context, $conf) {
    $entity_type = $conf['entity_type'];
    // If unset it wants a generic, unfilled context, which is just NULL.
    if (empty($context->data) || !isset($context->data) || !is_numeric($context->data)) {
        return ctools_context_create_empty('entity:' . $entity_type, NULL);
    }
    if (!empty($context->data) && is_numeric($context->data)) {
        // Load the entity from the query string value.
        $entity_id = $context->data;
        $entity = entity_load_single($entity_type, $entity_id);
        // Send it to ctools.
        return ctools_context_create('entity:' . $entity_type, $entity);
    }
}