-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
46 lines (31 loc) · 1.34 KB
/
Copy pathindex.php
File metadata and controls
46 lines (31 loc) · 1.34 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
<?php
if (!defined('LYCHEE')) exit('Error: Direct access is not allowed!');
class UpdateMetadataPlugin implements SplObserver {
private $database = null;
private $settings = null;
public function __construct($database, $settings) {
# These params are passed to your plugin from Lychee
# Save them to access the database and settings of Lychee
$this->database = $database;
$this->settings = $settings;
# Add more code here if wanted
# __construct() will be called every time Lychee gets called
# Make sure this part is performant
return true;
}
public function update(\SplSubject $subject) {
# Check if the called hook is the hook you are waiting for
# A list of all hooks is available online
if ($subject->action == 'Photo::setTags:after' || $subject->action == 'Photo::setTags:before') {
error_log("Setting tags: {$subject->action}: ". print_r($subject, true));
return true;
}
# Do something when Photo::add:before gets called
# $this->database => The database of Lychee
# $this->settings => The settings of Lychee
# $subject->args => Params passed to the original function
return true;
}
}
# Register your plugin
$plugins->attach(new UpdateMetadataPlugin($database, $settings));