FileHooks   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
dl 0
loc 23
rs 10
c 1
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 2 1
A deleteTrack() 0 10 2
1
<?php
2
/**
3
 * Audio Player
4
 *
5
 * This file is licensed under the Affero General Public License version 3 or
6
 * later. See the LICENSE.md file.
7
 *
8
 * @author Marcel Scherello <[email protected]>
9
 * @copyright 2016-2020 Marcel Scherello
10
 */
11
 
12
namespace OCA\audioplayer\Hooks;
13
use OCA\audioplayer\Controller;
14
use \OCP\Files\FileInfo;
15
use OCP\ILogger;
16
17
class FileHooks {
18
19
    private $logger;
20
21
    public function __construct(ILogger $logger) {
22
        $this->logger = $logger;
23
    }
24
25
    /**
26
     * delete track from library after file deletion
27
     * @param array $params
28
     * @throws \OCP\AppFramework\QueryException
29
     */
30
	public static function deleteTrack($params) {
31
32
		$view = \OC\Files\Filesystem::getView();
33
		$node = $view->getFileInfo($params['path']);
34
35
        #$this->logger->debug('Hook delete id: '.$node->getId(), array('app' => 'audioplayer'));
36
		if ($node->getType() === FileInfo::TYPE_FILE) {
37
			$app = new \OCA\audioplayer\AppInfo\Application();
38
        	$container = $app->getContainer();
39
            $container->query(\OCA\audioplayer\Controller\DbController::class)->deleteFromDB($node->getId());
40
		}
41
	}    
42
}
43