Update returned data from Dictionary->getDetails()

This commit is contained in:
Robbie Antenesse 2019-05-21 17:01:48 -06:00
parent 62dad867e0
commit 1369fb0fdb
1 changed files with 14 additions and 5 deletions

View File

@ -84,17 +84,26 @@ VALUES ($new_id, ?, ?, ?, ?)";
$result = $this->db->query($query)->fetch();
if ($result) {
// Default json values in case they are somehow not created by front end first
$partsOfSpeech = $result['parts_of_speech'] !== '' ? json_decode($result['parts_of_speech']) : $this->defaults['partsOfSpeech'];
$phonology = $result['phonology'] !== '' ? json_decode($result['phonology']) : $this->defaults['phonology'];
$partsOfSpeech = $result['parts_of_speech'] !== '' ? $result['parts_of_speech'] : $this->defaults['partsOfSpeech'];
return array(
'id' => $result['id'],
'externalId' => $this->token->hash($result['id']),
'name' => $result['name'],
'specification' => $result['specification'],
'description' => $result['description'],
'partsOfSpeech' => $partsOfSpeech,
'details' => array(
'phonology' => $phonology,
'phonology' => array(
'consonants' => $result['consonants'] !== '' ? explode(' ', $result['consonants']) : array(),
'vowels' => $result['vowels'] !== '' ? explode(' ', $result['vowels']) : array(),
'blends' => $result['blends'] !== '' ? explode(' ', $result['blends']) : array(),
'phonotactics' => array(
'onset' => $result['onset'] !== '' ? explode(',', $result['onset']) : array(),
'nucleus' => $result['nucleus'] !== '' ? explode(',', $result['nucleus']) : array(),
'coda' => $result['coda'] !== '' ? explode(',', $result['coda']) : array(),
'exceptions' => $result['parts_of_speech'],
),
),
'orthography' => array(
'notes' => $result['orthography_notes'],
),