-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModule.php
More file actions
47 lines (42 loc) · 1.3 KB
/
Module.php
File metadata and controls
47 lines (42 loc) · 1.3 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
<?php
namespace Floxim\Main;
use \Floxim\Floxim\System\Fx as fx;
class Module extends \Floxim\Floxim\Component\Module\Entity {
public function init()
{
$this->handleLinkers();
$this->handleThumbs();
}
protected function handleLinkers()
{
fx::listen('after_delete', function($e) {
$entity = $e['entity'];
if (!$entity->isInstanceOf('floxim.main.content') || $entity->isInstanceOf('floxim.main.linker')) {
return;
}
$linkers = fx::data('floxim.main.linker')->where('linked_id', $entity['id'])->all();
$linkers->apply(function($l) {
$l->delete();
});
});
}
protected function handleThumbs()
{
fx::listen('unlink', function($e) {
$f = $e['file'];
if (fx::files()->isMetaFile($f)) {
return;
}
if (fx::path()->isInside($f, fx::path('@thumbs')) ) {
return;
}
if (!fx::path()->isInside($f, fx::path('@content_files')) ) {
return;
}
$thumbs = \Floxim\Floxim\System\Thumb::findThumbs($f);
foreach ($thumbs as $thumb) {
fx::files()->rm($thumb);
}
});
}
}