SubmissionNativeXmlFilter::addControlledVocabulary PHP Method

addControlledVocabulary() public method

Add submission controlled vocabulary to its DOM element.
public addControlledVocabulary ( $doc, $submissionNode, $controlledVocabulariesNodeName, $controlledVocabularyNodeName, $controlledVocabulary )
$doc DOMDocument
$submissionNode DOMElement
$controlledVocabulariesNodeName string Parent node name
$controlledVocabularyNodeName string Item node name
$controlledVocabulary array Associative array (locale => array of items)
    function addControlledVocabulary($doc, $submissionNode, $controlledVocabulariesNodeName, $controlledVocabularyNodeName, $controlledVocabulary)
    {
        $deployment = $this->getDeployment();
        $locales = array_keys($controlledVocabulary);
        foreach ($locales as $locale) {
            if (!empty($controlledVocabulary[$locale])) {
                $controlledVocabulariesNode = $doc->createElementNS($deployment->getNamespace(), $controlledVocabulariesNodeName);
                $controlledVocabulariesNode->setAttribute('locale', $locale);
                foreach ($controlledVocabulary[$locale] as $controlledVocabularyItem) {
                    $controlledVocabulariesNode->appendChild($node = $doc->createElementNS($deployment->getNamespace(), $controlledVocabularyNodeName, htmlspecialchars($controlledVocabularyItem, ENT_COMPAT, 'UTF-8')));
                }
                $submissionNode->appendChild($controlledVocabulariesNode);
            }
        }
    }