You are here

function support_ticket_test_support_ticket_view in Support Ticketing System 8

Implements hook_ENTITY_TYPE_view() for support_ticket entities.

File

modules/support_ticket/tests/modules/support_ticket_test/support_ticket_test.module, line 18
A dummy module for testing support_ticket related hooks.

Code

function support_ticket_test_support_ticket_view(array &$build, SupportTicketInterface $support_ticket, EntityViewDisplayInterface $display, $view_mode) {
  if ($view_mode == 'rss') {

    // Add RSS elements and namespaces when building the RSS feed.
    $support_ticket->rss_elements[] = array(
      'key' => 'testElement',
      'value' => t('Value of testElement RSS element for support_ticket @id.', array(
        '@id' => $support_ticket
          ->id(),
      )),
    );

    // Add content that should be displayed only in the RSS feed.
    $build['extra_feed_content'] = array(
      '#markup' => '<p>' . t('Extra data that should appear only in the RSS feed for support_ticket @id.', array(
        '@id' => $support_ticket
          ->id(),
      )) . '</p>',
      '#weight' => 10,
    );
  }
  if ($view_mode != 'rss') {

    // Add content that should NOT be displayed in the RSS feed.
    $build['extra_non_feed_content'] = array(
      '#markup' => '<p>' . t('Extra data that should appear everywhere except the RSS feed for support_ticket @id.', array(
        '@id' => $support_ticket
          ->id(),
      )) . '</p>',
    );
  }
}