Skip to content

Commit

Permalink
Merge pull request #731 from pascalchevrel/return_no_variable
Browse files Browse the repository at this point in the history
fix #730: small refactoring of  variable use in api
  • Loading branch information
pascalchevrel committed Apr 18, 2016
2 parents 63de56d + ec5a40f commit 228916b
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 16 deletions.
18 changes: 9 additions & 9 deletions app/controllers/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,42 +16,42 @@
case 'entity':
$repo = $request->parameters[2];
$entity = $request->extra_parameters['id'];
include MODELS . 'api/entity.php';
$json = include MODELS . 'api/entity.php';
if (empty($json)) {
$request->error = 'Entity not available';
$json = $request->invalidAPICall();
}
break;
case 'locales':
include MODELS . 'api/repository_locales.php';
$json = include MODELS . 'api/repository_locales.php';
break;
case 'repositories':
include MODELS . 'api/repositories_list.php';
$json = include MODELS . 'api/repositories_list.php';
break;
case 'search':
// We chain 2 queries to match both strings and entities
if ($request->parameters[2] == 'all') {
$request->parameters[2] = 'entities';
include MODELS . 'api/repository_search.php';
$json = include MODELS . 'api/repository_search.php';
$entities_json = $json;

$request->parameters[2] = 'strings';
include MODELS . 'api/repository_search.php';
$json = include MODELS . 'api/repository_search.php';
$strings_json = $json;

$json = array_merge($entities_json, $strings_json);
} else {
include MODELS . 'api/repository_search.php';
$json = include MODELS . 'api/repository_search.php';
}
break;
case 'suggestions':
include MODELS . 'api/suggestions.php';
$json = include MODELS . 'api/suggestions.php';
break;
case 'tm':
include MODELS . 'api/translation_memory.php';
$json = include MODELS . 'api/translation_memory.php';
break;
case 'versions':
include MODELS . 'api/versions.php';
$json = include MODELS . 'api/versions.php';
break;
default:
return false;
Expand Down
2 changes: 1 addition & 1 deletion app/models/api/entity.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@
Cache::setKey($cache_id, $translations);
}

return $json = $translations;
return $translations;
2 changes: 1 addition & 1 deletion app/models/api/repositories_list.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
}

// Default to list all existing repositories
return $json = Project::getRepositories();
return Project::getRepositories();
2 changes: 1 addition & 1 deletion app/models/api/repository_locales.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
namespace Transvision;

$json = Project::getRepositoryLocales($request->parameters[2]);
return Project::getRepositoryLocales($request->parameters[2]);
2 changes: 1 addition & 1 deletion app/models/api/repository_search.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
array_splice($source_strings_merged, 500);
array_splice($target_strings_merged, 500);

return $json = ShowResults::getRepositorySearchResults(
return ShowResults::getRepositorySearchResults(
$entities_merged,
[$source_strings_merged, $target_strings_merged]
);
2 changes: 1 addition & 1 deletion app/models/api/suggestions.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
return $value;
};

return $json = ShowResults::getSuggestionsResults(
return ShowResults::getSuggestionsResults(
$source_strings_merged,
$target_strings_merged,
$search->getSearchTerms(),
Expand Down
2 changes: 1 addition & 1 deletion app/models/api/translation_memory.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
unset($source_strings, $target_strings);
}

return $json = ShowResults::getTranslationMemoryResults(
return ShowResults::getTranslationMemoryResults(
$output,
$search->getSearchTerms(),
$get_option('max_results'), // Cap results with the ?max_results=number option
Expand Down
2 changes: 1 addition & 1 deletion app/models/api/versions.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
namespace Transvision;

return $json = $request->api_versions;
return $request->api_versions;

0 comments on commit 228916b

Please sign in to comment.