You are here

class WebformWorkflowStateInlineEntityFormController in Webform Workflow 7

@file Defines the inline entity form controller for webform workflow states.

Hierarchy

Expanded class hierarchy of WebformWorkflowStateInlineEntityFormController

1 string reference to 'WebformWorkflowStateInlineEntityFormController'
webform_workflow_entity_info in ./webform_workflow.module
Implements hook_entity_info().

File

includes/webform_workflow_state.inline_entity_form.inc, line 8
Defines the inline entity form controller for webform workflow states.

View source
class WebformWorkflowStateInlineEntityFormController extends EntityInlineEntityFormController {

  /**
   * Overrides EntityInlineEntityFormController::labels().
   */
  public function labels() {
    $labels = array(
      'singular' => t('state'),
      'plural' => t('states'),
    );
    return $labels;
  }

  /**
   * Overrides EntityInlineEntityFormController::entityForm().
   */
  public function entityForm($entity_form, &$form_state) {
    $entity_form = parent::entityForm($entity_form, $form_state);
    form_load_include($form_state, 'inc', 'webform_workflow', 'includes/webform_workflow_state.forms');
    webform_workflow_state_form_attach($entity_form, $form_state, $entity_form['#entity']);
    return $entity_form;
  }

  /**
   * Overrides EntityInlineEntityFormController::tableFields().
   */
  public function tableFields($bundles) {
    $fields = array();
    $fields['label'] = array(
      'type' => 'property',
      'label' => t('Name'),
      'weight' => 1,
    );
    $fields['color'] = array(
      'type' => 'property',
      'label' => t('Color'),
      'weight' => 2,
      // For the 'formatter callback' key to work, this patch to Inline Entity
      // Form is required: https://www.drupal.org/node/2097583#comment-8997683
      'formatter callback' => array(
        $this,
        'formatColor',
      ),
    );
    $fields['ww_state_notify_users'] = array(
      'type' => 'field',
      'label' => t('Users to notify'),
      'weight' => 3,
    );
    $fields['ww_state_notify_os'] = array(
      'type' => 'field',
      'label' => t('Notify submitter'),
      'weight' => 4,
    );
    return $fields;
  }

  /**
   * Formatter callback for a state color.
   *
   * @param string $color
   *   The color (as a machine name).
   *
   * @return string
   *   An HTML string.
   */
  public function formatColor($color) {
    $color_labels = webform_workflow_state_color_options_list();
    return theme('webform_workflow_state_color', array(
      'content' => $color_labels[$color],
      'color' => $color,
    ));
  }

}

Members

Namesort descending Modifiers Type Description Overrides
EntityInlineEntityFormController::$entityType protected property
EntityInlineEntityFormController::$settings public property
EntityInlineEntityFormController::createClone public function Creates a clone of the given entity. 2
EntityInlineEntityFormController::css public function Returns an array of css filepaths for the current entity type, keyed by theme name. 1
EntityInlineEntityFormController::defaultLabels public function Returns the default entity type labels. 2
EntityInlineEntityFormController::defaultSettings public function Returns an array of default settings in the form of key => value. 2
EntityInlineEntityFormController::delete public function Delete permanently saved entities. 1
EntityInlineEntityFormController::entityFormSubmit public function Handles the submission of an entity form. 4
EntityInlineEntityFormController::entityFormValidate public function Validates the entity form. 2
EntityInlineEntityFormController::entityType public function Returns the entity type managed by this controller.
EntityInlineEntityFormController::getSetting public function Returns a setting value.
EntityInlineEntityFormController::removeForm public function Returns the remove form to be shown through the IEF widget. 1
EntityInlineEntityFormController::removeFormSubmit public function Handles the submission of a remove form. Decides what should happen to the entity after the removal confirmation.
EntityInlineEntityFormController::save public function Permanently saves the given entity. 2
EntityInlineEntityFormController::settingsForm public function Returns the settings form for the current entity type. 2
EntityInlineEntityFormController::__construct public function 1
WebformWorkflowStateInlineEntityFormController::entityForm public function Overrides EntityInlineEntityFormController::entityForm(). Overrides EntityInlineEntityFormController::entityForm
WebformWorkflowStateInlineEntityFormController::formatColor public function Formatter callback for a state color.
WebformWorkflowStateInlineEntityFormController::labels public function Overrides EntityInlineEntityFormController::labels(). Overrides EntityInlineEntityFormController::labels
WebformWorkflowStateInlineEntityFormController::tableFields public function Overrides EntityInlineEntityFormController::tableFields(). Overrides EntityInlineEntityFormController::tableFields