3 namespace Drupal\fontyourface\Entity;
5 use Drupal\Core\Config\Entity\ConfigEntityBase;
6 use Drupal\fontyourface\FontDisplayInterface;
9 * Defines the Font display entity.
12 * id = "font_display",
13 * label = @Translation("Font display"),
15 * "list_builder" = "Drupal\fontyourface\FontDisplayListBuilder",
17 * "add" = "Drupal\fontyourface\Form\FontDisplayForm",
18 * "edit" = "Drupal\fontyourface\Form\FontDisplayForm",
19 * "delete" = "Drupal\fontyourface\Form\FontDisplayDeleteForm"
21 * "route_provider" = {
22 * "html" = "Drupal\fontyourface\FontDisplayHtmlRouteProvider",
25 * config_prefix = "font_display",
26 * admin_permission = "administer font entities",
31 * "font_url" = "font_url",
33 * "weight" = "weight",
34 * "fallback" = "fallback",
35 * "selectors" = "selectors",
39 * "canonical" = "/admin/appearance/font/font_display/{font_display}",
40 * "add-form" = "/admin/appearance/font/font_display/add",
41 * "edit-form" = "/admin/appearance/font/font_display/{font_display}/edit",
42 * "delete-form" = "/admin/appearance/font/font_display/{font_display}/delete",
43 * "collection" = "/admin/appearance/font/font_display"
47 class FontDisplay extends ConfigEntityBase implements FontDisplayInterface {
49 * The Font display ID.
56 * The Font display label.
63 * Font URL - these are unique.
84 * Fallback fonts when font fails to load.
91 * Selectors where font applies.
98 * Theme - where the font + selectors will be used.
107 public function getFont() {
108 return Font::loadByUrl($this->getFontUrl());
114 public function getFontUrl() {
115 return $this->get('font_url');
121 public function setFontUrl($font_url) {
122 $this->set('font_url', $font_url);
129 public function getFallback() {
130 return $this->get('fallback');
136 public function setFallback($fallback) {
137 $this->set('fallback', $fallback);
144 public function getSelectors() {
145 return $this->get('selectors');
151 public function setSelectors($selectors) {
152 $this->set('selectors', $selectors);
159 public function getTheme() {
160 return $this->get('theme');
166 public function setTheme($theme) {
167 $this->set('theme', $theme);
174 public static function loadByTheme($theme) {
175 return \Drupal::entityManager()->getStorage('font_display')->loadByProperties(['theme' => $theme]);