Declare task

Before using a task, you must define a task, and defining the task is simple. Set a task as follows:

 /**
 * Class TestTask
 *
 * @since 2.0
 *
 * @Task(name="testTask")
 */
class TestTask
{
    /**
     * @TaskMapping(name="list")
     *
     * @param int    $id
     * @param string $default
     *
     * @return array
     */
    public function getList(int $id, string $default = 'def'): array
    {
        return [
            'list'    => [1, 3, 3],
            'id'      => $id,
            'default' => $default
        ];
    }

    /**
     * @TaskMapping()
     *
     * @param int $id
     *
     * @return bool
     */
    public function delete(int $id): bool
    {
        if ($id > 10) {
            return true;
        }

        return false;
    }
}     

@Task

Tag class is a task

  • Name specifies the task name, the default full path class name

@TaskMapping

Map name

  • Name name mapping, default to the method name of the class

Each method that is marked by @Task is a task. If the method does not use the @TaskMapping annotation, it will not be resolved into a task.

/docs/2.x/en/task/statement.html
progress-bar