Select Git revision
phpstan-php8.neon.dist
Forked from
Stud.IP / Stud.IP
Source project has a limited visibility.
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
CronjobScheduler.class.php 12.74 KiB
<?php
/**
* CronjobScheduler - Scheduler for the cronjobs.
*
* @author Jan-Hendrik Willms <tleilax+studip@gmail.com>
* @license http://www.gnu.org/licenses/gpl-2.0.html GPL version 2
* @category Stud.IP
* @since 2.4
*/
// +---------------------------------------------------------------------------+
// This file is part of Stud.IP
// CronjobScheduler.class.php
//
// Copyright (C) 2013 Jan-Hendrik Willms <tleilax+studip@gmail.com>
// +---------------------------------------------------------------------------+
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or any later version.
// +---------------------------------------------------------------------------+
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
// +---------------------------------------------------------------------------+
class CronjobScheduler
{
protected static $instance = null;
/**
* Returns the scheduler object. Implements the singleton pattern to
* ensure that only one scheduler exists.
*
* @return CronjobScheduler The scheduler object
*/
public static function getInstance()
{
if (self::$instance === null) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Private constructor to ensure the singleton pattern is used correctly.
*/
private function __construct()
{
}
/**
* Registers a new executable task.
*
* @param mixed $task Either path of the task class filename (relative
* to Stud.IP root) or an instance of CronJob
* @param bool $active Indicates whether the task should be set active
* or not
* @return String Id of the created task
* @throws InvalidArgumentException when the task class file does not
* exist
* @throws RuntimeException when task has already been registered
*/
public function registerTask($task, $active = true)
{
if (is_object($task)) {