Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By bojanz on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
8.x-2.x
Introduced in version:
8.x-2.0-beta6
Description:
Previously the buildPaneSummary() method was expected to return an HTML string, which required panes to inject the renderer service to render a renderable array into a string. This complicated matters, and made it harder to extend & modify the method by child classes.
Since beta6, the method returns a renderable array.
Before (ContactInformation):
/**
* {@inheritdoc}
*/
public function buildPaneSummary() {
return $this->order->getEmail();
}
After (ContactInformation):
/**
* {@inheritdoc}
*/
public function buildPaneSummary() {
return [
'#plain_text' => $this->order->getEmail(),
];
}
Before (BillingInformation):
/**
* {@inheritdoc}
*/
public function buildPaneSummary() {
$summary = '';
if ($billing_profile = $this->order->getBillingProfile()) {
$profile_view_builder = $this->entityTypeManager->getViewBuilder('profile');
$summary = $profile_view_builder->view($billing_profile, 'default');
$summary = $this->renderer->render($summary);
}
return $summary;
}
After (BillingInformation):
/**
* {@inheritdoc}
*/
public function buildPaneSummary() {
$summary = [];
if ($billing_profile = $this->order->getBillingProfile()) {
$profile_view_builder = $this->entityTypeManager->getViewBuilder('profile');
$summary = $profile_view_builder->view($billing_profile, 'default');
}
return $summary;
}
Note that a BC layer ensures that returning an HTML string from buildPaneSummary() still works, but is discouraged.
Impacts:
Module developers