Skip to content

Commit

Permalink
Merge pull request #28103 from colemanw/tagIndividuals
Browse files Browse the repository at this point in the history
APIv4 - Fix missing tag filer on Individual,Organization,Household
  • Loading branch information
demeritcowboy authored Nov 13, 2023
2 parents 93f9988 + 45db313 commit 3d1357f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ public function applies($entity, $action) {
if ($action !== 'get') {
return FALSE;
}
if (CoreUtil::isContact($entity)) {
return TRUE;
}
$usedFor = \CRM_Core_OptionGroup::values('tag_used_for', FALSE, FALSE, FALSE, NULL, 'name');
return in_array($entity, $usedFor, TRUE);
}
Expand Down
3 changes: 2 additions & 1 deletion tests/phpunit/api/v4/Entity/TagTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use Civi\Api4\Contact;
use api\v4\Api4TestBase;
use Civi\Api4\EntityTag;
use Civi\Api4\Individual;
use Civi\Api4\Tag;
use Civi\Test\TransactionalInterface;

Expand Down Expand Up @@ -79,7 +80,7 @@ public function testTagFilter(): void {
$this->assertCount(1, $shouldReturnContact1);
$this->assertEquals($contact1['id'], $shouldReturnContact1->first()['id']);

$shouldReturnContact2 = Contact::get(FALSE)
$shouldReturnContact2 = Individual::get(FALSE)
->addSelect('id')
->addWhere('tags', 'IN', [$setChild['id']])
->execute();
Expand Down

0 comments on commit 3d1357f

Please sign in to comment.