You are here

function command_buttons_machine_name_load in Command Buttons 7

Load a collection of button entities based on their machine name.

Parameters

$buttons: An array of button machine names.

File

./command_buttons.module, line 865

Code

function command_buttons_machine_name_load($buttons) {
  $entities = array();
  $bids = array();
  if (!is_array($buttons)) {
    $buttons = array(
      $buttons,
    );
  }
  if (empty($buttons)) {
    return $entities;
  }
  $results = db_select('command_buttons', 'b')
    ->fields('b', array(
    'bid',
  ))
    ->condition('name', $buttons, 'IN')
    ->orderBy('title')
    ->execute();
  while ($result = $results
    ->fetchObject()) {
    $bids[] = $result->bid;
  }
  if (count($bids)) {
    $entities = command_buttons_load_multiple($bids);
  }
  return $entities;
}