1 | <?php |
||
3 | class CMSTricksCsvBulkLoader extends CsvBulkLoader |
||
|
|||
4 | { |
||
5 | |||
6 | /** |
||
7 | * Map columns to DataObject-properties. |
||
8 | * If not specified, we assume the first row |
||
9 | * in the file contains the column headers. |
||
10 | * The order of your array should match the column order. |
||
11 | * |
||
12 | * The column count should match the count of array elements, |
||
13 | * fill with NULL values if you want to skip certain columns. |
||
14 | * |
||
15 | * You can also combine {@link $hasHeaderRow} = true and {@link $columnMap} |
||
16 | * and omit the NULL values in your map. |
||
17 | * |
||
18 | * Supports one-level chaining of has_one relations and properties with dot notation |
||
19 | * (e.g. Team.Title). The first part has to match a has_one relation name |
||
20 | * (not necessarily the classname of the used relation). |
||
21 | * |
||
22 | * <code> |
||
23 | * <?php |
||
24 | * // simple example |
||
25 | * array( |
||
26 | * 'Title', |
||
27 | * 'Birthday' |
||
28 | * ) |
||
29 | * |
||
30 | * // complex example |
||
31 | * array( |
||
32 | * 'first name' => 'FirstName', // custom column name |
||
33 | * null, // ignored column |
||
34 | * 'RegionID', // direct has_one/has_many ID setting |
||
35 | * 'OrganisationTitle', // create has_one relation to existing record using $relationCallbacks |
||
36 | * 'street' => 'Organisation.StreetName', // match an existing has_one or create one and write property. |
||
37 | * ); |
||
38 | * ?> |
||
39 | * </code> |
||
40 | * |
||
41 | * @var array |
||
42 | */ |
||
43 | public $columnMap = array(); |
||
44 | |||
45 | /** |
||
46 | * Find a has_one relation based on a specific column value. |
||
47 | * |
||
48 | * <code> |
||
49 | * <?php |
||
50 | * array( |
||
51 | * 'OrganisationTitle' => array( |
||
52 | * 'relationname' => 'Organisation', // relation accessor name |
||
53 | * 'callback' => 'getOrganisationByTitle', |
||
54 | * ); |
||
55 | * ); |
||
56 | * ?> |
||
57 | * </code> |
||
58 | * |
||
59 | * @var array |
||
60 | */ |
||
61 | public $relationCallbacks = array(); |
||
62 | |||
63 | /** |
||
64 | * Specifies how to determine duplicates based on one or more provided fields |
||
65 | * in the imported data, matching to properties on the used {@link DataObject} class. |
||
66 | * Alternatively the array values can contain a callback method (see example for |
||
67 | * implementation details). The callback method should be defined on the source class. |
||
68 | * |
||
69 | * NOTE: If you're trying to get a unique Member record by a particular field that |
||
70 | * isn't Email, you need to ensure that Member is correctly set to the unique field |
||
71 | * you want, as it will merge any duplicates during {@link Member::onBeforeWrite()}. |
||
72 | * |
||
73 | * {@see Member::set_unique_identifier_field()}. |
||
74 | * |
||
75 | * If multiple checks are specified, the first one "wins". |
||
76 | * |
||
77 | * <code> |
||
78 | * <?php |
||
79 | * array( |
||
80 | * 'customernumber' => 'ID', |
||
81 | * 'phonequestionnaire_fieldsnumber' => array( |
||
82 | * 'callback' => 'getByImportedPhoneNumber' |
||
83 | * ) |
||
84 | * ); |
||
85 | * ?> |
||
86 | * </code> |
||
87 | * |
||
88 | * @var array |
||
89 | */ |
||
90 | public $duplicateChecks = array( |
||
91 | 'Code' => 'Code' |
||
92 | ); |
||
93 | |||
94 | /** |
||
95 | * @var Boolean $clearBeforeImport Delete ALL records before importing. |
||
96 | */ |
||
97 | public $deleteExistingRecords = false; |
||
98 | |||
99 | /** |
||
100 | * Each row in the imported dataset should map to one instance |
||
101 | * of this class (with optional property translation |
||
102 | * through {@self::$columnMaps}. |
||
103 | * |
||
104 | * @var string |
||
105 | */ |
||
106 | public $objectClass = ""; |
||
107 | |||
108 | |||
109 | /** |
||
110 | * Override this on subclasses to give the specific functions names. |
||
111 | * |
||
112 | * @var string |
||
113 | */ |
||
114 | public static $title = "Import Stuff"; |
||
115 | |||
116 | |||
117 | /** |
||
118 | * Delimiter character (Default: comma). |
||
119 | * |
||
120 | * @var string |
||
121 | */ |
||
122 | public $delimiter = ','; |
||
123 | |||
124 | /** |
||
125 | * Enclosure character (Default: doublequote) |
||
126 | * |
||
127 | * @var string |
||
128 | */ |
||
129 | public $enclosure = '"'; |
||
130 | |||
131 | /** |
||
132 | * Identifies if the has a header row. |
||
133 | * @var boolean |
||
134 | */ |
||
135 | public $hasHeaderRow = true; |
||
136 | |||
137 | |||
138 | public function getExportExampleData() |
||
145 | } |
||
146 |
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.