function drafty_entity_is_new in Drafty 7
Helper function to determine if an entity is new or not.
The $is_new property cannot be relied on, as not all entities use this. E.g. files.
Parameters
mixed $entity: The entity to check.
string $entity_type: The entity type being passed in.
Return value
bool
2 calls to drafty_entity_is_new()
- drafty_enforce_field_attach_submit in modules/
drafty_enforce/ drafty_enforce.module - Implements hook_field_attach_submit().
- drafty_entity_presave in ./
drafty.module - Implements hook_entity_presave().
File
- ./
drafty.module, line 191 - Hook implementations and API functions for the Drafty module.
Code
function drafty_entity_is_new($entity, $entity_type) {
// Use is_new if it's available, since it's not impossible for new entities to
// have an ID set.
if (!empty($entity->is_new)) {
return TRUE;
}
list($id) = entity_extract_ids($entity_type, $entity);
return empty($id);
}