Skip to content
Snippets Groups Projects
Commit a35bbafc authored by Angie Byron's avatar Angie Byron
Browse files

Issue #3059387 by b_sharpe, AaronChristian: Taxonomy Terms cannot be rendered...

Issue #3059387 by b_sharpe, AaronChristian: Taxonomy Terms cannot be rendered when in preview: EntityMalformedException
parent d185342b
Branches
Tags
6 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!1012Issue #3226887: Hreflang on non-canonical content pages,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10,!596Issue #3046532: deleting an entity reference field, used in a contextual view, makes the whole site unrecoverable,!496Issue #2463967: Use .user.ini file for PHP settings,!144Issue #2666286: Clean up menu_ui to conform to Drupal coding standards
...@@ -567,7 +567,7 @@ function rdf_preprocess_taxonomy_term(&$variables) { ...@@ -567,7 +567,7 @@ function rdf_preprocess_taxonomy_term(&$variables) {
$term = $variables['term']; $term = $variables['term'];
$mapping = rdf_get_mapping('taxonomy_term', $term->bundle()); $mapping = rdf_get_mapping('taxonomy_term', $term->bundle());
$bundle_mapping = $mapping->getPreparedBundleMapping(); $bundle_mapping = $mapping->getPreparedBundleMapping();
$variables['attributes']['about'] = $term->toUrl()->toString(); $variables['attributes']['about'] = $variables['url'];
$variables['attributes']['typeof'] = empty($bundle_mapping['types']) ? NULL : $bundle_mapping['types']; $variables['attributes']['typeof'] = empty($bundle_mapping['types']) ? NULL : $bundle_mapping['types'];
// Add RDFa markup for the taxonomy term name as metadata, if present. // Add RDFa markup for the taxonomy term name as metadata, if present.
......
...@@ -153,7 +153,7 @@ function template_preprocess_taxonomy_term(&$variables) { ...@@ -153,7 +153,7 @@ function template_preprocess_taxonomy_term(&$variables) {
/** @var \Drupal\taxonomy\TermInterface $term */ /** @var \Drupal\taxonomy\TermInterface $term */
$term = $variables['term']; $term = $variables['term'];
$variables['url'] = $term->toUrl()->toString(); $variables['url'] = !$term->isNew() ? $term->toUrl()->toString() : NULL;
// Make name field available separately. Skip this custom preprocessing if // Make name field available separately. Skip this custom preprocessing if
// the field display is configurable and skipping has been enabled. // the field display is configurable and skipping has been enabled.
......
...@@ -145,4 +145,27 @@ public function testTaxonomyVocabularyTree() { ...@@ -145,4 +145,27 @@ public function testTaxonomyVocabularyTree() {
$this->assertEqual(5, count($ancestors), 'The term has five ancestors including the term itself.'); $this->assertEqual(5, count($ancestors), 'The term has five ancestors including the term itself.');
} }
/**
* Tests that a Term is renderable when unsaved (preview).
*/
public function testTermPreview() {
$entity_manager = \Drupal::entityTypeManager();
$vocabulary = $this->createVocabulary();
// Create a unsaved term.
$term = $entity_manager->getStorage('taxonomy_term')->create([
'vid' => $vocabulary->id(),
'name' => 'Inator',
]);
// Confirm we can get the view of unsaved term.
$render_array = $entity_manager->getViewBuilder('taxonomy_term')
->view($term);
$this->assertTrue(!empty($render_array), 'Term view builder is built.');
// Confirm we can render said view.
$rendered = \Drupal::service('renderer')->renderPlain($render_array);
$this->assertTrue(!empty(trim($rendered)), 'Term is able to be rendered.');
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment