You are here

public static function RoutingTransactionNameSubscriber::entityBundleRouteTransactionName in New Relic 8

Same name and namespace in other branches
  1. 2.x src/EventSubscriber/RoutingTransactionNameSubscriber.php \Drupal\new_relic_rpm\EventSubscriber\RoutingTransactionNameSubscriber::entityBundleRouteTransactionName()
  2. 2.0.x src/EventSubscriber/RoutingTransactionNameSubscriber.php \Drupal\new_relic_rpm\EventSubscriber\RoutingTransactionNameSubscriber::entityBundleRouteTransactionName()

Get the transaction name for an "entity.$TYPE.$OP" route.

1 call to RoutingTransactionNameSubscriber::entityBundleRouteTransactionName()
RoutingTransactionNameSubscriberTest::testEntityRouteTransactionName in tests/src/Unit/EventListener/RoutingTransactionNameSubscriberTest.php
@covers ::entityBundleRouteTransactionName

File

src/EventSubscriber/RoutingTransactionNameSubscriber.php, line 68

Class

RoutingTransactionNameSubscriber
Enhances routes with a transaction name or transaction name callback.

Namespace

Drupal\new_relic_rpm\EventSubscriber

Code

public static function entityBundleRouteTransactionName(Request $request) {
  $name = $request->attributes
    ->get('_transaction_name');
  if (preg_match('/^entity\\.([a-z_]+)\\./', $name, $matches)) {
    $entity_type = $matches[1];
    if (($entity = $request->attributes
      ->get($entity_type)) && $entity instanceof EntityInterface) {
      return sprintf('%s:%s', $name, $entity
        ->bundle());
    }
  }
  return $name;
}