function find_verse_tags($passage) { # Find verse $verse = find_verse($passage); # Get tags $tags = $verse->getTags(); # Handle tags foreach ($tags as $tag) { # Get keyword $keyword = $tag->getKeyword(); # Get keyword synonyms $keyword_synonyms = $keyword->getKeywordSynonyms(); unset($keyword_synonyms_array); foreach ($keyword_synonyms as $keyword_synonym) { $keyword_synonyms_array[] = ['value' => $keyword_synonym->getValue()]; } # Get type $tag_type = $tag->getTagType(); # Insert into tags array $tags_array[] = ['keyword' => ['synonyms' => $keyword_synonyms_array, 'value' => $keyword->getValue()], 'tag' => ['id' => $tag->getId(), 'type' => $tag_type->getValue()]]; } # Return tags return $tags_array; }
<?php # Include autoloader require_once 'vendor/autoload.php'; # Include config require_once 'generated-conf/config.php'; $verse = find_verse('Genesis 1:4'); $keyword = find_keyword('Jealousy'); $type = find_tag_type('instructs regarding'); $tag = new Tag(); $tag->setKeyword($keyword)->setTagType($type)->setVerse($verse)->save(); var_dump($tag->toArray());