function feeds_get_feeds_item_property in Feeds 7.2
Entity API getter callback for getting a feeds_item property on an entity.
Parameters
object $entity: An entity object.
array $options: Options are ignored, but it is a param that is given by the Entiy API.
string $name: The name of the property to get.
string $entity_type: The entity's type.
Return value
mixed The feeds_item property.
1 string reference to 'feeds_get_feeds_item_property'
- feeds_entity_property_info_alter in ./
feeds.module - Implements hook_entity_property_info_alter().
File
- ./
feeds.module, line 1553 - Feeds - basic API functions and hook implementations.
Code
function feeds_get_feeds_item_property($entity, array $options, $name, $entity_type) {
// Map property name to actual feeds_item column.
$property_map = array(
'feed_node' => 'feed_nid',
'feed_nid' => 'feed_nid',
'feeds_item_guid' => 'guid',
'feeds_item_url' => 'url',
);
$property_name = $property_map[$name];
// First check if the entity has already the feeds item loaded with the
// requested property and return its value if it does.
if (isset($entity->feeds_item->{$property_name})) {
return $entity->feeds_item->{$property_name};
}
// No feed item. Try to load the feed item if the entity has an ID.
list($entity_id) = entity_extract_ids($entity_type, $entity);
if ($entity_id) {
$feeds_item = feeds_item_info_load($entity_type, $entity_id);
// Check again for the requested property and return its value if it exists.
if (isset($feeds_item->{$property_name})) {
return $feeds_item->{$property_name};
}
}
}