1 | <?php |
||
12 | class FileTextExtractable extends DataExtension |
||
|
|||
13 | { |
||
14 | private static $db = array( |
||
15 | 'FileContentCache' => 'Text' |
||
16 | ); |
||
17 | |||
18 | private static $casting = array( |
||
19 | 'FileContent' => 'Text' |
||
20 | ); |
||
21 | |||
22 | private static $dependencies = array( |
||
23 | 'TextCache' => '%$FileTextCache' |
||
24 | ); |
||
25 | |||
26 | /** |
||
27 | * @var FileTextCache |
||
28 | */ |
||
29 | protected $fileTextCache = null; |
||
30 | |||
31 | /** |
||
32 | * |
||
33 | * @param FileTextCache $cache |
||
34 | */ |
||
35 | public function setTextCache(FileTextCache $cache) |
||
39 | |||
40 | /** |
||
41 | * @return FileTextCache |
||
42 | */ |
||
43 | public function getTextCache() |
||
47 | |||
48 | /** |
||
49 | * Helper function for template |
||
50 | * |
||
51 | * @return string |
||
52 | */ |
||
53 | public function getFileContent() |
||
57 | |||
58 | /** |
||
59 | * Tries to parse the file contents if a FileTextExtractor class exists to handle the file type, and returns the text. |
||
60 | * The value is also cached into the File record itself. |
||
61 | * |
||
62 | * @param boolean $disableCache If false, the file content is only parsed on demand. |
||
63 | * If true, the content parsing is forced, bypassing the cached version |
||
64 | * @return string |
||
65 | */ |
||
66 | public function extractFileAsText($disableCache = false) |
||
90 | |||
91 | public function onBeforeWrite() |
||
96 | } |
||
97 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.