Skip to content

Commit

Permalink
Made the table field configurable.
Browse files Browse the repository at this point in the history
  • Loading branch information
Florian Krämer committed Nov 30, 2015
1 parent 50b4a40 commit 8262991
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/Model/Behavior/TagBehavior.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class TagBehavior extends Behavior
'implementedMethods' => [
'normalizeTags' => 'normalizeTags',
],
'fkTableField' => 'fk_table'
];

/**
Expand Down Expand Up @@ -103,7 +104,7 @@ public function bindAssociations()
$table = $this->_table;
$tableAlias = $this->_table->alias();

$assocConditions = [$taggedAlias . '.fk_table' => $table->table()];
$assocConditions = [$taggedAlias . '.' . $this->config('fkTableField') => $table->table()];

if (!$table->association($taggedAlias)) {
$table->hasMany($taggedAlias, $taggedAssoc + [
Expand Down Expand Up @@ -189,7 +190,7 @@ public function attachCounters()
if (!$counterCache->config($taggedAlias)) {
$field = key($config['taggedCounter']);
$config['taggedCounter']['tag_count']['conditions'] = [
$taggedTable->aliasField('fk_table') => $this->_table->table()
$taggedTable->aliasField($this->config('fkTableField')) => $this->_table->table()
];
$counterCache->config($this->_table->alias(), $config['taggedCounter']);
}
Expand All @@ -209,7 +210,7 @@ public function normalizeTags($tags)

$result = [];

$common = ['_joinData' => ['fk_table' => $this->_table->table()]];
$common = ['_joinData' => [$this->config('fkTableField') => $this->_table->table()]];
if ($namespace = $this->config('namespace')) {
$common += compact('namespace');
}
Expand Down

0 comments on commit 8262991

Please sign in to comment.