public static function deploy($schedule) { // Don't proceed if there's nothing to schedule if (static::count() == 0 && count($schedule) == 0) { return false; } $cronfile = shared_storage_dir() . '/' . Context::getAppId() . '.cron'; $previous_tasks = file_exists($cronfile) ? file_get_contents($cronfile) : ""; $new_tasks = ''; // Remove all scheduled tasks for this app static::truncate(); foreach ($schedule as $task) { $task = ScheduledTask::create($task); $new_tasks .= $task->getCommand() . "\n"; } file_put_contents($cronfile, $new_tasks); static::install(); return $previous_tasks != $new_tasks; }
public function keys() { Context::setTablePrefix(''); return Model\AppKey::where('app_id', Context::getAppId())->get(); }