You are here

public function Font::activate in @font-your-face 8.3

Enable a font.

Return value

bool TRUE is font is enabled. FALSE otherwise.

Overrides FontInterface::activate

File

src/Entity/Font.php, line 135

Class

Font
Defines the Font entity.

Namespace

Drupal\fontyourface\Entity

Code

public function activate() {
  $config = \Drupal::configFactory()
    ->getEditable('fontyourface.settings');
  if (!$this
    ->isActivated()) {
    $enabled_fonts = $config
      ->get('enabled_fonts');
    $enabled_fonts[] = $this->url->value;
    $config
      ->set('enabled_fonts', $enabled_fonts)
      ->save();
  }
  $this->status->value = TRUE;
  $this
    ->save();
  return $this
    ->isActivated();
}