function flag_entity::applies_to_entity in Flag 7.3
Checks whether the flag applies for the current entity bundle.
Overrides flag_flag::applies_to_entity
File
- includes/
flag/ flag_entity.inc, line 124 - Contains the flag_entity class.
Class
- flag_entity
- Base entity flag handler.
Code
function applies_to_entity($entity) {
$entity_info = entity_get_info($this->entity_type);
// The following conditions are applied:
// - if the types array is empty, the flag applies to all bundles and thus
// to this entity.
// - if the entity has no bundles, the flag applies to the entity.
// - if the entity's bundle is in the list of types.
if (empty($this->types) || empty($entity_info['entity keys']['bundle']) || in_array($entity->{$entity_info['entity keys']['bundle']}, $this->types)) {
return TRUE;
}
return FALSE;
}