-
Notifications
You must be signed in to change notification settings - Fork 3
Example: Quest list (quests.xml)
Chris edited this page May 26, 2016
·
2 revisions
The parser implementation (pandaac\Exporter\Parsers\Quests in this case) accepts an array of options as its first parameter. By default they are as shown below, but you may pass either of them to change it.
new pandaac\Exporter\Parsers\Quests([
'missions' => false,
'states' => false,
])-
missions
true -
states
true- Requires the
missionsoption to be enabled
- Requires the
use pandaac\Exporter\Exporter;
use pandaac\Exporter\Parsers\Quests;
try {
$quests = new Exporter(
'./data/XML/quests.xml',
new Quests
);
$response = $quests->export();
} catch (Exception $e) {
// Log errors...
}The export() method returns a Illuminate\Support\Collection object, please refer to its documentation. If you would prefer a JSON or an array response however, you may do as follows...
$response = $quests->export()->toJson();$response = $quests->export()->toArray();[
{
"name": "Example Quest I",
"startstorageid": 1001,
"startstoragevalue": 1,
"missions": [
{
"name": "Example Mission 1",
"storageid": 1001,
"startvalue": 1,
"endvalue": 3,
"states": {
"1": "Example description 1",
"2": "Example description 2",
"3": "Example description 3"
}
},
{
"name": "Example Mission 2",
"storageid": 1001,
"startvalue": 4,
"endvalue": 5,
"states": {
"4": "Example description 1",
"5": "Example description 2"
}
}
]
},
...
]