Completed
Push — master ( 501bdd...affc69 )
by Iurii
02:06
created

Extractor::info()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 7
nc 1
nop 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A Extractor::__construct() 0 4 1
1
<?php
2
3
/**
4
 * @package GPL Cart core
5
 * @author Iurii Makukh <[email protected]>
6
 * @copyright Copyright (c) 2015, Iurii Makukh
7
 * @license https://www.gnu.org/licenses/gpl.html GNU/GPLv3
8
 */
9
10
namespace gplcart\modules\extractor;
11
12
use gplcart\core\Module;
13
14
/**
15
 * Main class for Extractor module
16
 */
17
class Extractor extends Module
18
{
19
20
    /**
21
     * Constructor
22
     */
23
    public function __construct()
24
    {
25
        parent::__construct();
26
    }
27
28
    /**
29
     * Implements hook "route.list"
30
     * @param array $routes
31
     */
32
    public function hookRouteList(array &$routes)
33
    {
34
        $routes['admin/tool/extract'] = array(
35
            'menu' => array('admin' => 'Extractor'),
36
            'handlers' => array(
37
                'controller' => array('gplcart\\modules\\extractor\\controllers\\Extract', 'editExtract')
38
            )
39
        );
40
    }
41
42
    /**
43
     * Implements hook "job.handlers"
44
     * @param array $handlers
45
     */
46
    public function hookJobHandlers(array &$handlers)
47
    {
48
        $handlers['extract'] = array(
49
            'handlers' => array(
50
                'process' => array('gplcart\\modules\\extractor\\handlers\\Extract', 'process')
51
            ),
52
        );
53
    }
54
55
    /**
56
     * Implements hook "cron"
57
     */
58
    public function hookCron()
59
    {
60
        // Automatically delete created files older than 1 day
61
        $lifespan = 86400;
62
        $directory = GC_PRIVATE_DOWNLOAD_DIR . '/extracted-translations';
63
        if (is_dir($directory)) {
64
            gplcart_file_delete($directory, array('csv'), $lifespan);
65
        }
66
    }
67
68
}
69