public function MigrateSourceYaml::__construct in Migrate Source YAML 7
Construct a new YAML source object.
Parameters
string $path: The system path to the YAML file.
string $list: The name of the list to import from. This list must be at the base of the YAML file.
array $fields: Optionally provide an array of fields where each key is the field name (as found in each item of the YAML list being imported) and the value being a description of the field. Use this to customise the description of any fields or to specify additional fields to be added to in prepareRow(). This may additionally be used where the first row of data doesn't contain all fields as this plugin only extracts names from the first row of data.
array $options: Optionally provide options as described in MigrateSource.
Overrides MigrateSource::__construct
File
- includes/
MigrateSourceYaml.inc, line 34 - Contains MigrateSourceYaml.
Class
- MigrateSourceYaml
- Migrate source class to import from a YAML file.
Code
public function __construct($path, $list, array $fields = array(), array $options = array()) {
parent::__construct($options);
$this->file = $path;
$this->list = $list;
$this->yamlParser = new Parser();
$this
->parse();
$this->fields = $fields;
foreach (reset($this->data) as $key => $field) {
if (!isset($this->fields[$key])) {
$this->fields[$key] = ucfirst($key);
}
}
}