You are here

protected function Field::getEntityLink in Security Review 8

Attempt to get a good link for the given entity.

Falls back on a string with entity type id and id if no good link can be found.

Parameters

\Drupal\Core\Entity\EntityBase $entity: The entity.

Return value

string

2 calls to Field::getEntityLink()
Field::evaluate in src/Checks/Field.php
Returns the evaluation page of a result.
Field::evaluatePlain in src/Checks/Field.php
Evaluates a CheckResult and returns a plaintext output.

File

src/Checks/Field.php, line 174

Class

Field
Checks for Javascript and PHP in submitted content.

Namespace

Drupal\security_review\Checks

Code

protected function getEntityLink(EntityInterface $entity) {
  try {
    $url = $entity
      ->toUrl('edit-form');
  } catch (UndefinedLinkTemplateException $e) {
    $url = NULL;
  }
  if ($url === NULL) {
    try {
      $url = $entity
        ->toUrl();
    } catch (UndefinedLinkTemplateException $e) {
      $url = NULL;
    }
  }
  return $url !== NULL ? $url
    ->toString() : $entity
    ->getEntityTypeId() . ':' . $entity
    ->id();
}