File tree Expand file tree Collapse file tree 7 files changed +13
-23
lines changed Expand file tree Collapse file tree 7 files changed +13
-23
lines changed Original file line number Diff line number Diff line change @@ -22,16 +22,9 @@ abstract class AbstractEvent implements StoppableEventInterface
22
22
/**
23
23
* @param ActiveRecordInterface $model The target model associated with this event.
24
24
*/
25
- public function __construct (private readonly ActiveRecordInterface $ model )
26
- {
27
- }
28
-
29
- /**
30
- * @return ActiveRecordInterface The target model associated with this event.
31
- */
32
- public function getModel (): ActiveRecordInterface
33
- {
34
- return $ this ->model ;
25
+ public function __construct (
26
+ public readonly ActiveRecordInterface $ model ,
27
+ ) {
35
28
}
36
29
37
30
/**
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ final class AfterCreateQuery extends AbstractEvent
16
16
{
17
17
public function __construct (
18
18
ActiveRecordInterface $ model ,
19
- public ActiveQueryInterface & $ query ,
19
+ public readonly ActiveQueryInterface $ query ,
20
20
) {
21
21
parent ::__construct ($ model );
22
22
}
Original file line number Diff line number Diff line change 13
13
*/
14
14
final class BeforeCreateQuery extends AbstractEvent
15
15
{
16
- public function __construct (
17
- ActiveRecordInterface $ model ,
18
- ) {
19
- parent ::__construct ($ model );
20
- }
21
16
}
Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ public function getEventHandlers(): array
35
35
36
36
private function afterPopulate (AfterPopulate $ event ): void
37
37
{
38
- $ model = $ event ->getModel () ;
38
+ $ model = $ event ->model ;
39
39
$ value = is_callable ($ this ->value ) ? ($ this ->value )($ event ) : $ this ->value ;
40
40
41
41
foreach ($ this ->getPropertyNames () as $ propertyName ) {
Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ public function getEventHandlers(): array
36
36
37
37
private function beforeInsert (BeforeInsert $ event ): void
38
38
{
39
- $ model = $ event ->getModel () ;
39
+ $ model = $ event ->model ;
40
40
$ value = is_callable ($ this ->value ) ? ($ this ->value )($ event ) : $ this ->value ;
41
41
42
42
foreach ($ this ->getPropertyNames () as $ propertyName ) {
@@ -48,7 +48,7 @@ private function beforeInsert(BeforeInsert $event): void
48
48
49
49
private function beforeUpsert (BeforeUpsert $ event ): void
50
50
{
51
- $ model = $ event ->getModel () ;
51
+ $ model = $ event ->model ;
52
52
$ value = is_callable ($ this ->value ) ? ($ this ->value )($ event ) : $ this ->value ;
53
53
54
54
foreach ($ this ->getPropertyNames () as $ propertyName ) {
Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ public function getEventHandlers(): array
35
35
36
36
private function beforeUpdate (BeforeUpdate $ event ): void
37
37
{
38
- $ model = $ event ->getModel () ;
38
+ $ model = $ event ->model ;
39
39
$ value = is_callable ($ this ->value ) ? ($ this ->value )($ event ) : $ this ->value ;
40
40
41
41
foreach ($ this ->getPropertyNames () as $ propertyName ) {
@@ -47,7 +47,7 @@ private function beforeUpdate(BeforeUpdate $event): void
47
47
48
48
private function beforeUpsert (BeforeUpsert $ event ): void
49
49
{
50
- $ model = $ event ->getModel () ;
50
+ $ model = $ event ->model ;
51
51
$ value = is_callable ($ this ->value ) ? ($ this ->value )($ event ) : $ this ->value ;
52
52
53
53
$ updateProperties = match ($ event ->updateProperties ) {
Original file line number Diff line number Diff line change 10
10
use Yiisoft \ActiveRecord \Event \BeforeDelete ;
11
11
use Yiisoft \Db \QueryBuilder \Condition \Equals ;
12
12
13
+ use function is_callable ;
14
+
13
15
/**
14
16
* Attribute for implementing soft deletion in Active Record models. Instead of deleting records from the
15
17
* database, it sets a value of the date and time for properties to indicate that the record has been logically deleted.
@@ -43,7 +45,7 @@ public function getEventHandlers(): array
43
45
44
46
private function afterCreateQuery (AfterCreateQuery $ event ): void
45
47
{
46
- $ model = $ event ->getModel () ;
48
+ $ model = $ event ->model ;
47
49
$ tableName = $ model ->tableName ();
48
50
49
51
foreach ($ this ->getPropertyNames () as $ propertyName ) {
@@ -55,7 +57,7 @@ private function afterCreateQuery(AfterCreateQuery $event): void
55
57
56
58
private function beforeDelete (BeforeDelete $ event ): void
57
59
{
58
- $ model = $ event ->getModel () ;
60
+ $ model = $ event ->model ;
59
61
$ value = is_callable ($ this ->value ) ? ($ this ->value )($ event ) : $ this ->value ;
60
62
61
63
$ propertyValues = [];
You can’t perform that action at this time.
0 commit comments