public function saveTags($attachment, $tags)
    {
        $newTags = [];
        foreach ($tags as $tag) {
            if (isset($this->config('tags')[$tag])) {
                $newTags[] = $tag;
                if ($this->config('tags')[$tag]['exclusive'] === true) {
                    $this->_clearTag($attachment, $tag);
                }
            }
        }

        $this->Attachments->patchEntity($attachment, ['tags' => $newTags]);
        return (bool)$this->Attachments->save($attachment);
    }
public function saveTags($attachment, $tags)
    {
        $newTags = [];
        foreach ($tags as $tag) {
            if (isset($this->config('tags')[$tag])) {
                $newTags[] = $tag;
                if ($this->config('tags')[$tag]['exclusive'] === true) {
                    $this->_clearTag($attachment, $tag);
                }
            }
        }

        $this->Attachments->patchEntity($attachment, ['tags' => $newTags]);
        return (bool)$this->Attachments->save($attachment);
    }
public function saveTags ( $ attachment , $ tags ) { $ newTags = [ ] ; foreach ( $ tags as $ tag ) { if ( isset ( $ this -> config ( 'tags' ) [ $ tag ] ) ) { $ newTags [ ] = $ tag ; if ( $ this -> config ( 'tags' ) [ $ tag ] [ 'exclusive' ] === true ) { $ this -> _clearTag ( $ attachment , $ tag ) ; } } } $ this -> Attachments -> patchEntity ( $ attachment , [ 'tags' => $ newTags ] ) ; return ( bool ) $ this -> Attachments -> save ( $ attachment ) ; }
method to save the tags of an attachment

@param  Attachments\Model\Entity\Attachment $attachment the attachment entity
@param  array $tags       array of tags
@return bool
method to save the tags of an attachment