Go through the list of public tags and assign them to this object.

@param array $data JSON data from Hail
19651
protected function processPublicTags($data)
    {
        $tagIdList = [];
        // Clean tags before importing the new ones
        // but have not been returned this time around
        $this->PublicTags()->removeAll();
        foreach ($data as $tagData) {
            $tagIdList[] = $tagData['id'];

            // Find a matching HailTag or create an new one
            $tag = PublicTag::get()->filter(['HailID' => $tagData['id']])->first();

            if (!$tag) {
                $tag = new PublicTag();
            }

            $tag->OrganisationID = $this->OrganisationID;
            $tag->HailOrgID = $this->HailOrgID;
            $tag->HailOrgName = $this->HailOrgName;

            // Update the PublicTags
            $tag->importHailData($tagData);
            if (!$this->PublicTags()->byID($tag->ID)) {
                $this->PublicTags()->add($tag);
            }
        }

    }
412637
public function populate($data = array())
    {
        if (isset($data['name']) && $data['name'] !== null) {
            $this->name = $data['name'];
        }
        if (isset($data['code']) && $data['code'] !== null) {
            $this->code = $data['code'];
        }
        if (isset($data['phase']) && $data['phase'] !== null) {
            $this->phase = $data['phase'];
        }
        if (isset($data['active']) && $data['active'] !== null) {
            $this->active = $data['active'];
        }
    }
437957
public function setFromArray(array $data): void
	{
		foreach ($data as $parameter => $value) {
			$this->bindings[$parameter] = new Bind($parameter, $value);
		}
	}
475130
private function ensurePlaceholders(array &$data)
    {
        //Let's force placeholders for every sub loaded
        foreach ($this->nodes as $name => $node) {
            $data[$name] = $node instanceof ArrayInterface ? [] : null;
        }
    }
408769
public function tagData(array $tags, $data, User $user = null, $replace = false)
    {
        $taggedObjects = [];
        $uniqueTags = [];

        foreach ($tags as $tag) {
            $value = trim($tag);

            if (!empty($value)) {
                $uniqueTags[strtolower($value)] = $value;
            }
        }
        $tagsList = [];

        foreach ($uniqueTags as $tagName) {
            $tagsList[$tagName] = $this->getOrCreateTag($tagName, $user);
        }

        foreach ($data as $objectData) {
            $objectId = $objectData['id'];
            $objectClass = $objectData['class'];
            $objectName = isset($objectData['name']) ? $objectData['name'] : null;

            if ($replace) {
                $this->removeUnusedTags($objectClass, $objectId, $tags);
            }

            foreach ($uniqueTags as $tagName) {
                $tag = $tagsList[$tagName];
                $taggedObject = null;

                if ($tag->getId()) {
                    $taggedObject = $this->getOneTaggedObjectByTagAndObject($tag, $objectId, $objectClass);
                }

                if (is_null($taggedObject)) {
                    $taggedObject = new TaggedObject();
                }

                $taggedObject->setTag($tag);
                $taggedObject->setObjectId($objectId);
                $taggedObject->setObjectClass($objectClass);
                $tag->addTaggedObject($taggedObject);

                if ($objectName) {
                    $taggedObject->setObjectName($objectName);
                }

                $this->om->persist($taggedObject);
                $taggedObjects[] = $taggedObject;
            }
        }

        $this->om->flush();

        return $taggedObjects;
    }
1242377
public function setJsonBody($data)
    {
        $body = json_encode($data, JSON_UNESCAPED_UNICODE);
        $this->setHeader('content-type', 'application/json');
        $this->setBody($body);
    }
367799
public function populate($data = array())
    {
        if (isset($data['title']) && $data['title'] != null) {
            $this->title = $data['title'];
        }

        if (isset($data['image']) && $data['image'] != null) {
            $this->image = $data['image'];
        }

        if (isset($data['area']) && $data['area'] != null) {
            $this->area = $data['area'];
        }

        if (isset($data['package']) && $data['package'] != null) {
            $this->package = $data['package'];
        }

        if (isset($data['theme']) && $data['theme'] != null) {
            $this->theme = $data['theme'];
        }

        if (isset($data['author']) && $data['author'] != null) {
            $this->author = $data['author'];
        }

        if (isset($data['is_active']) && $data['is_active'] != null) {
            $this->is_active = $data['is_active'];
        }
    }
982699
protected function process_quiz_slot_tags($data) {
        global $DB;

        $data = (object)$data;

        $data->slotid = $this->get_new_parentid('quiz_question_instance');
        if ($this->task->is_samesite() && $tag = core_tag_tag::get($data->tagid, 'id, name')) {
            $data->tagname = $tag->name;
        } else if ($tag = core_tag_tag::get_by_name(0, $data->tagname, 'id, name')) {
            $data->tagid = $tag->id;
        } else {
            $data->tagid = null;
            $data->tagname = $tag->name;
        }

        $DB->insert_record('quiz_slot_tags', $data);
    }
