diff --git a/lib/Drupal/profile2/Profile.php b/lib/Drupal/profile2/Profile.php index 8d3a19b..449968a 100644 --- a/lib/Drupal/profile2/Profile.php +++ b/lib/Drupal/profile2/Profile.php @@ -56,8 +56,7 @@ class Profile extends Entity { */ public $changed; - - public function __construct($values = array()) { + public function __construct(array $values = array(), $entity_type) { if (isset($values['user'])) { $this->setUser($values['user']); unset($values['user']); diff --git a/lib/Drupal/profile2/ProfileType.php b/lib/Drupal/profile2/ProfileType.php index 41c7364..44acd39 100644 --- a/lib/Drupal/profile2/ProfileType.php +++ b/lib/Drupal/profile2/ProfileType.php @@ -29,10 +29,6 @@ class ProfileType extends Entity { public $label; public $weight = 0; - public function __construct($values = array()) { - parent::__construct($values, 'profile2_type'); - } - /** * Returns whether the profile type is locked, thus may not be deleted or renamed. * diff --git a/profile2.module b/profile2.module index b13f6b3..de49a0e 100644 --- a/profile2.module +++ b/profile2.module @@ -5,6 +5,9 @@ * Support for configurable user profiles. */ +use Drupal\profile2\Profile; +use Drupal\profile2\ProfileType; + /** * Implements hook_entity_info(). */ @@ -12,11 +15,9 @@ function profile2_entity_info() { $return = array( 'profile2' => array( 'label' => t('Profile'), - 'plural label' => t('Profiles'), - 'description' => t('Profile2 user profiles.'), - 'entity class' => 'Profile', - 'controller class' => 'EntityAPIController', + 'entity class' => 'Drupal\profile2\Profile', 'base table' => 'profile', + 'uri callback' => 'profile2_uri', 'fieldable' => TRUE, 'view modes' => array( 'account' => array( @@ -67,14 +68,12 @@ function profile2_entity_info() { $return['profile2_type'] = array( 'label' => t('Profile type'), - 'plural label' => t('Profile types'), - 'description' => t('Profiles types of Profile2 user profiles.'), - 'entity class' => 'ProfileType', - 'controller class' => 'EntityAPIControllerExportable', + 'entity class' => 'Drupal\profile2\ProfileType', 'base table' => 'profile_type', 'fieldable' => FALSE, 'bundle of' => 'profile2', 'exportable' => TRUE, + 'uri callback' => 'profile2_type_uri', 'entity keys' => array( 'id' => 'id', 'name' => 'type', @@ -93,6 +92,30 @@ function profile2_entity_info() { } /** + * Entity uri callback. + * + * @param Drupal\profile2\Profile $profile + * A Profile entity. + */ +function profile2_uri(Profile $profile) { + return array( + 'path' => 'admin/structure/profiles', + ); +} + +/** + * Entity uri callback. + * + * @param Drupal\profile2\ProfileType $profile_type + * A ProfileType entity. + */ +function profile2_type_uri(ProfileType $profile) { + return array( + 'path' => 'admin/structure/profiles/manage', + ); +} + +/** * Menu argument loader; Load a profile type by string. * * @param $type