diff --git a/lib/Drupal/profile2/Profile.php b/lib/Drupal/profile2/Profile.php index 4467510..2fc8a02 100644 --- a/lib/Drupal/profile2/Profile.php +++ b/lib/Drupal/profile2/Profile.php @@ -144,32 +144,6 @@ class Profile extends Entity { return $this->label; } - public function buildContent($view_mode = 'full', $langcode = NULL) { - $content = array(); - - // Assume newly create objects are still empty. - if (!empty($this->is_new)) { - $content['empty']['#markup'] = '' . t('There is no profile data yet.') . ''; - } - - if (!isset($langcode)) { - $langcode = language(LANGUAGE_TYPE_CONTENT)->langcode; - } - - // Allow modules to change the view mode. - $context = array('langcode' => $langcode); - drupal_alter('entity_view_mode', $view_mode, $this, $context); - - // Build fields content. - // In case of a multiple view, node_view_multiple() already ran the - // 'prepare_view' step. An internal flag prevents the operation from running - // twice. - field_attach_prepare_view('profile2', array($this->id() => $this), $view_mode, $langcode); - $content += field_attach_view('profile2', $this, $view_mode, $langcode); - - return $content; - } - public function save() { // Care about setting created and changed values. But do not automatically // set a created values for already existing profiles. diff --git a/profile2.module b/profile2.module index 2e6e06c..105cd8f 100644 --- a/profile2.module +++ b/profile2.module @@ -23,6 +23,7 @@ function profile2_entity_info() { 'form controller class' => array( 'default' => 'Drupal\profile2\ProfileFormController', ), + 'render controller class' => 'Drupal\Core\Entity\EntityRenderController', 'view modes' => array( 'account' => array( 'label' => t('User account'), @@ -446,7 +447,8 @@ function profile2_user_view($account, $view_mode, $langcode) { '#title' => $profile->label, '#prefix' => '', ); - $account->content['profile_' . $type]['view'] = $profile->buildContent('account'); + entity_render_controller('profile2')->buildContent(array($profile), 'account'); + $account->content['profile_' . $type]['view'] = $profile->content; } } } @@ -708,7 +710,7 @@ function profile2_theme() { * * @see Profile::view() */ -function profile2_view($profile, $view_mode = 'full', $langcode = NULL, $page = NULL) { +function profile2_view($profile, $view_mode = 'account', $langcode = NULL, $page = NULL) { return $profile->view($view_mode, $langcode, $page); }