+ try {
+ $font = Font::loadByUrl('local_fonts://' . $entity->id());
+ $parameters = [
+ 'js' => 'nojs',
+ 'font' => $font->id(),
+ ];
+ $options = [
+ 'query' => \Drupal::destination()->getAsArray(),
+ ];
+ $row['font_view'] = Link::fromTextAndUrl($this->t('View Font'), $font->toUrl('canonical'));
+ if ($font->isActivated()) {
+ $url = Url::fromRoute('entity.font.deactivate', $parameters, $options);
+ $row['font_manage'] = Link::fromTextAndUrl($this->t('Disable'), $url);
+ }
+ else {
+ $url = Url::fromRoute('entity.font.activate', $parameters, $options);
+ $row['font_manage'] = Link::fromTextAndUrl($this->t('Enable'), $url);
+ }
+ }
+ catch (Exception $e) {
+ $row['font_view'] = $this->t('Disabled');
+ $row['font_manage'] = $this->t('Disabled');
+ }