Handle field single term meta registration.

@param string $value
@param int    $term_id
427487
protected function saveTermSingleValue($value, int $term_id)
    {
        $previous = get_term_meta($term_id, $this->getName(), true);

        if (is_null($value) || empty($value)) {
            delete_term_meta($term_id, $this->getName());
        } elseif (empty($previous)) {
            add_term_meta($term_id, $this->getName(), $value, true);
        } else {
            update_term_meta($term_id, $this->getName(), $value, $previous);
        }
    }
883304
public function saveFields($term_id)
    {
        // No term or no fields
        if (!isset($term_id) || empty($term_id) || empty($this->fields)) {
            return;
        }

        // Check slug
        $slug = Request::post('taxonomy', '');

        // Check integrity
        if (empty($slug) || $slug !== $this->slug) {
            return;
        }

        // Remove action hook and add it again later for no infinite loop
        remove_action('created_'.$slug, [&$this, 'saveFields']);
        remove_action('edited_'.$slug, [&$this, 'saveFields']);

        /**
         * Fires for all term's fields.
         *
         * @var string $slug
         * @param int $term_id
         * @param array $fields
         */
        do_action('ol_zeus_termhook_save_'.$slug, $term_id, $this->fields);

        // Update all metas
        foreach ($this->fields as $field) {
            if (!$field) {
                continue;
            }

            // Build contents
            $ctn = (array) $field->getModel()->getContents();
            $hasId = (boolean) $field->getModel()->getHasId();

            // Check ID
            if ($hasId && (!isset($ctn['id']) || empty($ctn['id']))) {
                continue;
            }

            // Gets the value
            $value = Request::post($ctn['id'], null);

            // Check value
            if (is_null($value)) {
                $value = Option::getTermMeta($term_id, $slug.'-'.$ctn['id']);
            }

            /**
             * Filter the value content.
             *
             * @var string $current
             * @param int $term_id
             * @param string $option_name
             * @param object $value
             * @return object $value
             */
            $value = apply_filters('ol_zeus_termhook_save_'.$slug.'_field', $value, $term_id, $slug.'-'.$ctn['id']);

            // Updates meta
            Option::updateTermMeta($term_id, $slug.'-'.$ctn['id'], $value);
        }

        // Add back action hook again for no infinite loop
        add_action('created_'.$slug, [$this, 'saveFields'], 10, 2);
        add_action('edited_'.$slug, [$this, 'saveFields'], 10, 2);

        return true;
    }
591688
public function setInvoiceCorrectionMetadata(\AgentSIB\Diadoc\Api\Proto\Documents\InvoiceDocument\InvoiceCorrectionMetadata $value = null)
    {
        $this->InvoiceCorrectionMetadata = $value;
    }
1085747
public function setTerms($terms, $vocabulary_id = null)
    {
        $this->removeTerms($vocabulary_id);

        foreach ($terms as $term_id) {
            $this->addTerm($term_id);
        }
    }
384879
public function termGet(int $term_id)
    {
        $value = get_term_meta($term_id, $this->getName(), true);

        if (! empty($value)) {
            $this->setValue($value);
        }
    }
1019955
public static function setVal($metaKey, $elementKey, $elementId, $value)
    {
        $data = self::create()
            ->filterByMetaKey($metaKey)
            ->filterByElementKey($elementKey)
            ->filterByElementId($elementId)
            ->findOne()
        ;

        if (null === $data) {
            $data = new MetaData();
            $data->setMetaKey($metaKey);
            $data->setElementKey($elementKey);
            $data->setElementId($elementId);
        }

        $data->setValue($value);

        $data->save();
    }
1273361
protected function deleteLinked($field_value_id)
    {
        $this->db->delete('product_field', array('field_value_id' => $field_value_id));
        $this->db->delete('field_value_translation', array('field_value_id' => $field_value_id));
        $this->db->delete('file', array('entity' => 'field_value', 'entity_id' => $field_value_id));
    }
