PluginProbe ʕ •ᴥ•ʔ
Matomo Analytics – Powerful, Privacy-First Insights for WordPress / 1.3.1
Matomo Analytics – Powerful, Privacy-First Insights for WordPress v1.3.1
5.11.1 5.11.0 5.10.2 5.10.1 trunk 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.3.0 1.3.1 1.3.2 4.0.0 4.0.1 4.0.2 4.0.3 4.0.4 4.1.0 4.1.1 4.1.2 4.1.3 4.10.0 4.11.0 4.12.0 4.13.0 4.13.2 4.13.3 4.13.4 4.13.5 4.14.0 4.14.1 4.14.2 4.15.0 4.15.1 4.15.2 4.15.3 4.2.0 4.3.0 4.3.1 4.4.1 4.4.2 4.5.0 4.6.0 5.0.1 5.0.2 5.0.3 5.0.4 5.0.5 5.0.6 5.0.7 5.0.8 5.1.0 5.1.1 5.1.2 5.1.3 5.1.4 5.1.5 5.1.6 5.1.7 5.10.0 5.2.0 5.2.1 5.2.2 5.3.0 5.3.1 5.3.2 5.3.3 5.6.0 5.6.1 5.7.0 5.7.1 5.8.0 5.8.1 5.8.2
matomo / app / core / TaskScheduler.php
matomo / app / core Last commit date
API 6 years ago Access 6 years ago Application 6 years ago Archive 6 years ago ArchiveProcessor 6 years ago Archiver 6 years ago AssetManager 6 years ago Auth 6 years ago Category 6 years ago CliMulti 6 years ago Columns 6 years ago Composer 6 years ago Concurrency 6 years ago Config 6 years ago Container 6 years ago CronArchive 6 years ago DataAccess 5 years ago DataFiles 6 years ago DataTable 6 years ago Db 6 years ago DeviceDetector 5 years ago Email 6 years ago Exception 6 years ago Http 6 years ago Intl 6 years ago Mail 6 years ago Measurable 6 years ago Menu 6 years ago Metrics 6 years ago Notification 6 years ago Period 6 years ago Plugin 6 years ago ProfessionalServices 6 years ago Report 6 years ago ReportRenderer 6 years ago Scheduler 6 years ago Segment 6 years ago Session 6 years ago Settings 6 years ago Tracker 5 years ago Translation 6 years ago UpdateCheck 6 years ago Updater 6 years ago Updates 6 years ago Validators 6 years ago View 6 years ago ViewDataTable 6 years ago Visualization 6 years ago Widget 6 years ago .htaccess 6 years ago Access.php 6 years ago Archive.php 6 years ago ArchiveProcessor.php 6 years ago AssetManager.php 6 years ago Auth.php 6 years ago BaseFactory.php 6 years ago Cache.php 6 years ago CacheId.php 6 years ago CliMulti.php 6 years ago Common.php 6 years ago Config.php 6 years ago Console.php 6 years ago Context.php 6 years ago Cookie.php 5 years ago CronArchive.php 5 years ago DataArray.php 6 years ago DataTable.php 6 years ago Date.php 6 years ago Db.php 6 years ago DbHelper.php 6 years ago Development.php 6 years ago DeviceDetectorFactory.php 6 years ago ErrorHandler.php 6 years ago EventDispatcher.php 6 years ago ExceptionHandler.php 6 years ago FileIntegrity.php 6 years ago Filechecks.php 6 years ago Filesystem.php 6 years ago FrontController.php 6 years ago Http.php 6 years ago IP.php 6 years ago Log.php 6 years ago LogDeleter.php 6 years ago Mail.php 6 years ago Metrics.php 6 years ago MetricsFormatter.php 6 years ago Nonce.php 5 years ago Notification.php 6 years ago NumberFormatter.php 6 years ago Option.php 5 years ago Period.php 6 years ago Piwik.php 6 years ago Plugin.php 6 years ago Profiler.php 6 years ago ProxyHeaders.php 6 years ago ProxyHttp.php 6 years ago QuickForm2.php 6 years ago RankingQuery.php 6 years ago Registry.php 6 years ago ReportRenderer.php 6 years ago ScheduledTask.php 6 years ago Segment.php 6 years ago Sequence.php 6 years ago Session.php 6 years ago SettingsPiwik.php 6 years ago SettingsServer.php 6 years ago Singleton.php 6 years ago Site.php 6 years ago TCPDF.php 6 years ago TaskScheduler.php 6 years ago Theme.php 6 years ago Timer.php 6 years ago Tracker.php 6 years ago Translate.php 6 years ago Twig.php 6 years ago Unzip.php 6 years ago UpdateCheck.php 6 years ago Updater.php 6 years ago Updates.php 6 years ago Url.php 6 years ago UrlHelper.php 6 years ago Version.php 5 years ago View.php 6 years ago bootstrap.php 6 years ago dispatch.php 6 years ago testMinimumPhpVersion.php 6 years ago
TaskScheduler.php
121 lines
1 <?php
2 /**
3 * Piwik - free/libre analytics platform
4 *
5 * @link https://matomo.org
6 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
7 *
8 */
9
10 namespace Piwik;
11
12 use Piwik\Container\StaticContainer;
13 use Piwik\Scheduler\Scheduler;
14 use Piwik\Scheduler\Task;
15
16 // When set to true, all scheduled tasks will be triggered in all requests (careful!)
17 //define('DEBUG_FORCE_SCHEDULED_TASKS', true);
18
19 /**
20 * Manages scheduled task execution.
21 *
22 * A scheduled task is a callback that should be executed every so often (such as daily,
23 * weekly, monthly, etc.). They are registered by extending {@link \Piwik\Plugin\Tasks}.
24 *
25 * Tasks are executed when the `core:archive` command is executed.
26 *
27 * ### Examples
28 *
29 * **Scheduling a task**
30 *
31 * class Tasks extends \Piwik\Plugin\Tasks
32 * {
33 * public function schedule()
34 * {
35 * $this->hourly('myTask'); // myTask() will be executed once every hour
36 * }
37 * public function myTask()
38 * {
39 * // do something
40 * }
41 * }
42 *
43 * **Executing all pending tasks**
44 *
45 * $results = TaskScheduler::runTasks();
46 * $task1Result = $results[0];
47 * $task1Name = $task1Result['task'];
48 * $task1Output = $task1Result['output'];
49 *
50 * echo "Executed task '$task1Name'. Task output:\n$task1Output";
51 *
52 * @deprecated Use Piwik\Scheduler\Scheduler instead
53 * @see \Piwik\Scheduler\Scheduler
54 */
55 class TaskScheduler
56 {
57 /**
58 * Executes tasks that are scheduled to run, then reschedules them.
59 *
60 * @return array An array describing the results of scheduled task execution. Each element
61 * in the array will have the following format:
62 *
63 * ```
64 * array(
65 * 'task' => 'task name',
66 * 'output' => '... task output ...'
67 * )
68 * ```
69 */
70 public static function runTasks()
71 {
72 return self::getInstance()->run();
73 }
74
75 /**
76 * Determines a task's scheduled time and persists it, overwriting the previous scheduled time.
77 *
78 * Call this method if your task's scheduled time has changed due to, for example, an option that
79 * was changed.
80 *
81 * @param Task $task Describes the scheduled task being rescheduled.
82 * @api
83 */
84 public static function rescheduleTask(Task $task)
85 {
86 self::getInstance()->rescheduleTask($task);
87 }
88
89 /**
90 * Returns true if the TaskScheduler is currently running a scheduled task.
91 *
92 * @return bool
93 */
94 public static function isTaskBeingExecuted()
95 {
96 return self::getInstance()->isRunningTask();
97 }
98
99 /**
100 * Return the next scheduled time given the class and method names of a scheduled task.
101 *
102 * @param string $className The name of the class that contains the scheduled task method.
103 * @param string $methodName The name of the scheduled task method.
104 * @param string|null $methodParameter Optional method parameter.
105 * @return mixed int|bool The time in miliseconds when the scheduled task will be executed
106 * next or false if it is not scheduled to run.
107 */
108 public static function getScheduledTimeForMethod($className, $methodName, $methodParameter = null)
109 {
110 return self::getInstance()->getScheduledTimeForMethod($className, $methodName, $methodParameter);
111 }
112
113 /**
114 * @return Scheduler
115 */
116 private static function getInstance()
117 {
118 return StaticContainer::getContainer()->get('Piwik\Scheduler\Scheduler');
119 }
120 }
121