-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP: Deploy options DB for update process (1)
Signed-off-by: Andrey Borysenko <andrey18106x@gmail.com>
- Loading branch information
1 parent
ad473e8
commit eee8e6d
Showing
10 changed files
with
368 additions
and
164 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors | ||
* SPDX-License-Identifier: AGPL-3.0-or-later | ||
*/ | ||
|
||
namespace OCA\AppAPI\Db; | ||
|
||
use JsonSerializable; | ||
use OCP\AppFramework\Db\Entity; | ||
|
||
/** | ||
* Class ExAppDeployOption | ||
* | ||
* @package OCA\AppAPI\Db | ||
* | ||
* @method string getAppid() | ||
* @method string getType() | ||
* @method array getValue() | ||
* @method void setAppid(string $appid) | ||
* @method void setName(string $name) | ||
* @method void setType(string $type) | ||
* @method void setValue(array $value) | ||
*/ | ||
class ExAppDeployOption extends Entity implements JsonSerializable { | ||
protected $appid; | ||
protected $type; | ||
protected $value; | ||
|
||
/** | ||
* @param array $params | ||
*/ | ||
public function __construct(array $params = []) { | ||
$this->addType('appid', 'string'); | ||
$this->addType('name', 'string'); | ||
$this->addType('type', 'string'); | ||
$this->addType('value', 'json'); | ||
|
||
if (isset($params['id'])) { | ||
$this->setId($params['id']); | ||
} | ||
if (isset($params['appid'])) { | ||
$this->setAppid($params['appid']); | ||
} | ||
if (isset($params['type'])) { | ||
$this->setType($params['type']); | ||
} | ||
if (isset($params['value'])) { | ||
$this->setValue($params['value']); | ||
} | ||
} | ||
|
||
public function jsonSerialize(): array { | ||
return [ | ||
'id' => $this->getId(), | ||
'appid' => $this->getAppid(), | ||
'type' => $this->getType(), | ||
'value' => $this->getValue(), | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors | ||
* SPDX-License-Identifier: AGPL-3.0-or-later | ||
*/ | ||
|
||
namespace OCA\AppAPI\Db; | ||
|
||
use OCP\AppFramework\Db\QBMapper; | ||
use OCP\DB\Exception; | ||
use OCP\DB\QueryBuilder\IQueryBuilder; | ||
use OCP\IDBConnection; | ||
|
||
/** | ||
* @template-extends QBMapper<ExAppDeployOption> | ||
*/ | ||
class ExAppDeployOptionsMapper extends QBMapper { | ||
public function __construct(IDBConnection $db) { | ||
parent::__construct($db, 'ex_deploy_options'); | ||
} | ||
|
||
/** | ||
* @throws Exception | ||
*/ | ||
public function findAll(): array { | ||
$qb = $this->db->getQueryBuilder(); | ||
$result = $qb->select('exs.*') | ||
->from($this->tableName, 'exs') | ||
->executeQuery(); | ||
return $result->fetchAll(); | ||
} | ||
|
||
/** | ||
* @throws Exception | ||
*/ | ||
public function removeAllByAppId(string $appId): int { | ||
$qb = $this->db->getQueryBuilder(); | ||
$qb->delete($this->tableName) | ||
->where( | ||
$qb->expr()->eq('appid', $qb->createNamedParameter($appId, IQueryBuilder::PARAM_STR)) | ||
); | ||
return $qb->executeStatement(); | ||
} | ||
} |
Oops, something went wrong.