File tree Expand file tree Collapse file tree 4 files changed +53
-2
lines changed Expand file tree Collapse file tree 4 files changed +53
-2
lines changed Original file line number Diff line number Diff line change @@ -155,6 +155,13 @@ $crontabJob->setEnabled(false);
155
155
This will prepend your cron job with a ` # ` in your
156
156
crontab when persisting it.
157
157
158
+ ### Write your own adapter
159
+ Additionally, if you cannot read another user's crontabs or if you are on a distributed architecture where crons are not
160
+ run on the machine executing the jobs, you can create any other Adapter for your architecture
161
+ by implementing the ` CrontabAdapterInterface ` .
162
+
163
+ You can then instantiate the ` CrontabRepository ` with your adapter.
164
+
158
165
Unit tests
159
166
----------
160
167
Original file line number Diff line number Diff line change 24
24
*
25
25
* @author TiBeN
26
26
*/
27
- class CrontabAdapter
27
+ class CrontabAdapter implements CrontabAdapterInterface
28
28
{
29
29
private $ userName ;
30
30
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ /*
4
+ * Copyright 2013 Benjamin Legendre
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+
19
+ namespace TiBeN \CrontabManager ;
20
+
21
+ /**
22
+ * Crontab adapter.
23
+ * Retrieve and write cron jobs data using the "crontab" command line.
24
+ *
25
+ * @author TiBeN
26
+ */
27
+ interface CrontabAdapterInterface
28
+ {
29
+
30
+ /**
31
+ * Read the crontab and return
32
+ * raw data
33
+ *
34
+ * @return String $output the crontab raw data
35
+ */
36
+ public function readCrontab ();
37
+
38
+ /**
39
+ * Write the raw crontab data to the crontab.
40
+ *
41
+ * @param String $crontabRawData
42
+ */
43
+ public function writeCrontab ($ crontabRawData );
44
+ }
Original file line number Diff line number Diff line change @@ -55,7 +55,7 @@ class CrontabRepository
55
55
*
56
56
* @param CrontabAdapter $crontabAdapter
57
57
*/
58
- public function __construct (CrontabAdapter $ crontabAdapter )
58
+ public function __construct (CrontabAdapterInterface $ crontabAdapter )
59
59
{
60
60
$ this ->crontabAdapter = $ crontabAdapter ;
61
61
$ this ->readCrontab ();
You can’t perform that action at this time.
0 commit comments