You are here

class StateFlowNode in State Machine 7.3

Class StateFlowNode.

Handles node entities.

Hierarchy

Expanded class hierarchy of StateFlowNode

2 string references to 'StateFlowNode'
hook_state_flow_entity_plugins in modules/state_flow_entity/state_flow_entity.api.php
Implements hook_state_flow_entity_plugins().
state_flow_state_flow_entity_plugins in modules/state_flow/state_flow.module
Implements hook_state_flow_entity_plugins().

File

modules/state_flow/plugins/state_flow_node.inc, line 12
State Flow implementation of the State Machine class

View source
class StateFlowNode extends StateFlowEntity {

  /**
   * Callback for when an entity enters the unpublished state.
   *
   * Make sure this revision is the one going to the node table.
   */
  public function on_enter_published() {
    $this->object->published_revision_id = $this->object->{$this
      ->get_revision_key()};
    $this->object->status = 1;
  }

  /**
   * Callback for when a node enters the unpublished state.
   *
   * Make sure this revision is the one going to the node table.
   */
  public function on_enter_unpublished() {

    // "published_revision_id" is somewhat of a misnomer here. It's really
    // "the revision_id that is in the node table."
    $this->object->published_revision_id = $this->object->{$this
      ->get_revision_key()};
    $this->object->revision = FALSE;
    $this->object->state_flow_node_on_enter_unpublished = TRUE;
  }
  public function on_exit_published() {

    // If it is a scheduled event the transition has to be handled later because
    // we want to keep the current state.
    $event = $this
      ->get_event($this
      ->get_history_entity()->event);
    if ($event
      ->get_option('target') !== 'schedule') {
      $this->object->status = 0;
    }
  }

  /**
   * Handle unpublishing / publishing.
   *
   * Usually StateFlowNode::on_exit_published() handles this - but since
   * scheduling shouldn't change the state during scheduling we do it here too.
   *
   * @see StateFlowNode::on_exit_published()
   */
  public function on_exit_scheduled() {

    // Fire the previously skipped hook.
    $this
      ->on_exit_published();
    parent::on_exit_scheduled();
  }

  /**
   * Provide the current state of this revision or entity.
   *
   * @return string
   *   Machine name of a state.
   */
  public function load() {
    $state = parent::load();

    // When State Flow is installed on an existing site there may be nodes
    // already published. Those nodes should be considered as "published" by
    // State Flow.
    if (empty($state) && !empty($this->object->status) && !empty($this->object->nid)) {
      return 'published';
    }
    return $state;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
StateFlowEntity::$current public property Overrides StateMachine::$current
StateFlowEntity::$default_state public property
StateFlowEntity::$initial public property Called from StateMachine::__construct to initialize the states and events. Overrides StateMachine::$initial
StateFlowEntity::$object public property Overrides StateMachine::$object
StateFlowEntity::$plugin public property
StateFlowEntity::clean_history_entity public function Removes all non Entity API properties from the history_entity.
StateFlowEntity::delete_state_flow_revision public function
StateFlowEntity::entityPresave public function Called by hook_entity_presave().
StateFlowEntity::entity_saved public function Called by hook_entity_insert() / hook_entity_update().
StateFlowEntity::fire_event public function Extending fire_event() from state_machine's base.inc. Overrides StateMachine::fire_event
StateFlowEntity::forward_history protected function Forwards the history and states similar what drafty does for entities.
StateFlowEntity::get_active_revision public function Get the active revision.
StateFlowEntity::get_available_events_options public function Get available events as an array suitable for FAPI.
StateFlowEntity::get_default_event_name public function Get a default event.
StateFlowEntity::get_entity_id_key public function Get the revision key for this entity type.
StateFlowEntity::get_entity_type public function
StateFlowEntity::get_event public function Return an event. Overrides StateMachine::get_event
StateFlowEntity::get_full_history public function Provide entire state_flow history.
StateFlowEntity::get_history_entity public function Get the state flow history entity.
StateFlowEntity::get_label_for_current_state public function Get the label for the current state.
StateFlowEntity::get_latest_revision public function Get the latest revision id.
StateFlowEntity::get_object public function
StateFlowEntity::get_revision_key public function Get the revision key for this entity type.
StateFlowEntity::get_states_options public function
StateFlowEntity::history_entity_form_field_validate public function Validate the filed API from values with state_flow_history_entity values.
StateFlowEntity::history_entity_form_submit_build_entity public function Build up a full state flow history entity from form values.
StateFlowEntity::init public function Called from StateMachine::__construct to initialize the states and events. Overrides StateMachine::init
StateFlowEntity::isActivePublishedRevision public function Check if the current object is the active published revision.
StateFlowEntity::isDraftRevision protected function Check if the current object is a draft revision.
StateFlowEntity::latest_state public function
StateFlowEntity::object_is_drafty_forward_revision public function
StateFlowEntity::object_is_new public function Returns TRUE if the entity is new.
StateFlowEntity::revision_state public function Return the state of the revision
StateFlowEntity::set_available_publish_revision public function Set the vid from the node table as the "Published" revision.
StateFlowEntity::set_current_history public function Provide history with each revision.
StateFlowEntity::set_history_entity public function Set the state flow history entity.
StateFlowEntity::set_object public function
StateFlowEntity::write_active public function Update the current status record for the revision.
StateFlowEntity::write_history public function Write the transaction to the history table.
StateFlowEntity::write_state public function Update the current status record for the revision.
StateFlowEntity::__construct public function Create instance of StateMachine. Overrides StateMachine::__construct
StateFlowNode::load public function Provide the current state of this revision or entity. Overrides StateFlowEntity::load
StateFlowNode::on_enter_published public function Callback for when an entity enters the unpublished state.
StateFlowNode::on_enter_unpublished public function Callback for when a node enters the unpublished state.
StateFlowNode::on_exit_published public function
StateFlowNode::on_exit_scheduled public function Handle unpublishing / publishing. Overrides StateFlowEntity::on_exit_scheduled
StateMachine::$events protected property
StateMachine::$states protected property
StateMachine::create_event protected function Create a new event.
StateMachine::create_state protected function Create a new state.
StateMachine::get_all_events public function Get all of the events.
StateMachine::get_available_events public function Returns an array of events that are valid for the current state.
StateMachine::get_current_state public function Returns the current state.
StateMachine::get_state public function Return a state instance by key, lazy-loading the instance if necessary.
StateMachine::ignore public function Whether State Machine to be ignored.
StateMachine::on_event_fail protected function Method to be called when firing an event fails for any reason.
StateMachine::persist protected function Persist the current state to the object storage.
StateMachine::set_current_state protected function Set the current state to the state identified by the specified key.
StateMachine::set_initial_state protected function Set the initial state for this machine.