user = entity_metadata_wrapper('user', $userpoints_transaction->uid); $userpoints_transaction->entity = NULL; if (!empty($userpoints_transaction->entity_type) && !empty($userpoints_transaction->entity_id)) { // Make entity available as lazy loading wrapper $userpoints_transaction->entity = entity_metadata_wrapper($userpoints_transaction->entity_type, $userpoints_transaction->entity_id); } // Invoke rules event. rules_invoke_event($event, $userpoints_transaction); // Convert back to keep any changes to the properties. $params = (array) $userpoints_transaction; $params['uid'] = $userpoints_transaction->user->getIdentifier(); if ($userpoints_transaction->entity) { $params['entity_type'] = $userpoints_transaction->entity->type(); $params['entity_id'] = $userpoints_transaction->entity->getIdentifier(); } unset($params['entity']); } } catch (EntityMetadataWrapperException $e) { // The referenced entity does not exist. // @todo: Find a way to handle this more gracefully. } unset($params['entity']); unset($params['user']); }