File: /var/www/html/ielts-store/wp-content/plugins/automatewoo/includes/Entity/Workflow.php
<?php
namespace AutomateWoo\Entity;
use AutomateWoo\Workflows\Status;
/**
* @class Workflow
* @since 5.1.0
*/
class Workflow {
const TYPE_AUTOMATIC = 'automatic';
const TYPE_MANUAL = 'manual';
const ORIGIN_MANUALLY_CREATED = 'manually_created';
/**
* @var int
*/
protected $id = 0;
/**
* @var string
*/
protected $type = self::TYPE_AUTOMATIC;
/**
* @var Status
*/
protected $status;
/**
* @var string
*/
protected $title = '';
/**
* @var WorkflowTiming
*/
protected $timing;
/**
* @var bool
*/
protected $is_transactional = false;
/**
* @var bool
*/
protected $is_tracking_enabled = false;
/**
* @var bool
*/
protected $is_conversion_tracking_enabled = false;
/**
* Google Analytics link tracking
*
* This will be appended to every URL in the email content or SMS body. e.g. utm_source=automatewoo&utm_medium=email&utm_campaign=example
*
* @var string
*/
protected $ga_link_tracking = '';
/**
* @var Trigger
*/
protected $trigger;
/**
* Multiple groups of rules.
*
* @var RuleGroup[]
*/
protected $rule_groups = [];
/**
* @var Action[]
*/
protected $actions = [];
/**
* The origin of the workflow indicating how it was created (e.g. manually, a preset name, etc.)
*
* @var string
*/
protected $origin = self::ORIGIN_MANUALLY_CREATED;
/**
* Workflow constructor.
*
* @param Trigger $trigger
* @param string $type
* @param WorkflowTiming|null $timing Used when the workflow type is 'automatic'
* @param Status|null $status
*/
public function __construct( Trigger $trigger, string $type = self::TYPE_AUTOMATIC, $timing = null, $status = null ) {
$this->trigger = $trigger;
$this->type = $type;
$this->timing = $timing ?? new WorkflowTimingImmediate();
$this->status = $status ?? new Status( Status::DISABLED );
}
/**
* @return int
*/
public function get_id(): int {
return $this->id;
}
/**
* @param int $id
* @return $this
*/
public function set_id( int $id ) {
$this->id = $id;
return $this;
}
/**
* @return string
*/
public function get_type(): string {
return $this->type;
}
/**
* @param string $type
* @return $this
*/
public function set_type( string $type ) {
$this->type = $type;
return $this;
}
/**
* @return Status
*/
public function get_status(): Status {
return $this->status;
}
/**
* @param Status $status
* @return $this
*/
public function set_status( Status $status ) {
$this->status = $status;
return $this;
}
/**
* @return string
*/
public function get_title(): string {
return $this->title;
}
/**
* @param string $title
* @return $this
*/
public function set_title( string $title ) {
$this->title = $title;
return $this;
}
/**
* @return WorkflowTiming
*/
public function get_timing(): WorkflowTiming {
return $this->timing;
}
/**
* @param WorkflowTiming $timing
* @return $this
*/
public function set_timing( WorkflowTiming $timing ) {
$this->timing = $timing;
return $this;
}
/**
* @return bool
*/
public function is_transactional(): bool {
return $this->is_transactional;
}
/**
* @param bool $is_transactional
* @return $this
*/
public function set_is_transactional( $is_transactional ) {
$this->is_transactional = (bool) $is_transactional;
return $this;
}
/**
* @return bool
*/
public function is_tracking_enabled(): bool {
return $this->is_tracking_enabled;
}
/**
* @param bool $is_tracking_enabled
* @return $this
*/
public function set_is_tracking_enabled( $is_tracking_enabled ) {
$this->is_tracking_enabled = (bool) $is_tracking_enabled;
return $this;
}
/**
* @return bool
*/
public function is_conversion_tracking_enabled(): bool {
return $this->is_conversion_tracking_enabled;
}
/**
* @param bool $is_conversion_tracking_enabled
* @return $this
*/
public function set_is_conversion_tracking_enabled( $is_conversion_tracking_enabled ) {
$this->is_conversion_tracking_enabled = (bool) $is_conversion_tracking_enabled;
return $this;
}
/**
* @return string
*/
public function get_ga_link_tracking(): string {
return $this->ga_link_tracking;
}
/**
* @param string $ga_link_tracking
* @return Workflow
*/
public function set_ga_link_tracking( string $ga_link_tracking ) {
$this->ga_link_tracking = $ga_link_tracking;
return $this;
}
/**
* @return Trigger
*/
public function get_trigger() {
return $this->trigger;
}
/**
* @param Trigger $trigger
* @return $this
*/
public function set_trigger( Trigger $trigger ) {
$this->trigger = $trigger;
return $this;
}
/**
* @return RuleGroup[]
*/
public function get_rule_groups() {
return $this->rule_groups;
}
/**
* @param RuleGroup[] $rule_groups
*
* @return $this
*/
public function set_rule_groups( $rule_groups ) {
$this->rule_groups = [];
foreach ( $rule_groups as $rule_group ) {
$this->add_rule_group( $rule_group );
}
return $this;
}
/**
* @param RuleGroup $rule
*
* @return $this
*/
public function add_rule_group( RuleGroup $rule ) {
$this->rule_groups[] = $rule;
return $this;
}
/**
* @return Action[]
*/
public function get_actions() {
return $this->actions;
}
/**
* @param Action[] $actions
* @return $this
*/
public function set_actions( $actions ) {
$this->actions = [];
foreach ( $actions as $action ) {
$this->add_action( $action );
}
return $this;
}
/**
* @param Action $action
* @return $this
*/
public function add_action( Action $action ) {
$this->actions[] = $action;
return $this;
}
/**
* @param string|int $index
* @return $this
*/
public function remove_action( $index ) {
unset( $this->actions[ $index ] );
return $this;
}
/**
* @return string
*/
public function get_origin(): string {
return $this->origin;
}
/**
* @param string $origin
*
* @return Workflow
*/
public function set_origin( string $origin ): Workflow {
$this->origin = $origin;
return $this;
}
}