926389
public function applyData ( $data = NULL ) {
        if (NULL != $data && is_array( $data )) {
            foreach ($data as $propName => $propValue) {
                $this->assignValue( $propName, $propValue );
            }
        } else {
            $this->buildVars();
        }
    }
323346
public function prepareTagsForOutput(array $data) {
		$tags = [];

		foreach ($data as $tag) {
			if ($this->_config['namespace']) {
				$tags[] = $tag['namespace'] . $this->_config['separator'] . $tag['label'];
			} else {
				$tags[] = $tag['label'];
			}
		}

		if ($this->_config['strategy'] === 'array') {
			return $tags;
		}

		return implode($this->_config['delimiter'] . ' ', $tags);
	}
905141
protected function withBulk(array $data = [])
    {
        if (!$this->isArray($data)) {
            return;
        }

        foreach ($data['data'] as $index => $element) {
            $row = $this->data->addChild('row');

            $row->addAttribute('no', ++$index);

            foreach ($element as $key => $value) {
                $child = $row->addChild('FL', $value);

                $child->addAttribute('val', $key);
            }
        }
    }
692702
private function setMessages(array $data) : void
    {
        /**
         * @var string $name
         * @var array  $errors
         */
        foreach ($data as $name => $errors) {
            // Not sure if this can be optimized and create the DOMXPath only once.
            // At this point the dom is constantly changing.
            $xpath = new DOMXPath($this->document);
            // Get all elements with the name
            $nodeList = $xpath->query(sprintf('//*[@name="%1$s"] | //*[@data-input-name="%1$s"]', $name));

            if ($nodeList->length === 0) {
                // No element found for this element ???
                continue;
            }

            // Get first element only
            $node = $nodeList->item(0);

            /** @var DOMElement $parent */
            $parent = $node->parentNode;
            if (strpos($parent->getAttribute('class'), $this->cssHasErrorClass) === false) {
                // Set error class to parent
                $class = trim($parent->getAttribute('class') . ' ' . $this->cssHasErrorClass);
                $parent->setAttribute('class', $class);
            }

            // Inject error messages
            foreach ($errors as $code => $message) {
                $div = $this->document->createElement('div');
                $div->setAttribute('class', $this->cssErrorClass);
                $div->nodeValue = $message;
                $node->parentNode->insertBefore($div, $node->nextSibling);
            }

            /** @var DOMElement $node */
            foreach ($nodeList as $node) {
                // Set aria-invalid attribute on all elements
                $node->setAttribute('aria-invalid', 'true');
            }
        }
    }
234009
private function parseData(array $data)
    {
        $this->type = array_get($data, 'data.type');
        $this->id = array_get($data, 'data.id');

        $this->attributes = array_get($data, 'data.attributes');

        $this->version = array_get($data, 'jsonapi.version', $this->version);

        $this->meta = array_get($data, 'meta');
    }
555268
public function setData(array $data)
    {
        if (isset($data['attachables'])) {
            $this->setAttachables($data['attachables']);
        }

        if (isset($data['groups'])) {
            $this->setGroups($data['groups']);
        }

        if (isset($data['widgets'])) {
            $this->setWidgets($data['widgets']);
        }

        unset($data['attachables'], $data['groups'], $data['widgets']);

        return parent::setData($data);
    }
175377
public function setData($data)
    {
        // Encode <, >, ', &, and " for RFC4627-compliant JSON, which may also be embedded into HTML.
        $this->data = json_encode($data, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT);
    }
1327990
public function populate($data = array())
    {
        $this->title = (isset($data['title'])) ? $data['title'] : null;
        $this->dynarea = (isset($data['dynarea'])) ? $data['dynarea'] : null;
        if (isset($data['is_active']) && $data['is_active'] != null) {
            $this->is_active = $data['is_active'];
        }
        if (isset($data['position']) && $data['position'] != null) {
            $this->position = $data['position'];
        }
        $this->identifier = (isset($data['identifier'])) ? $data['identifier'] : null;
        $this->type = (isset($data['type'])) ? $data['type'] : null;
    }
1373301
public function set_tags($tags) {
        $this->tags = [];
        foreach ($tags as $tag) {
            // We use $tag->id as the key for the array so not only it handles duplicates of the same tag being given,
            // but also it is consistent with the behaviour of set_tags_by_id() below.
            $this->tags[$tag->id] = $tag;
        }
    }