|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Printful\GettextCms\Structures; |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* Class represents configuration for scanning a directory or a single file for translation messages |
|
7
|
|
|
*/ |
|
8
|
|
|
class ScanItem |
|
9
|
|
|
{ |
|
10
|
|
|
/** |
|
11
|
|
|
* Path to a directory or a file to scan |
|
12
|
|
|
* @var string |
|
13
|
|
|
*/ |
|
14
|
|
|
public $path; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* File extensions to scan. |
|
18
|
|
|
* Missing value means all supported files will be scanned. |
|
19
|
|
|
* |
|
20
|
|
|
* @var string[] |
|
21
|
|
|
*/ |
|
22
|
|
|
public $extensions = null; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* List of functions to scan for |
|
26
|
|
|
* Format is: [ custom-function => gettext-function, ..] |
|
27
|
|
|
* For example: [translate => gettext, translatePlural => ngettext] |
|
28
|
|
|
* |
|
29
|
|
|
* Default values can be found here, for example: |
|
30
|
|
|
* @see \Gettext\Extractors\JsCode::$options |
|
31
|
|
|
* @see \Gettext\Extractors\PhpCode::$options |
|
32
|
|
|
* |
|
33
|
|
|
* @var array If null, we use default functions from Gettext library (standard gettext functions) |
|
34
|
|
|
*/ |
|
35
|
|
|
public $functions = null; |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* Scan directory recursively |
|
39
|
|
|
* @var bool |
|
40
|
|
|
*/ |
|
41
|
|
|
public $recursive; |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* @param string $path Path to a directory or a file to scan |
|
45
|
|
|
* @param array $extensions List of extensions to scan for |
|
46
|
|
|
* @param bool $recursive Scan directory recursively |
|
47
|
|
|
* @param array|null $functions Functions that should be scanned for additionally, format: [customFunction => gettext|dgettext|..]] |
|
48
|
|
|
* |
|
49
|
|
|
* @see ScanItem::$functions |
|
50
|
|
|
*/ |
|
51
|
16 |
|
public function __construct($path, array $extensions = null, $recursive = true, array $functions = null) |
|
52
|
|
|
{ |
|
53
|
16 |
|
$this->path = $path; |
|
54
|
16 |
|
$this->extensions = $extensions; |
|
55
|
16 |
|
$this->recursive = $recursive; |
|
56
|
16 |
|
$this->functions = $functions; |
|
57
|
|
|
} |
|
58
|
|
|
} |