Submit
Path:
~
/
/
proc
/
self
/
root
/
opt
/
psa
/
admin
/
plib
/
modules
/
wp-toolkit
/
vendor
/
plesk
/
background-tasks
/
src
/
Helper
/
File Content:
StepHelper.php
<?php // Copyright 1999-2024. WebPros International GmbH. All rights reserved. namespace BackgroundTasks\Helper; use BackgroundTasks\BaseTaskInterface; use BackgroundTasks\DataStorage\TaskDataStorageInterface; use BackgroundTasks\Progress\StepProgressInterface; use BackgroundTasks\Step\StepInterface; use BackgroundTasks\Step\StepMetaInfo; class StepHelper { /** * @param StepInterface[] $steps * @param TaskDataStorageInterface $taskDataStorage * @param int $taskProgress * @param string $taskStatus * @return StepMetaInfo[] */ public static function getStepsMetaInfo(array $steps, TaskDataStorageInterface $taskDataStorage, $taskProgress, $taskStatus) { $visibleSteps = self::getVisibleSteps($steps); $stepsCount = \count($visibleSteps); $progressPerStep = \ceil(100 / ($stepsCount > 0 ? $stepsCount : 1)); $stepsProgress = 0; $stepsMetaInfo = []; foreach ($visibleSteps as $step) { $stepHint = ''; if ($stepsProgress + $progressPerStep <= $taskProgress) { $progress = 100; $status = StepInterface::STATUS_DONE; } elseif ($stepsProgress <= $taskProgress && $stepsProgress + $progressPerStep > $taskProgress) { $progress = -1; $customProgress = $taskDataStorage->getPrivateParam(StepProgressInterface::CURRENT_STEP_PROGRESS, -1); if ($customProgress >= 0) { $progress = $customProgress; } $customHint = $taskDataStorage->getPrivateParam(StepProgressInterface::CURRENT_STEP_HINT, ''); if ($customHint !== '') { $stepHint = $customHint; } $status = $taskStatus; } else { $progress = 0; if (\in_array($taskStatus, [BaseTaskInterface::STATUS_CANCELED, BaseTaskInterface::STATUS_ERROR], \true)) { $status = StepInterface::STATUS_CANCELED; } else { $status = StepInterface::STATUS_NOT_STARTED; } } $stepsProgress += $progressPerStep; $stepsMetaInfo[] = new StepMetaInfo($step, $status, $progress, $stepHint); } return $stepsMetaInfo; } /** * @param StepInterface[] $steps * @return StepInterface[] */ public static function getVisibleSteps(array $steps) { return \array_filter($steps, function (StepInterface $step) { return !$step->isHidden(); }); } }
Edit
Rename
Chmod
Delete
FILE
FOLDER
INFO
Name
Size
Permission
Action
ProgressHelper.php
1122 bytes
0644
StepHelper.php
2608 bytes
0644
TaskProgressEqualItems.php
4256 bytes
0644
N4ST4R_ID | Naxtarrr