addTask() public static method

添加任务
public static addTask ( string $task, integer $frequency = 60 ) : void
$task string 任务的类名带命名空间
$frequency integer 执行的频率
return void
Beispiel #1
0
 /**
  * 添加一个后台任务
  *
  * @param array $args 传递给命令的参数
  * @param array $options 传递给命令的选项
  *
  * @throws \InvalidArgumentException
  */
 public function execute(array $args, array $options = [])
 {
     if (!isset($args[0])) {
         throw new \InvalidArgumentException('arg action must be input');
     }
     $action = explode('::', $args[0]);
     if (!class_exists($action[0])) {
         throw new \InvalidArgumentException('action not not found!');
     }
     if (isset($args[1])) {
         $frequency = abs(intval($args[1]));
     } else {
         $frequency = null;
     }
     ProcessManage::addTask($action, $frequency);
 }