You are here

public function Meta::save in Easymeta 8

Save and persist Meta.

File

src/Meta.php, line 113

Class

Meta
Meta Class.

Namespace

Drupal\easymeta

Code

public function save() {
  $array = [
    "url" => $this
      ->getUrl(),
    "language" => $this
      ->getLanguage(),
    "metas" => serialize($this
      ->getValue()),
  ];
  if ($this->id) {
    $query = \Drupal::database()
      ->update('easymeta');
    $query
      ->fields($array);
    $query
      ->condition('emid', $this->id);
    return $query
      ->execute();
  }
  else {
    $query = \Drupal::database()
      ->insert('easymeta');
    $query
      ->fields($array);
    return $query
      ->execute();
  }
}