File tree Expand file tree Collapse file tree 4 files changed +32
-1
lines changed Expand file tree Collapse file tree 4 files changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -104,10 +104,18 @@ class GetFile extends Task
104
104
}
105
105
```
106
106
107
+ Blade template:
108
+
107
109
``` blade
108
110
cat {{ $options() }} {{ $path }}
109
111
```
110
112
113
+ You can create a new instance of the Task using the static ` make() ` method:
114
+
115
+ ``` php
116
+ GetFile::make('/etc/hosts')->dispatch();
117
+ ```
118
+
111
119
## Task options
112
120
113
121
You may specify a timeout. By default, the timeout is based on the ` task-runner.default_timeout ` config value.
Original file line number Diff line number Diff line change @@ -156,11 +156,21 @@ public function pending(): PendingTask
156
156
return new PendingTask ($ this );
157
157
}
158
158
159
+ /**
160
+ * Returns a new PendingTask with this task.
161
+ *
162
+ * @return \ProtoneMedia\LaravelTaskRunner\PendingTask
163
+ */
164
+ public static function make (...$ arguments ): PendingTask
165
+ {
166
+ return (new static (...$ arguments ))->pending ();
167
+ }
168
+
159
169
/**
160
170
* Helper methods to create a new PendingTask.
161
171
*/
162
172
public static function __callStatic ($ name , $ arguments )
163
173
{
164
- return app ( static ::class )->pending ()->{$ name }(...$ arguments );
174
+ return ( new static )->pending ()->{$ name }(...$ arguments );
165
175
}
166
176
}
Original file line number Diff line number Diff line change @@ -14,6 +14,11 @@ class CustomTask extends Task
14
14
15
15
public $ someData = 'foo ' ;
16
16
17
+ public function __construct ($ someData = 'foo ' )
18
+ {
19
+ $ this ->someData = $ someData ;
20
+ }
21
+
17
22
public function someMethod ()
18
23
{
19
24
return 'bar ' ;
Original file line number Diff line number Diff line change 5
5
use Illuminate \Support \Facades \View ;
6
6
use Mockery ;
7
7
use ProtoneMedia \LaravelTaskRunner \Connection ;
8
+ use ProtoneMedia \LaravelTaskRunner \PendingTask ;
8
9
9
10
it ('can generate defaults based on the class name and configuration ' , function () {
10
11
$ task = new DemoTask ;
60
61
expect ($ task ->getScript ())->toBe ('baz foo bar ' );
61
62
});
62
63
64
+ it ('has a helper method to create the task fluently ' , function () {
65
+ $ task = CustomTask::make ('otherData ' );
66
+
67
+ expect ($ task )->toBeInstanceOf (PendingTask::class);
68
+ expect ($ task ->task ->someData )->toBe ('otherData ' );
69
+ });
70
+
63
71
it ('can create a pending task with a static method ' , function () {
64
72
$ pendingTask = DemoTask::inBackground ();
65
73
expect ($ pendingTask ->task )->toBeInstanceOf (DemoTask::class);
You can’t perform that action at this time.
0 commit comments