Skip to content

Commit

Permalink
fixed programmatic profile creation via entity_property_values_create…
Browse files Browse the repository at this point in the history
…_entity() / Rules. Requires the latest Entity API.
  • Loading branch information
fago committed Feb 15, 2011
1 parent 501285d commit 2e314fb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion profile2.info.inc
Expand Up @@ -24,7 +24,7 @@ class Profile2MetadataController extends EntityDefaultMetadataController {
$properties['type'] = array(
'type' => 'profile2_type',
'getter callback' => 'entity_property_getter_method',
'setter callback' => 'entity_property_setter_method',
'setter callback' => 'entity_property_verbatim_set',
'setter permission' => 'administer profiles',
'required' => TRUE,
'description' => t('The profile type.'),
Expand Down
8 changes: 7 additions & 1 deletion profile2.module
Expand Up @@ -562,6 +562,9 @@ class Profile extends Entity {
$this->setUser($values['user']);
unset($values['user']);
}
if (isset($values['type']) && is_object($values['type'])) {
$values['type'] = $values['type']->type;
}
parent::__construct($values, 'profile2');
}

Expand All @@ -574,9 +577,12 @@ class Profile extends Entity {

/**
* Sets a new user owning this profile.
*
* @param $account
* The user account object or the user account id (uid).
*/
public function setUser($account) {
$this->uid = $account->uid;
$this->uid = is_object($account) ? $account->uid : $account;
}

/**
Expand Down

0 comments on commit 2e314fb

Please sign in to comment.