@@ -43,6 +43,7 @@ use Drupal\Component\Utility\Crypt;
4343use Drupal\Component\Utility\Xss;
4444use Drupal\Core\Access\AccessResult;
4545use Drupal\Core\Breadcrumb\Breadcrumb;
46+ use Drupal\Core\Cache\CacheableMetadata;
4647use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
4748use Drupal\Core\Entity\EntityInterface;
4849use Drupal\Core\Entity\EntityTypeInterface;
@@ -138,6 +139,12 @@ function apigee_edge_theme() {
138139 'render element' => 'elements',
139140 'base hook' => 'apigee_secret',
140141 ],
142+ 'apigee_app_credential_warnings' => [
143+ 'variables' => ['warnings' => []],
144+ ],
145+ 'apigee_app_credential_warnings_placeholder' => [
146+ 'variables' => ['app_type' => NULL, 'id' => NULL],
147+ ],
141148 ];
142149}
143150
@@ -450,17 +457,38 @@ function apigee_edge_entity_view(array &$build, EntityInterface $entity, EntityV
450457 }
451458
452459 if ($display->getComponent('warnings')) {
453- /** @var \Drupal\apigee_edge\Entity\AppWarningsCheckerInterface $app_warnings_checker */
454- $app_warnings_checker = \Drupal::service('apigee_edge.entity.app_warnings_checker');
455- $warnings = array_filter($app_warnings_checker->getWarnings($entity));
456- if (count($warnings)) {
460+ $app_settings_config = \Drupal::configFactory()->getEditable('apigee_edge.common_app_settings');
461+ CacheableMetadata::createFromRenderArray($build)->addCacheableDependency($app_settings_config)->applyTo($build);
462+
463+
464+ if ($app_settings_config->get('app_credential_warnings_bc_mode')) {
465+ /** @var \Drupal\apigee_edge\Entity\AppWarningsCheckerInterface $app_warnings_checker */
466+ $app_warnings_checker = \Drupal::service('apigee_edge.entity.app_warnings_checker');
467+ $warnings = array_filter($app_warnings_checker->getWarnings($entity));
468+ if (count($warnings)) {
469+ $build['warnings'] = [
470+ '#theme' => 'status_messages',
471+ '#message_list' => [
472+ 'warning' => $warnings,
473+ ],
474+ ];
475+ }
476+ }
477+ else {
457478 $build['warnings'] = [
458- '#theme' => 'status_messages',
459- '#message_list' => [
460- 'warning' => $warnings,
461- ],
479+ '#lazy_builder' => ['\Drupal\apigee_edge\LazyBuilder\AppWarningsLazyBuilder::lazyBuilder', [$entity->getEntityType()->id(), $entity->id()]],
480+ '#create_placeholder' => TRUE,
481+ '#lazy_builder_preview' => [
482+ '#theme' => 'apigee_app_credential_warnings_placeholder',
483+ '#app_type' => $entity->getEntityType()->id(),
484+ '#id' => $entity->id(),
485+ ]
462486 ];
463487 }
488+
489+ // if (array_key_exists('warnings', $build)) {
490+ // CacheableMetadata::createFromRenderArray($build['warnings'])->addCacheableDependency($app_settings_config)->applyTo($build['warnings']);
491+ // }
464492 }
465493}
466494
0 commit comments