public function getTarget($getLive = false)
    {
        if ($this->TargetID && $this->TargetClass) {
            $versionable = Injector::inst()->get($this->TargetClass)->has_extension(Versioned::class);
            $targetObject = null;

            if (!$versionable && $getLive) {
                return;
            }
            if ($versionable) {
                $targetObject = Versioned::get_by_stage(
                    $this->TargetClass,
                    $getLive ? Versioned::LIVE : Versioned::DRAFT
                )->byID($this->TargetID);
            }
            if (!$targetObject) {
                $targetObject = DataObject::get_by_id($this->TargetClass, $this->TargetID);
            }

            return $targetObject;
        }
    }
public function getTarget($getLive = false)
    {
        if ($this->TargetID && $this->TargetClass) {
            $versionable = Injector::inst()->get($this->TargetClass)->has_extension(Versioned::class);
            $targetObject = null;

            if (!$versionable && $getLive) {
                return;
            }
            if ($versionable) {
                $targetObject = Versioned::get_by_stage(
                    $this->TargetClass,
                    $getLive ? Versioned::LIVE : Versioned::DRAFT
                )->byID($this->TargetID);
            }
            if (!$targetObject) {
                $targetObject = DataObject::get_by_id($this->TargetClass, $this->TargetID);
            }

            return $targetObject;
        }
    }
public function getTarget ( $ getLive = false ) { if ( $ this -> TargetID && $ this -> TargetClass ) { $ versionable = Injector :: inst ( ) -> get ( $ this -> TargetClass ) -> has_extension ( Versioned :: class ) ; $ targetObject = null ; if ( ! $ versionable && $ getLive ) { return ; } if ( $ versionable ) { $ targetObject = Versioned :: get_by_stage ( $ this -> TargetClass , $ getLive ? Versioned :: LIVE : Versioned :: DRAFT ) -> byID ( $ this -> TargetID ) ; } if ( ! $ targetObject ) { $ targetObject = DataObject :: get_by_id ( $ this -> TargetClass , $ this -> TargetID ) ; } return $ targetObject ; } }
Get the target-object that this WorkflowInstance "points" to.

Workflows are not restricted to being active on SiteTree objects,
so we need to account for being attached to anything.

Sets Versioned::set_reading_mode() to allow fetching of Draft _and_ Published
content.

@param boolean $getLive
@return null|DataObject
Get the target - object that this WorkflowInstance points to .