diff --git a/includes/entity.wrapper.inc b/includes/entity.wrapper.inc index 70c14c1..07945bb 100644 --- a/includes/entity.wrapper.inc +++ b/includes/entity.wrapper.inc @@ -114,6 +114,27 @@ abstract class EntityMetadataWrapper { return isset($this->data) || (isset($this->info['parent']) && $this->info['parent']->dataAvailable()); } + /** + * Determines if a given property exists and has a value. + * + * @param $name + * The name of the property whose value might be empty. + * + * @return bool + * TRUE if 'name' is not a property, or if it's empty, otherwise FALSE. + * + * @see EntityMetadataWrapper::dataAvailable() + */ + public function isEmpty($name) { + try { + $value = $this->$name->value(); + } + catch (EntityMetadataWrapperException $e) { + $value = FALSE; + } + return empty($value); + } + /** * Set a new data value. */