protected function UsageEventSubscriber::getEntityUrl in Bynder 4.0.x
Same name and namespace in other branches
- 8.3 modules/bynder_usage/src/EventSubscriber/UsageEventSubscriber.php \Drupal\bynder_usage\EventSubscriber\UsageEventSubscriber::getEntityUrl()
Returns the canonical URL for the given entity.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: The source entity.
Return value
\Drupal\Core\Url|null The absolute URL of the given entity.
2 calls to UsageEventSubscriber::getEntityUrl()
- UsageEventSubscriber::getUsageEventMediainformation in modules/
bynder_usage/ src/ EventSubscriber/ UsageEventSubscriber.php - Auxiliary function to get media information for asset usage operations.
- UsageEventSubscriber::onDeleteBySourceEntity in modules/
bynder_usage/ src/ EventSubscriber/ UsageEventSubscriber.php - Triggers when the source entity is deleted.
File
- modules/
bynder_usage/ src/ EventSubscriber/ UsageEventSubscriber.php, line 100
Class
- UsageEventSubscriber
- Listens for the usage events from Entity Usage module.
Namespace
Drupal\bynder_usage\EventSubscriberCode
protected function getEntityUrl(EntityInterface $entity) {
// If the entity is a paragraph, attempt to recursively load the parent.
while ($entity && $entity instanceof ParagraphInterface) {
$entity = $entity
->getParentEntity();
}
// If the entity exists and has a canonical link template, get the URI.
return $entity && $entity
->hasLinkTemplate('canonical') ? $entity
->toUrl('canonical')
->setOption('path_processing', FALSE)
->setAbsolute() : NULL;
}