You are here

public function PartyDataBase::getAction in Party 8.2

Get a PartyDataSetAction class for an action on this data set.

Parameters

$action: The action name, as given in the data set info.

Throws

Exception if the $action provided is not defined for this data set.

File

lib/Drupal/party/Plugin/PartyDataBase.php, line 292
Contains \Drupal\party\Plugin\PartyDataBase.

Class

PartyDataBase
Class PartyDataBase

Namespace

Drupal\party\Plugin

Code

public function getAction($action) {

  // If we've already built this action controller don't do so again.
  if (!empty($this->actions[$action])) {
    return $this->actions[$action];
  }

  // Check the action is legit.
  $info = party_get_data_set_info($this->data_set);
  if (empty($info['actions'][$action])) {
    throw new Exception(t('Action: @action does not exist for data set @data_set', array(
      '@action' => $action,
      '@data_set' => $this->data_set,
    )));
  }
  $this->actions[$action] = new $info['actions'][$action]['controller']($this, $action);
  return $this->actions[$action];
}