You are here

public function PurgePurgerBundleUI::set_form_item in Purge 7.2

Sets the bundle with data from the form.

File

includes/purge_ui.class.inc, line 22
Provides administrative interface for the Purge module.

Class

PurgePurgerBundleUI
Generates UI elements for the Purge UI module.

Code

public function set_form_item($action = 'view', $item_type = NULL, $item_name = NULL) {
  $this->action = $action;
  $this->item_type = $item_type;
  $this->item_name = $item_name;

  // See if we are managing an existing item.
  if (!is_null($item_type) && !is_null($item_name)) {
    if ($action == 'view' || $action == 'edit') {
      $this->form_item = $this->{$item_type}[$item_name];
    }
    elseif ($action == 'clone') {
      $this->form_item = clone $this->{$item_type}[$item_name];
    }
    elseif ($action == 'example') {

      // Load the defaults.inc file
      module_load_include('inc', 'purge', 'includes/defaults');
      $example_bundle = new PurgePurgerBundleExample();
      $this->form_item = clone $example_bundle->{$item_type}[$item_name];

      // @TODO: also add the items of this example in the bundle.
    }
    elseif ($action == 'add' && ($item_name = 'new')) {
      if ($item_type == 'target') {
        $this->form_item = new PurgeTargetStatic();
      }
      elseif ($item_type == 'domain') {
        $this->form_item = new PurgeDomainStatic();
      }
      elseif ($item_type == 'header') {
        $this->form_item = new PurgeHeaderStatic();
      }
      elseif ($item_type == 'purger') {
        $this->form_item = new PurgePurgerURL();
      }
    }
  }
}