Habari\Term::associate PHP Метод

associate() публичный Метод

Associate this term to an object of a certain type via its id.
public associate ( $type, $id )
$type string. The name of the object type we want to set an association for
$id integer. The object's id
    public function associate($type, $id)
    {
        $result = true;
        $type_id = Vocabulary::object_type_id($type);
        Plugins::act('term_associate_to_object_before', $this->id, $id, $type_id);
        if (!DB::exists("{object_terms}", array('term_id' => $this->id, 'object_id' => $id, 'object_type_id' => $type_id))) {
            $result = DB::insert("{object_terms}", array('term_id' => $this->id, 'object_id' => $id, 'object_type_id' => $type_id));
        }
        Plugins::act('term_associate_to_object_after', $this->id, $id, $type_id);
        return $result;
    }