public function LocalFontConfigEntityListBuilder::buildRow in @font-your-face 8.3
Builds a row for an entity in the entity listing.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: The entity for this row of the list.
Return value
array A render array structure of fields for this entity.
Overrides EntityListBuilder::buildRow
See also
\Drupal\Core\Entity\EntityListBuilder::render()
File
- modules/
local_fonts/ src/ LocalFontConfigEntityListBuilder.php, line 31
Class
- LocalFontConfigEntityListBuilder
- Provides a listing of Custom Font entities.
Namespace
Drupal\local_fontsCode
public function buildRow(EntityInterface $entity) {
$row['label'] = $entity
->label();
$row['id'] = $entity
->id();
$row['font_family'] = $entity->font_family;
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');
}
return $row + parent::buildRow($entity);
}