[TASK] Fixed links to issues in Changelog
[Packages/TYPO3.CMS.git] / typo3 / sysext / scheduler / Classes / Example / SleepTask.php
1 <?php
2
3 /*
4 * This file is part of the TYPO3 CMS project.
5 *
6 * It is free software; you can redistribute it and/or modify it under
7 * the terms of the GNU General Public License, either version 2
8 * of the License, or any later version.
9 *
10 * For the full copyright and license information, please read the
11 * LICENSE.txt file that was distributed with this source code.
12 *
13 * The TYPO3 project - inspiring people to share!
14 */
15
16 namespace TYPO3\CMS\Scheduler\Example;
17
18 use TYPO3\CMS\Scheduler\Task\AbstractTask;
19
20 /**
21 * Provides a task that sleeps for some time
22 * This is useful for testing parallel executions
23 * @internal This class is an example is not considered part of the Public TYPO3 API.
24 */
25 class SleepTask extends AbstractTask
26 {
27 /**
28 * Number of seconds the task should be sleeping for
29 *
30 * @var int
31 */
32 public $sleepTime = 10;
33
34 /**
35 * Function executed from the Scheduler.
36 * Goes to sleep ;-)
37 *
38 * @return bool
39 */
40 public function execute()
41 {
42 $time = 10;
43 if (!empty($this->sleepTime)) {
44 $time = $this->sleepTime;
45 }
46 sleep($time);
47 return true;
48 }
49
50 /**
51 * This method returns the sleep duration as additional information
52 *
53 * @return string Information to display
54 */
55 public function getAdditionalInformation()
56 {
57 return $this->getLanguageService()->sL('LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:label.sleepTime') . ': ' . $this->sleepTime;
58 }
59 }