148612
protected function saveUserSingleValue($value, int $user_id)
    {
        $previous = get_user_meta($user_id, $this->getName(), true);

        if (is_null($value) || empty($value)) {
            delete_user_meta($user_id, $this->getName());
        } elseif (empty($previous)) {
            add_user_meta($user_id, $this->getName(), $value, true);
        } else {
            update_user_meta($user_id, $this->getName(), $value, $previous);
        }
    }
906788
public function metaboxSave($value, int $post_id)
    {
        $this->setValue($value);

        $previous = get_post_meta($post_id, $this->getName(), true);

        if (is_null($this->getValue()) || empty($this->getValue())) {
            delete_post_meta($post_id, $this->getName());
        } elseif (empty($previous)) {
            add_post_meta($post_id, $this->getName(), $this->getRawValue(), true);
        } else {
            update_post_meta($post_id, $this->getName(), $this->getRawValue(), $previous);
        }
    }
980844
public function setMeta($id, $name, $value, $field = 'value') {
        if (is_array($value)) {
            $value = json_encode($value, JSON_UNESCAPED_UNICODE);
        }

        return $this->updateMeta($id, $name, $field, $value);
    }
105666
public function setInvoiceCorrectionMetadata(\AgentSIB\Diadoc\Api\Proto\Events\EncryptedInvoiceCorrectionMetadata $value = null)
    {
        $this->InvoiceCorrectionMetadata = $value;
    }
1305546
def add_term(term, taxonomy, description, count)
      if term.respond_to?(:term_id)
        term_id = term.term_id
      else
        term_id = term.to_i
      end

      term_taxonomy = WPDB::TermTaxonomy.where(term_id: term_id, taxonomy: taxonomy).first
      unless term_taxonomy
        term_taxonomy = WPDB::TermTaxonomy.create(
          term_id: term_id,
          taxonomy: taxonomy,
          description: description,
          count: count
        )
      else
        term_taxonomy.count += count
      end

      add_termtaxonomy(term_taxonomy)
    end
270733
protected function saveUserMultipleValue($value, int $user_id)
    {
        $previous = get_user_meta($user_id, $this->getName(), false);

        if (is_null($value) || empty($value)) {
            delete_user_meta($user_id, $this->getName());
        } elseif (empty($previous) && is_array($value)) {
            array_walk($value, function ($val) use ($user_id) {
                add_user_meta($user_id, $this->getName(), $val, false);
            });
        } else {
            delete_user_meta($user_id, $this->getName());

            array_walk($value, function ($val) use ($user_id) {
                add_user_meta($user_id, $this->getName(), $val, false);
            });
        }
    }
66318
public function addAndTerm($term, $value)
    {
        //Trim spaces from the term
        $value = trim($value);

        //If the query isn't empty, add an AND
        if($this->query !== '')
        {
            $this->query .= ' AND ';
        }

        //Add the term to the query
        $this->query .= $term.':'.$value;
    }
1361511
static void register(final Object value) {
        synchronized (HashCodeBuilder.class) {
            if (getRegistry() == null) {
                REGISTRY.set(new HashSet<IDKey>());
            }
        }
        getRegistry().add(new IDKey(value));
    }
190047
public function delete($id)
    {
        $this->loadModel('Taxonomy.Terms');
        $term = $this->Terms->get($id);
        $this->Terms->addBehavior('Tree', ['scope' => ['vocabulary_id' => $term->vocabulary_id]]);
        $this->Terms->removeFromTree($term);

        if ($this->Terms->delete($term)) {
            $this->Flash->success(__d('taxonomy', 'Term successfully removed!'));
        } else {
            $this->Flash->danger(__d('taxonomy', 'Term could not be removed, please try again'));
        }

        $this->title(__d('taxonomy', 'Delete Term'));
        $this->redirect($this->referer());
    }
526403
public function addTerm($term_id)
    {
        TermContainer::findOrFail($term_id);

        // Cancel if the user wants to add the same term again
        if ($this->getTaxonomyQuery()->where('term_id', $term_id)->count()) {
            return;
        }

        $this->taxonomies()->attach($term_id);

        Cache::forget($this->getTaxonomyCacheKey());
    }