@@ -60,18 +60,6 @@ class Controller extends Package
60
60
*/
61
61
protected $ pkgAutoloaderMapCoreExtensions = false ;
62
62
63
- /**
64
- * Package class autoloader registrations
65
- * The package install helper class, included with this boilerplate,
66
- * is activated by default.
67
- *
68
- * @see https://goo.gl/4wyRtH
69
- * @var array
70
- */
71
- protected $ pkgAutoloaderRegistries = [
72
- //'src/MyVendor/Statistics' => '\MyVendor\ConcreteStatistics'
73
- ];
74
-
75
63
/**
76
64
* The packages handle.
77
65
* Note that this must be unique in the
@@ -108,17 +96,9 @@ class Controller extends Package
108
96
* @var array
109
97
*/
110
98
protected $ providers = [
111
- // Register your concrete5 service providers here
112
99
'Concrete\Package\SeoUpdateServiceNotifier\Src\Providers\UpdateServiceNotifierServiceProvider ' ,
113
100
];
114
101
115
- /**
116
- * How often should we allow pinging?
117
- *
118
- * @var integer
119
- */
120
- protected $ rate_limit_ttl = 43200 ; // Every 12 hours
121
-
122
102
/**
123
103
* Register the packages defined service providers.
124
104
*
@@ -143,76 +123,8 @@ public function on_start()
143
123
// Register defined service providers
144
124
$ this ->registerServiceProviders ();
145
125
146
- // Plugin the event listeners.
147
- $ this ->addEventListeners ();
148
- }
149
-
150
- /**
151
- * Get the list of update service URLs to ping.
152
- *
153
- * @return array
154
- */
155
- protected function getUpdateServiceUrls ()
156
- {
157
- return [
158
- 'https://requestb.in/1i2ftut1 '
159
- ];
160
- }
161
-
162
- /**
163
- * Checks to see whether we should ping the update services.
164
- * Currently this only checks that we are not above our rate limit.
165
- *
166
- * @return boolean
167
- */
168
- protected function canPing ()
169
- {
170
- $ cache = Core::make ('cache/expensive ' );
171
- $ item = $ cache ->getItem ('seo.update.notifier.expiry ' );
172
-
173
- if ($ item ->isMiss ()) {
174
- $ item ->set (time () + $ this ->rate_limit_ttl , $ this ->rate_limit_ttl );
175
-
176
- return true ;
177
- }
178
-
179
- return false ;
180
- }
181
-
182
- /**
183
- * Notifys update services that a page has been added / updated
184
- * and should be (re)indexed.
185
- *
186
- * @param \Page $page [description]
187
- * @return boolean
188
- */
189
- protected function pingPage (\Page $ page )
190
- {
191
- if ($ this ->canPing ()) {
192
- $ notifier = \Core::make ('seo.update.notifier ' );
193
-
194
- return $ notifier ->ping (
195
- $ this ->getUpdateServiceUrls (),
196
- \Config::get ('concrete.site ' ),
197
- \View::url ('/ ' ),
198
- \View::url ($ page ->getCollectionPath ())
199
- );
200
- }
201
- }
202
-
203
- /**
204
- * Wires the page event listeners to the update service
205
- * notification service.
206
- *
207
- * @return void
208
- */
209
- public function addEventListeners ()
210
- {
211
- \Events::addListener ('on_page_version_approve ' , function ($ event ) {
212
- $ page_id = $ event ->getCollectionVersionObject ()->getCollectionID ();
213
- $ page = \Page::getById ($ page_id );
214
- $ this ->pingPage ($ page );
215
- });
126
+ // Listen for page approvals so we can ping the update services.
127
+ Core::make ('seo.update.notifier ' )->listen ();
216
128
}
217
129
218
130
/**
@@ -222,11 +134,13 @@ public function addEventListeners()
222
134
*/
223
135
public function install ()
224
136
{
225
- // Add your custom logic here that needs to be executed BEFORE package install.
226
-
227
137
$ pkg = parent ::install ();
228
138
229
- // Add your custom logic here that needs to be executed AFTER package install.
139
+ // Install the dashboard page.
140
+ $ sp = \Concrete \Core \Page \Single::add ('/dashboard/system/seo/notifications ' , $ pkg );
141
+ $ sp ->update ([
142
+ 'cName ' => 'Update Services ' ,
143
+ ]);
230
144
231
145
return $ pkg ;
232
146
}
@@ -238,11 +152,7 @@ public function install()
238
152
*/
239
153
public function upgrade ()
240
154
{
241
- // Add your custom logic here that needs to be executed BEFORE package install.
242
-
243
155
parent ::upgrade ();
244
-
245
- // Add your custom logic here that needs to be executed AFTER package upgrade.
246
156
}
247
157
248
158
/**
@@ -252,10 +162,6 @@ public function upgrade()
252
162
*/
253
163
public function uninstall ()
254
164
{
255
- // Add your custom logic here that needs to be executed BEFORE package uninstall.
256
-
257
165
parent ::uninstall ();
258
-
259
- // Add your custom logic here that needs to be executed AFTER package uninstall.
260
166
}
261
167
}
0 commit comments