Commit 23c83da4 authored by catch's avatar catch

Issue #1857324 by Berdir, tim.plunkett: Use default theme name and entity key...

Issue #1857324 by Berdir, tim.plunkett: Use default theme name and entity key in $build for user entity.
parent af4765fa
......@@ -615,10 +615,10 @@ function rdf_preprocess_field(&$variables) {
}
/**
* Implements hook_preprocess_HOOK() for user-profile.tpl.php.
* Implements hook_preprocess_HOOK() for user.tpl.php.
*/
function rdf_preprocess_user_profile(&$variables) {
$account = $variables['elements']['#account'];
function rdf_preprocess_user(&$variables) {
$account = $variables['elements']['#user'];
$uri = $account->uri();
// Adds RDFa markup to the user profile page. Fields displayed in this page
......
......@@ -1859,11 +1859,11 @@ function hook_theme($existing, $type, $theme, $path) {
*
* For example:
* @code
* $theme_registry['user_profile'] = array(
* $theme_registry['user'] = array(
* 'variables' => array(
* 'account' => NULL,
* ),
* 'template' => 'core/modules/user/user-profile',
* 'template' => 'core/modules/user/user',
* 'file' => 'core/modules/user/user.pages.inc',
* 'type' => 'module',
* 'theme path' => 'core/modules/user',
......
......@@ -19,7 +19,6 @@
* label = @Translation("User"),
* module = "user",
* controller_class = "Drupal\user\UserStorageController",
* render_controller_class = "Drupal\user\UserRenderController",
* form_controller_class = {
* "profile" = "Drupal\user\ProfileFormController",
* "register" = "Drupal\user\RegisterFormController"
......
<?php
/**
* @file
* Definition of Drupal\user\UserRenderController.
*/
namespace Drupal\user;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityRenderController;
/**
* Render controller for users.
*/
class UserRenderController extends EntityRenderController {
/**
* Overrides Drupal\Core\Entity\EntityRenderController::getBuildDefaults().
*/
protected function getBuildDefaults(EntityInterface $entity, $view_mode, $langcode) {
$return = parent::getBuildDefaults($entity, $view_mode, $langcode);
// @todo rename "theme_user_profile" to "theme_user", 'account' to 'user'.
$return['#theme'] = 'user_profile';
$return['#account'] = $return['#user'];
return $return;
}
}
......@@ -2,19 +2,18 @@
/**
* @file
* Default theme implementation to present all user profile data.
* Default theme implementation to present all user data.
*
* This template is used when viewing a registered member's profile page,
* This template is used when viewing a registered user's page,
* e.g., example.com/user/123. 123 being the users ID.
*
* Use render($user_profile) to print all profile items, or print a subset
* Use render($content) to print all content, or print a subset
* such as render($content['field_example']).
* If the item is a category, it will contain all its profile items. By default,
* $user_profile['summary'] is provided, which contains data on the user's
* history. Other data can be included by modules.
* By default, $user_profile['summary'] is provided, which contains data on the
* user's history. Other data can be included by modules.
*
* Available variables:
* - $user_profile: An array of profile items. Use render() to print them.
* - $content: An array of content items. Use render() to print them.
* - Field variables: for each field instance attached to the user a
* corresponding variable is defined; e.g., $account->field_example has a
* variable $field_example defined. When needing to access a field's raw
......@@ -23,11 +22,11 @@
* field language, e.g. $account->field_example['en'], thus overriding any
* language negotiation rule that was previously applied.
*
* @see template_preprocess_user_profile()
* @see template_preprocess_user()
*
* @ingroup themeable
*/
?>
<article class="profile"<?php print $attributes; ?>>
<?php print render($user_profile); ?>
<?php print render($content); ?>
</article>
......@@ -370,7 +370,7 @@ function hook_user_view($account, $view_mode, $langcode) {
* If the module wishes to act on the rendered HTML of the user rather than the
* structured content array, it may use this hook to add a #post_render callback.
* Alternatively, it could also implement hook_preprocess_HOOK() for
* user-profile.tpl.php. See drupal_render() and theme() documentation
* user.tpl.php. See drupal_render() and theme() documentation
* respectively for details.
*
* @param $build
......
......@@ -85,9 +85,9 @@ function user_help($path, $arg) {
*/
function user_theme() {
return array(
'user_profile' => array(
'user' => array(
'render element' => 'elements',
'template' => 'user-profile',
'template' => 'user',
'file' => 'user.pages.inc',
),
'user_admin_permissions' => array(
......@@ -1848,10 +1848,10 @@ function user_view_page($account) {
*
* - $page['content']['member_for']:
* Contains the default "Member for" profile data for a user.
* - $page['content']['#account']:
* - $page['content']['#user']:
* The user account of the profile being viewed.
*
* To theme user profiles, copy modules/user/user-profile.tpl.php
* To theme user profiles, copy modules/user/user.tpl.php
* to your theme directory, and edit it as instructed in that file's comments.
*
* @param $account
......
......@@ -184,19 +184,19 @@ function user_logout() {
}
/**
* Process variables for user-profile.tpl.php.
* Process variables for user.tpl.php.
*
* The $variables array contains the following arguments:
* - $account
*
* @see user-profile.tpl.php
* @see user.tpl.php
*/
function template_preprocess_user_profile(&$variables) {
$account = $variables['elements']['#account'];
function template_preprocess_user(&$variables) {
$account = $variables['elements']['#user'];
// Helpful $user_profile variable for templates.
// Helpful $content variable for templates.
foreach (element_children($variables['elements']) as $key) {
$variables['user_profile'][$key] = $variables['elements'][$key];
$variables['content'][$key] = $variables['elements'][$key];
}
// Preprocess fields.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment