Skip to content

Example: Quest list (quests.xml)

Chris edited this page May 26, 2016 · 2 revisions

Options

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.

Syntax
new pandaac\Exporter\Parsers\Quests([
  'missions' => false,
  'states' => false,
])
Defaults
  • missions true
  • states true
    • Requires the missions option to be enabled

Example

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();

Example output (JSON)

[
  {
    "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"
        }
      }
    ]
  },

  ...
]

Clone this wiki locally