Skip to content
This repository has been archived by the owner on Oct 20, 2023. It is now read-only.

Commit

Permalink
Fixing to save tag with identifier.
Browse files Browse the repository at this point in the history
  • Loading branch information
okinaka committed Apr 18, 2014
1 parent d4c4e9e commit b378ddd
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions Model/Behavior/TaggableBehavior.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,15 @@ public function saveTags(Model $model, $string = null, $foreignKey = null, $upda
extract($this->disassembleTags($model, $string, $this->settings[$model->alias]['separator']));

if (!empty($tags)) {
$conditions = array('OR' => array_map(function ($tag) use ($tagModel) {
return array(
$tagModel->alias . '.identifier' => $tag['identifier'],
$tagModel->alias . '.keyname' => $tag['keyname'],
);
}, $tags));
$existingTags = $tagModel->find('all', array(
'contain' => array(),
'conditions' => array(
$tagModel->alias . '.keyname' => Set::extract($tags, '{n}.keyname')),
'conditions' => $conditions,
'fields' => array(
$tagModel->alias . '.identifier',
$tagModel->alias . '.keyname',
Expand Down

0 comments on commit b378ddd

Please sign in to comment.