12
12
use Illuminate \Contracts \Mail \Mailer ;
13
13
use Illuminate \Support \Arr ;
14
14
use Illuminate \Support \Facades \Date ;
15
- use Illuminate \Support \Reflector ;
16
15
use Illuminate \Support \Stringable ;
17
16
use Illuminate \Support \Traits \Macroable ;
18
17
use Illuminate \Support \Traits \ReflectsClosures ;
23
22
24
23
class Event
25
24
{
26
- use Macroable, ManagesFrequencies, ReflectsClosures, Tappable;
25
+ use Macroable, ManagesAttributes, ManagesFrequencies, ReflectsClosures, Tappable;
27
26
28
27
/**
29
28
* The command string.
@@ -32,90 +31,6 @@ class Event
32
31
*/
33
32
public $ command ;
34
33
35
- /**
36
- * The cron expression representing the event's frequency.
37
- *
38
- * @var string
39
- */
40
- public $ expression = '* * * * * ' ;
41
-
42
- /**
43
- * How often to repeat the event during a minute.
44
- *
45
- * @var int|null
46
- */
47
- public $ repeatSeconds = null ;
48
-
49
- /**
50
- * The timezone the date should be evaluated on.
51
- *
52
- * @var \DateTimeZone|string
53
- */
54
- public $ timezone ;
55
-
56
- /**
57
- * The user the command should run as.
58
- *
59
- * @var string|null
60
- */
61
- public $ user ;
62
-
63
- /**
64
- * The list of environments the command should run under.
65
- *
66
- * @var array
67
- */
68
- public $ environments = [];
69
-
70
- /**
71
- * Indicates if the command should run in maintenance mode.
72
- *
73
- * @var bool
74
- */
75
- public $ evenInMaintenanceMode = false ;
76
-
77
- /**
78
- * Indicates if the command should not overlap itself.
79
- *
80
- * @var bool
81
- */
82
- public $ withoutOverlapping = false ;
83
-
84
- /**
85
- * Indicates if the command should only be allowed to run on one server for each cron expression.
86
- *
87
- * @var bool
88
- */
89
- public $ onOneServer = false ;
90
-
91
- /**
92
- * The number of minutes the mutex should be valid.
93
- *
94
- * @var int
95
- */
96
- public $ expiresAt = 1440 ;
97
-
98
- /**
99
- * Indicates if the command should run in the background.
100
- *
101
- * @var bool
102
- */
103
- public $ runInBackground = false ;
104
-
105
- /**
106
- * The array of filter callbacks.
107
- *
108
- * @var array
109
- */
110
- protected $ filters = [];
111
-
112
- /**
113
- * The array of reject callbacks.
114
- *
115
- * @var array
116
- */
117
- protected $ rejects = [];
118
-
119
34
/**
120
35
* The location that output should be sent to.
121
36
*
@@ -666,117 +581,6 @@ protected function getHttpClient(Container $container)
666
581
};
667
582
}
668
583
669
- /**
670
- * State that the command should run in the background.
671
- *
672
- * @return $this
673
- */
674
- public function runInBackground ()
675
- {
676
- $ this ->runInBackground = true ;
677
-
678
- return $ this ;
679
- }
680
-
681
- /**
682
- * Set which user the command should run as.
683
- *
684
- * @param string $user
685
- * @return $this
686
- */
687
- public function user ($ user )
688
- {
689
- $ this ->user = $ user ;
690
-
691
- return $ this ;
692
- }
693
-
694
- /**
695
- * Limit the environments the command should run in.
696
- *
697
- * @param array|mixed $environments
698
- * @return $this
699
- */
700
- public function environments ($ environments )
701
- {
702
- $ this ->environments = is_array ($ environments ) ? $ environments : func_get_args ();
703
-
704
- return $ this ;
705
- }
706
-
707
- /**
708
- * State that the command should run even in maintenance mode.
709
- *
710
- * @return $this
711
- */
712
- public function evenInMaintenanceMode ()
713
- {
714
- $ this ->evenInMaintenanceMode = true ;
715
-
716
- return $ this ;
717
- }
718
-
719
- /**
720
- * Do not allow the event to overlap each other.
721
- *
722
- * The expiration time of the underlying cache lock may be specified in minutes.
723
- *
724
- * @param int $expiresAt
725
- * @return $this
726
- */
727
- public function withoutOverlapping ($ expiresAt = 1440 )
728
- {
729
- $ this ->withoutOverlapping = true ;
730
-
731
- $ this ->expiresAt = $ expiresAt ;
732
-
733
- return $ this ->skip (function () {
734
- return $ this ->mutex ->exists ($ this );
735
- });
736
- }
737
-
738
- /**
739
- * Allow the event to only run on one server for each cron expression.
740
- *
741
- * @return $this
742
- */
743
- public function onOneServer ()
744
- {
745
- $ this ->onOneServer = true ;
746
-
747
- return $ this ;
748
- }
749
-
750
- /**
751
- * Register a callback to further filter the schedule.
752
- *
753
- * @param \Closure|bool $callback
754
- * @return $this
755
- */
756
- public function when ($ callback )
757
- {
758
- $ this ->filters [] = Reflector::isCallable ($ callback ) ? $ callback : function () use ($ callback ) {
759
- return $ callback ;
760
- };
761
-
762
- return $ this ;
763
- }
764
-
765
- /**
766
- * Register a callback to further filter the schedule.
767
- *
768
- * @param \Closure|bool $callback
769
- * @return $this
770
- */
771
- public function skip ($ callback )
772
- {
773
- $ this ->rejects [] = Reflector::isCallable ($ callback ) ? $ callback : function () use ($ callback ) {
774
- return $ callback ;
775
- };
776
-
777
- return $ this ;
778
- }
779
-
780
584
/**
781
585
* Register a callback to be called before the operation.
782
586
*
0 commit comments