$paths = self::uniquePaths();
foreach ($paths as $path) {
$dir = \CRM_Utils_File::addTrailingSlash($path) . 'api' . DIRECTORY_SEPARATOR . 'v3' . DIRECTORY_SEPARATOR . 'examples';
- if (is_dir($dir)) {
+ if (\CRM_Utils_File::isDir($dir)) {
foreach (scandir($dir) as $item) {
if ($item && strpos($item, '.') === FALSE && array_search($item, $examples) === FALSE) {
$examples[] = $item;
$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 (is_dir($dir)) {
+ if (\CRM_Utils_File::isDir($dir)) {
foreach (scandir($dir) as $item) {
$item = str_replace('.ex.php', '', $item);
if ($item && strpos($item, '.') === FALSE) {
// Fetch block for a specific action
else {
$action = strtolower($action);
- $fnName = 'civicrm_api3_' . _civicrm_api_get_entity_name_from_camel($entity) . '_' . $action;
+ $fnName = 'civicrm_api3_' . CRM_Core_DAO_AllCoreTables::convertEntityNameToLower($entity) . '_' . $action;
// Support the alternate "1 file per action" structure
$actionFile = "api/v3/$entity/" . ucfirst($action) . '.php';
$actionFileContents = file_get_contents("api/v3/$entity/" . ucfirst($action) . '.php', FILE_USE_INCLUDE_PATH);
/**
* Format a docblock to be a bit more readable
- * Not a proper doc parser... patches welcome :)
+ *
+ * FIXME: APIv4 uses markdown in code docs. Switch to that.
*
* @param string $text
* @return string
// Extract code blocks - save for later to skip html conversion
$code = [];
- preg_match_all('#@code(.*?)@endcode#is', $text, $code);
- $text = preg_replace('#@code.*?@endcode#is', '<pre></pre>', $text);
+ preg_match_all('#(@code|```)(.*?)(@endcode|```)#is', $text, $code);
+ $text = preg_replace('#(@code|```)(.*?)(@endcode|```)#is', '<pre></pre>', $text);
// Convert @annotations to titles
$text = preg_replace_callback(
$text = nl2br($text);
// Add unformatted code blocks back in
- if ($code && !empty($code[1])) {
- foreach ($code[1] as $block) {
+ if ($code && !empty($code[2])) {
+ foreach ($code[2] as $block) {
$text = preg_replace('#<pre></pre>#', "<pre>$block</pre>", $text, 1);
}
}