Skip to content

Commit

Permalink
Merge pull request #27174 from colemanw/examples
Browse files Browse the repository at this point in the history
APIv3 - Delete api examples
  • Loading branch information
demeritcowboy authored Aug 25, 2023
2 parents 6824c3a + 44def67 commit bde6db9
Show file tree
Hide file tree
Showing 319 changed files with 15 additions and 36,825 deletions.
38 changes: 0 additions & 38 deletions CRM/Admin/Page/APIExplorer.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,44 +87,6 @@ public function userContext() {
return 'civicrm/api';
}

/**
* AJAX callback to fetch examples.
*/
public static function getExampleFile() {
if (!empty($_GET['entity']) && strpos($_GET['entity'], '.') === FALSE) {
$examples = [];
$paths = self::uniquePaths();
foreach ($paths as $path) {
$dir = \CRM_Utils_File::addTrailingSlash($path) . 'api' . DIRECTORY_SEPARATOR . 'v3' . DIRECTORY_SEPARATOR . 'examples' . DIRECTORY_SEPARATOR . $_GET['entity'];
if (\CRM_Utils_File::isDir($dir)) {
foreach (scandir($dir) as $item) {
$item = str_replace('.ex.php', '', $item);
if ($item && strpos($item, '.') === FALSE) {
$examples[] = ['key' => $item, 'value' => $item];
}
}
}
}
CRM_Utils_JSON::output($examples);
}
if (!empty($_GET['file']) && strpos($_GET['file'], '.') === FALSE) {
$paths = self::uniquePaths();
$fileFound = FALSE;
foreach ($paths as $path) {
$fileName = \CRM_Utils_File::addTrailingSlash($path) . 'api' . DIRECTORY_SEPARATOR . 'v3' . DIRECTORY_SEPARATOR . 'examples' . DIRECTORY_SEPARATOR . $_GET['file'] . '.ex.php';
if (!$fileFound && file_exists($fileName)) {
$fileFound = TRUE;
echo file_get_contents($fileName);
}
}
if (!$fileFound) {
echo "Not found.";
}
CRM_Utils_System::civiExit();
}
CRM_Utils_System::permissionDenied();
}

/**
* Ajax callback to display code docs.
*/
Expand Down
4 changes: 0 additions & 4 deletions CRM/Contact/BAO/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -1579,11 +1579,7 @@ public static function fixDateValues($relative, &$from, &$to) {
* 4 => null
* );
*
* There are some examples of the syntax in
* https://github.com/civicrm/civicrm-core/tree/master/api/v3/examples/Relationship
*
* More notes at CRM_Core_DAO::createSQLFilter
*
* and a list of supported operators in CRM_Core_DAO
*
* @param array $formValues
Expand Down
5 changes: 0 additions & 5 deletions CRM/Core/xml/Menu/Misc.xml
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,6 @@
<access_arguments>access CiviCRM</access_arguments>
<title>CiviCRM API v3</title>
</item>
<item>
<path>civicrm/ajax/apiexample</path>
<page_callback>CRM_Admin_Page_APIExplorer::getExampleFile</page_callback>
<access_arguments>access CiviCRM</access_arguments>
</item>
<item>
<path>civicrm/ajax/apidoc</path>
<page_callback>CRM_Admin_Page_APIExplorer::getDoc</page_callback>
Expand Down
211 changes: 0 additions & 211 deletions Civi/Test/Api3DocTrait.php

This file was deleted.

11 changes: 11 additions & 0 deletions Civi/Test/Api3TestTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,17 @@ public function callAPIFailure($entity, $action, $params, $expectedErrorMessage
return $result;
}

/**
* @deprecated
* @param string $entity
* @param string $action
* @param array $params
* @return array|int
*/
public function callAPIAndDocument($entity, $action, $params) {
return $this->callAPISuccess($entity, $action, $params);
}

/**
* wrap api functions.
* so we can ensure they succeed & throw exceptions without litterering the test with checks
Expand Down
Loading

0 comments on commit bde6db9

Please sign in to comment.