Skip to content

Commit

Permalink
Try moving the filtering further up the API
Browse files Browse the repository at this point in the history
  • Loading branch information
seamuslee001 committed May 9, 2017
1 parent e2980d5 commit 6914092
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
14 changes: 6 additions & 8 deletions api/v3/Extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,11 @@ function civicrm_api3_extension_get($params) {
$result = array();
$id = 0;
foreach ($statuses as $key => $status) {
if (!empty($params['key'])) {
if (!in_array($key, $keys)) {
continue;
}
}
try {
$obj = $mapper->keyToInfo($key);
}
Expand All @@ -347,14 +352,7 @@ function civicrm_api3_extension_get($params) {
}
$info = CRM_Extension_System::createExtendedInfo($obj);
$info['id'] = $id++; // backward compatibility with indexing scheme
if (!empty($params['key'])) {
if (in_array($key, $keys)) {
$result[] = $info;
}
}
else {
$result[] = $info;
}
$result[] = $info;
}
$options = _civicrm_api3_get_options_from_params($params);
$returnFields = !empty($options['return']) ? $options['return'] : array();
Expand Down
4 changes: 2 additions & 2 deletions tests/phpunit/api/v3/ExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function testExtesnionGetSingleExtension() {
public function testSingleExtesnionGetWithReturnFields() {
$result = $this->callAPISuccess('extension', 'get', array('key' => 'test.extension.manager.moduletest', 'return' => array('name', 'status', 'key')));
$this->assertEquals('test.extension.manager.moduletest', $result['values'][$result['id']]['key']);
$this->assertNull($result['values'][$result['id']]['type']);
$this->assertFalse(isset($result['values'][$result['id']]['type']));
$this->assertEquals('test_extension_manager_moduletest', $result['values'][$result['id']]['name']);
$this->assertEquals('uninstalled', $result['values'][$result['id']]['status']);
}
Expand All @@ -84,7 +84,7 @@ public function testSingleExtesnionGetWithReturnFields() {
* Test Extension Get resturns detailed information
* CRM-20532
*/
public function testeExtesnionGet() {
public function testExtesnionGet() {
$result = $this->callAPISuccess('extension', 'get', array());
$angularResult = $this->callAPISuccess('extension', 'get', array('key' => 'org.civicrm.angularprofiles'));
$this->assertNotNull($result['values'][$angularResult['id']]['comments']);
Expand Down

0 comments on commit 6914092

Please sign in to comment.