You are here

public function ShsCacheableJsonResponse::sendContent in Simple hierarchical select 2.0.x

Same name and namespace in other branches
  1. 8 src/Cache/ShsCacheableJsonResponse.php \Drupal\shs\Cache\ShsCacheableJsonResponse::sendContent()

File

src/Cache/ShsCacheableJsonResponse.php, line 55

Class

ShsCacheableJsonResponse
A cacheable JsonResponse that returns alterable data for SHS.

Namespace

Drupal\shs\Cache

Code

public function sendContent() {
  $identifier = str_replace('-', '_', $this->context['identifier']);
  $hooks = [
    'shs_term_data_response',
    "shs__bundle_{$this->context['bundle']}__term_data_response",
    "shs__field_{$identifier}__term_data_response",
  ];

  // Alter json encoded data.
  \Drupal::moduleHandler()
    ->alter($hooks, $this->content, $this->context);
  echo $this->content;
  return $this;
}