You are here

function CdbController::dynamic_banner_find_load_default in Dynamic Banner 8

Find the default banner and return all of it's attributes

File

src/application/Controller/CdbController.php, line 112

Class

CdbController

Namespace

Drupal\dynamic_banner\application\Controller

Code

function dynamic_banner_find_load_default() {

  // TODO: Drupal Rector Notice: Please delete the following comment after you've made any necessary changes.
  // You will need to use `\Drupal\core\Database\Database::getConnection()` if you do not yet have access to the container here.
  $query = \Drupal::database()
    ->select('dynamic_banner', 'd');
  $query
    ->condition('d.path', 'DEFAULT', '=')
    ->fields('d');
  $result = $query
    ->execute()
    ->fetchObject();
  if ($result) {
    return $result;
  }

  // do not return null for this
  $blank_banner = new stdClass();
  $blank_banner->dbid = 0;
  $blank_banner->path = 'DEFAULT';
  $blank_banner->imgurl = '';
  $blank_banner->mode = 'normal';
  $blank_banner->text = '';
  $blank_banner->link = '';
  $blank_banner->imgfid = '';
  return $blank_banner;
}