Skip to content
Snippets Groups Projects
Commit 0aca47f4 authored by AdamPS's avatar AdamPS
Browse files

Minor comment changes, comment out all the speculative code for now

parent 283b4e07
Branches
Tags 8.x-1.0-alpha6
No related merge requests found
......@@ -16,6 +16,7 @@ use Drupal\node\Entity\NodeType;
*/
function manage_display_entity_type_build(array &$entity_types) {
$entity_types['node']->set('node_basefield_skip_preprocess', TRUE);
// Set user name as a label else it gets printed twice on the user page.
$keys = $entity_types['user']->get('entity_keys');
$keys['label'] = 'name';
......@@ -67,32 +68,32 @@ function manage_display_entity_base_field_info_alter(&$base_field_definitions, E
/**
* Implements hook_entity_view().
*/
function manage_display_entity_view(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display, $view_mode) {
if ($entity instanceof FieldableEntityInterface) {
$label_field = $entity->getEntityType()->getKey('label');
if (isset($build[$label_field])) {
//$build[$label_field]['#pre_render'][] = 'manage_display_title_pre_render';
// @todo If want to keep the field in the entity.
// Requires a change to EntityViewController::buildTitle
// $build['#built_page_title'] = TRUE;
// @todo If also want to hide title block.
// But loses metadata - better to prevent only title block.
// $build['#title'] = '';
//??$build['#title'] = new HtmlEscapedText($entity->label());
}
}
}
// function manage_display_entity_view(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display, $view_mode) {
// if ($entity instanceof FieldableEntityInterface) {
// $label_field = $entity->getEntityType()->getKey('label');
// if (isset($build[$label_field])) {
// $build[$label_field]['#pre_render'][] = 'manage_display_title_pre_render';
// @todo If want to keep the field in the entity.
// Requires a change to EntityViewController::buildTitle
// $build['#built_page_title'] = TRUE;
// @todo If also want to hide title block.
// But loses metadata - better to prevent only title block.
// $build['#title'] = '';
// ??$build['#title'] = new HtmlEscapedText($entity->label());
// }
// }
// }
/**
* Implements pre_render callback for entity.
*/
function manage_display_title_pre_render(array $build) {
if (isset($build['#is_page_title'])) {
// @todo Ensure markup is inline: swap formatter etc. Workaround for https://www.drupal.org/node/2941208.
// Is this too late, as it has already been built? Instead hook_entity_view_display_alter?
}
return $build;
}
// function manage_display_title_pre_render(array $build) {
// if (isset($build['#is_page_title'])) {
// // @todo Ensure markup is inline: swap formatter etc. Workaround for https://www.drupal.org/node/2941208.
// // Is this too late, as it has already been built? Instead hook_entity_view_display_alter?
// }
// return $build;
// }
/**
* Return information about the base fields that can be managed.
......@@ -163,6 +164,7 @@ function template_preprocess_submitted(&$variables) {
$variables['date']['#inline_field'] = TRUE;
$variables['date'] = \Drupal::service('renderer')->render($variables['date']);
// @todo This doesn't fully work with quickedit - when the field gets re-rendered after edit, the date is missing.
// Detect this case with a field preprocess hook and make a call to render the date.
// Drupal core doesn't fully work either: the user picture doesn't get re-rendered.
}
}
......@@ -171,6 +173,7 @@ function template_preprocess_submitted(&$variables) {
* Implements hook_preprocess_node().
*/
function manage_display_preprocess_node(&$variables) {
// @todo generalise this to any entity type. Read entity_keys to find the field names.
// Move date into the created element.
if (isset($variables['content']['uid']['#formatter']) && ($variables['content']['uid']['#formatter'] == 'submitted')) {
if (isset($variables['content']['created'])) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment