You are here

protected function Transaction::urlRouteParameters in Transaction 8

Gets an array of placeholders for this entity.

Individual entity classes may override this method to add additional placeholders if desired. If so, they should be sure to replicate the property caching logic.

Parameters

string $rel: The link relationship type, for example: canonical or edit-form.

Return value

array An array of URI placeholders.

Overrides EntityBase::urlRouteParameters

File

src/Entity/Transaction.php, line 581

Class

Transaction
Provides the transaction content entity.

Namespace

Drupal\transaction\Entity

Code

protected function urlRouteParameters($rel) {
  $uri_route_parameters = parent::urlRouteParameters($rel);
  if ($rel === 'collection' || $rel == 'add-form') {
    $uri_route_parameters['transaction_type'] = $this
      ->getTypeId();
    $uri_route_parameters['target_entity_type'] = $this
      ->getType()
      ->getTargetEntityTypeId();

    // Transactions with empty target entity field is inconsistent. Returning
    // 0 to avoid exceptions. URL will end in a page not found.
    $uri_route_parameters['target_entity'] = $this
      ->getTargetEntityId() ?: 0;
  }
  return $uri_route_parameters;
}