Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
[#1011](https://github.com/nextcloud/cookbook/pull/1011) @christianlupus
- Make PHP code styling more strict
[#1011](https://github.com/nextcloud/cookbook/pull/1011) @christianlupus
- Adding some strings to transifex
[#1049](https://github.com/nextcloud/cookbook/pull/1049) @christianlupus

### Codebase maintenance
- Removed codecov.io upload of intermediate merge commits during pull requests [#1028](https://github.com/nextcloud/cookbook/issues/1028)
Expand Down
14 changes: 12 additions & 2 deletions lib/Db/RecipeDb.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IDBConnection;
use OCP\AppFramework\Db\DoesNotExistException;
use OCP\IL10N;

class RecipeDb {
private const DB_TABLE_RECIPES = 'cookbook_names';
Expand All @@ -18,7 +19,16 @@ class RecipeDb {
*/
private $types;

public function __construct(IDBConnection $db, DbTypesPolyfillHelper $polyfillTypes) {
/**
* @var IL10N
*/
private $l;

public function __construct(
IDBConnection $db,
DbTypesPolyfillHelper $polyfillTypes,
IL10N $l
) {
$this->db = $db;
$this->types = $polyfillTypes;
}
Expand All @@ -41,7 +51,7 @@ public function findRecipeById(int $id) {
$cursor->closeCursor();

if ($row === false) {
throw new DoesNotExistException("Recipe with $id was not found in database.");
throw new DoesNotExistException($this->l->t("Recipe with ID %d was not found in database.", [$id]));
}

$ret = [];
Expand Down
17 changes: 15 additions & 2 deletions lib/Service/DbCacheService.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use OCP\AppFramework\Db\DoesNotExistException;
use OCA\Cookbook\Exception\InvalidJSONFileException;
use OCA\Cookbook\Helper\UserConfigHelper;
use OCP\IL10N;

class DbCacheService {
private $userId;
Expand All @@ -27,6 +28,11 @@ class DbCacheService {
*/
private $userConfigHelper;

/**
* @var IL10N
*/
private $l;

private $jsonFiles;
private $dbReceipeFiles;
private $dbKeywords;
Expand All @@ -36,11 +42,18 @@ class DbCacheService {
private $obsoleteRecipes;
private $updatedRecipes;

public function __construct(?string $UserId, RecipeDb $db, RecipeService $recipeService, UserConfigHelper $userConfigHelper) {
public function __construct(
?string $UserId,
RecipeDb $db,
RecipeService $recipeService,
UserConfigHelper $userConfigHelper,
IL10N $l
) {
$this->userId = $UserId;
$this->db = $db;
$this->recipeService = $recipeService;
$this->userConfigHelper = $userConfigHelper;
$this->l = $l;
}

public function updateCache() {
Expand Down Expand Up @@ -123,7 +136,7 @@ private function parseJSONFile(File $jsonFile): array {
if (!$json || !isset($json['name']) || $json['name'] === 'No name') {
$id = $jsonFile->getParent()->getId();

throw new InvalidJSONFileException("The JSON file in the folder with id $id does not have a valid name.");
throw new InvalidJSONFileException($this->l->t('The JSON file in the folder with id %d does not have a valid name.', [$id]));
}

$id = (int) $jsonFile->getParent()->getId();
Expand Down