class WormsAdapter implements LabelSourceAdapterContract

WoRMS label source adapter.

Constants

MAX_RESULTS

WoRMS limits their results to a maximum of 50. We use a loop to get more results for each "find" request. This is the number of maximum results that the loop will return to prevent too many requests.

Properties

protected SoapClient $client

SOAP client for the WoRMS webservice.

Methods

setSoapClient(SoapClient $client)

Set the SOAP client instance to use for requests.

SoapClient
getSoapClient()

Get the SOAP client instance to use for requests.

array
find(Request $request)

Find labels by scientific name.

array
create(int $id, Request $request)

Create the label (or labels) from the label source based on an API request.

bool
filterUnaccepted(object $item)

Returns true for accepted WoRMS items and false otherwise.

array
parseItem(object $item)

Parse a WoRMS item to the internal representation.

array
createSingleLabel(array $attributes)

Create (and save) a single label.

array
createRecursiveLabels(array $attributes)

Create (and save) a label and all WoRMS parents that don't already exist in the tree.

array
extractParents(object $hierarchy)

Extract the aphia IDs in correct ordering from a WoRMS classification hierarchy.

Details

at line 41
setSoapClient(SoapClient $client)

Set the SOAP client instance to use for requests.

Parameters

SoapClient $client

at line 51
SoapClient getSoapClient()

Get the SOAP client instance to use for requests.

Return Value

SoapClient

at line 70
array find(Request $request)

Find labels by scientific name.

Uses the getAphiaRecords function of the WoRMS web service. see: http://www.marinespecies.org/aphia.php?p=soap

Parameters

Request $request

Return Value

array

All labels of the label source that match the query

at line 138
array create(int $id, Request $request)

Create the label (or labels) from the label source based on an API request.

Required request parameters:

string name Name of the new label string color Color of the new label (like bada55) int source_id AphiaID of the new label in WoRMS int label_source_id ID of the WoRMS LabelSource

Optional request parameters:

bool recursive Specifies if all parent labels should be fetched and inserted, too. int parent_id ID of the parent label. Must not be present if recursive is present.

Parameters

int $id

Label tree ID

Request $request

Return Value

array

Array of Label objects that were created

at line 184
private bool filterUnaccepted(object $item)

Returns true for accepted WoRMS items and false otherwise.

Parameters

object $item

Return Value

bool

at line 195
private array parseItem(object $item)

Parse a WoRMS item to the internal representation.

Parameters

object $item

Return Value

array

at line 226
private array createSingleLabel(array $attributes)

Create (and save) a single label.

Parameters

array $attributes

All label attributes

Return Value

array

Array containing the single label

at line 248
private array createRecursiveLabels(array $attributes)

Create (and save) a label and all WoRMS parents that don't already exist in the tree.

Parameters

array $attributes

All label attributes

Return Value

array

Array containing all newly created labels

at line 306
private array extractParents(object $hierarchy)

Extract the aphia IDs in correct ordering from a WoRMS classification hierarchy.

Parameters

object $hierarchy

Return Value

array

Arrays with aphia_id and name of each label