This repository was archived by the owner on Mar 30, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPlugin.php
More file actions
57 lines (50 loc) · 1.43 KB
/
Plugin.php
File metadata and controls
57 lines (50 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
namespace Bedard\Prerender;
use Backend;
use Bedard\Prerender\Classes\PrerenderMiddleware;
use Event;
use GuzzleHttp\Client;
use System\Classes\PluginBase;
/**
* Prerender Plugin Information File
*/
class Plugin extends PluginBase
{
/**
* Boot method, called right before the request route.
*
* @return array
*/
public function boot()
{
if (config('bedard.prerender::enable')) {
// apply middleware to all routes
$kernel = $this->app['Illuminate\Contracts\Http\Kernel'];
$kernel->pushMiddleware(PrerenderMiddleware::class);
// register an event handler to recache urls
Event::listen('bedard.prerender.recache', function ($url) {
$client = new Client();
$client->request('POST', 'https://api.prerender.io/recache', [
'json' => [
'prerenderToken' => config('bedard.prerender::prerenderToken'),
'url' => $url,
],
]);
});
}
}
/**
* Returns information about this plugin.
*
* @return array
*/
public function pluginDetails()
{
return [
'author' => 'Scott Bedard',
'description' => 'Prerendering plugin for October CMS',
'icon' => 'icon-sitemap',
'name' => 'Prerender',
];
}
}