4
4
5
5
use System \Classes \PluginBase ;
6
6
use ABWebDevelopers \ImageResize \Classes \Resizer ;
7
+ use ABWebDevelopers \ImageResize \Commands \ImageResizeClear ;
8
+ use ABWebDevelopers \ImageResize \Commands \ImageResizeGc ;
7
9
use Event ;
8
10
9
11
class Plugin extends PluginBase
10
12
{
13
+ /**
14
+ * @inheritDoc
15
+ */
11
16
public function pluginDetails ()
12
17
{
13
18
return [
@@ -19,22 +24,30 @@ public function pluginDetails()
19
24
];
20
25
}
21
26
27
+ /**
28
+ * @inheritDoc
29
+ */
22
30
public function registerMarkupTags ()
23
31
{
24
32
return [
25
33
'filters ' => [
26
34
'resize ' => function ($ image , $ width , $ height = null , $ options = []) {
27
35
$ resizer = new Resizer ((string ) $ image );
36
+
28
37
return $ resizer ->resize ((int ) $ width , (int ) $ height , (array ) $ options );
29
38
},
30
39
'modify ' => function ($ image , $ options = []) {
31
40
$ resizer = new Resizer ((string ) $ image );
41
+
32
42
return $ resizer ->resize (null , null , (array ) $ options );
33
43
}
34
44
]
35
45
];
36
46
}
37
47
48
+ /**
49
+ * @inheritDoc
50
+ */
38
51
public function registerSettings ()
39
52
{
40
53
return [
@@ -50,14 +63,20 @@ public function registerSettings()
50
63
]
51
64
];
52
65
}
53
-
66
+
67
+ /**
68
+ * @inheritDoc
69
+ */
54
70
public function registerPermissions ()
55
71
{
56
72
return [
57
73
'abwebdevelopers.imageresize.access_settings ' => ['tab ' => 'abwebdevelopers.imageresize::lang.permissions.tab ' , 'label ' => 'abwebdevelopers.imageresize::lang.permissions.access_settings ' ],
58
74
];
59
75
}
60
76
77
+ /**
78
+ * @inheritDoc
79
+ */
61
80
public function boot ()
62
81
{
63
82
Event::listen ('backend.page.beforeDisplay ' , function ($ controller , $ action , $ params ) {
@@ -70,4 +89,21 @@ public function boot()
70
89
}
71
90
});
72
91
}
92
+
93
+ /**
94
+ * @inheritDoc
95
+ */
96
+ public function register ()
97
+ {
98
+ $ this ->registerConsoleCommand ('imageresize:gc ' , ImageResizeGc::class);
99
+ $ this ->registerConsoleCommand ('imageresize:clear ' , ImageResizeClear::class);
100
+ }
101
+
102
+ /**
103
+ * @inheritDoc
104
+ */
105
+ public function registerSchedule ($ schedule )
106
+ {
107
+ $ schedule ->command ('imageresize:gc ' )->daily ();
108
+ }
73
109
}
0 commit comments