Skip to content

Commit

Permalink
Renamed option in CounterCache from finderType to finder
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed Aug 22, 2014
1 parent 190f10f commit 06f727e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions src/Model/Behavior/CounterCacheBehavior.php
Expand Up @@ -54,7 +54,7 @@
* [
* 'Users' => [
* 'posts_published' => [
* 'findType' => 'published' // Will be using findPublished()
* 'finder' => 'published' // Will be using findPublished()
* ]
* ]
* ]
Expand Down Expand Up @@ -177,17 +177,17 @@ protected function _processAssociation(Event $event, Entity $entity, Association
* @return int The number of relations matching the given config and conditions
*/
protected function _getCount(array $config, array $conditions) {
$findType = 'all';
if (!empty($config['findType'])) {
$findType = $config['findType'];
unset($config['findType']);
$finder = 'all';
if (!empty($config['finder'])) {
$finder = $config['finder'];
unset($config['finder']);
}

if (!isset($config['conditions'])) {
$config['conditions'] = [];
}
$config['conditions'] = array_merge($conditions, $config['conditions']);
$query = $this->_table->find($findType, $config);
$query = $this->_table->find($finder, $config);

return $query->count();
}
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Model/Behavior/CounterCacheBehaviorTest.php
Expand Up @@ -166,7 +166,7 @@ public function testCustomFind() {
$this->post->addBehavior('CounterCache', [
'Users' => [
'posts_published' => [
'findType' => 'published'
'finder' => 'published'
]
]
]);
Expand Down

0 comments on commit 06f727e

Please sign in to comment.