You are here

public function Groups::load in SimpleAds 8

1 call to Groups::load()
Groups::delete in src/Groups.php

File

src/Groups.php, line 82

Class

Groups
Groups utility class.

Namespace

Drupal\simpleads

Code

public function load() {
  if ($id = $this
    ->getId()) {
    $record = db_select('simpleads_groups', 's')
      ->fields('s')
      ->condition('s.id', $id)
      ->execute()
      ->fetchObject();
    $item = (new self())
      ->setId($id)
      ->setGroupName($record->name)
      ->setDescription($record->description)
      ->setOptions(!empty($record->options) ? json_decode($record->options, TRUE) : [])
      ->setCreatedAt($record->created_at)
      ->setChangedAt($record->changed_at);
    return $item;
  }
  return $this;
}