Skip to content

Commit

Permalink
Merge commit '0e2f0ba'
Browse files Browse the repository at this point in the history
  • Loading branch information
lekoala committed Oct 23, 2024
2 parents 6fcfa06 + 0e2f0ba commit 21293dd
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 5 deletions.
8 changes: 7 additions & 1 deletion src/CronJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,13 @@
* @property ?string $Title
* @property ?string $Category
* @property ?string $Description
* @property bool $Disabled
* @property bool|int $Disabled
* @mixin \LeKoala\Base\Extensions\BaseDataObjectExtension
* @mixin \SilverStripe\Assets\Shortcodes\FileLinkTracking
* @mixin \SilverStripe\Assets\AssetControlExtension
* @mixin \SilverStripe\CMS\Model\SiteTreeLinkTracking
* @mixin \SilverStripe\Versioned\RecursivePublishable
* @mixin \SilverStripe\Versioned\VersionedStateExtension
*/
class CronJob extends DataObject
{
Expand Down
10 changes: 8 additions & 2 deletions src/CronTaskResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,17 @@
*
* @property ?string $TaskClass
* @property ?string $Result
* @property bool $Failed
* @property bool $ForcedRun
* @property bool|int $Failed
* @property bool|int $ForcedRun
* @property ?string $StartDate
* @property ?string $EndDate
* @property int $TimeToExecute
* @mixin \LeKoala\Base\Extensions\BaseDataObjectExtension
* @mixin \SilverStripe\Assets\Shortcodes\FileLinkTracking
* @mixin \SilverStripe\Assets\AssetControlExtension
* @mixin \SilverStripe\CMS\Model\SiteTreeLinkTracking
* @mixin \SilverStripe\Versioned\RecursivePublishable
* @mixin \SilverStripe\Versioned\VersionedStateExtension
*/
class CronTaskResult extends DataObject
{
Expand Down
16 changes: 16 additions & 0 deletions src/SimpleJobsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ class SimpleJobsController extends Controller
*/
protected $basicAuthEnabled = false;

/**
* @var string
*/
protected static $currentTask = null;

/**
* @return void
*/
Expand Down Expand Up @@ -365,6 +370,7 @@ protected function runTask(CronTask $task, $forceRun = false)
// Handle exceptions for tasks
$error = null;
try {
self::$currentTask = get_class($task);
// We override docblock return type because we allow a result
/** @var mixed $result */
$result = $task->process();
Expand Down Expand Up @@ -407,6 +413,16 @@ protected function runTask(CronTask $task, $forceRun = false)
} else {
$this->output(get_class($task) . ' will run at ' . $cron->getNextRunDate()->format('Y-m-d H:i:s') . '.');
}

self::$currentTask = null;
}

/**
* @return ?string
*/
public static function getCurrentTask()
{
return self::$currentTask;
}

/**
Expand Down
10 changes: 8 additions & 2 deletions src/SimpleTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
*
* @property ?string $Name
* @property ?string $Task
* @property bool $Processed
* @property bool $Failed
* @property bool|int $Processed
* @property bool|int $Failed
* @property ?string $ErrorMessage
* @property int $TimeToExecute
* @property int $CallsCount
Expand All @@ -28,6 +28,12 @@
* @property ?string $RunDate
* @property int $OwnerID
* @method \SilverStripe\Security\Member Owner()
* @mixin \LeKoala\Base\Extensions\BaseDataObjectExtension
* @mixin \SilverStripe\Assets\Shortcodes\FileLinkTracking
* @mixin \SilverStripe\Assets\AssetControlExtension
* @mixin \SilverStripe\CMS\Model\SiteTreeLinkTracking
* @mixin \SilverStripe\Versioned\RecursivePublishable
* @mixin \SilverStripe\Versioned\VersionedStateExtension
*/
class SimpleTask extends DataObject
{
Expand Down

0 comments on commit 21293dd

Please sign in to comment.