Skip to content

Commit

Permalink
linting
Browse files Browse the repository at this point in the history
Signed-off-by: Florian Steffens <florian.steffens@nextcloud.com>
  • Loading branch information
Florian Steffens committed Oct 30, 2023
1 parent 54ffd58 commit dcf7f0d
Show file tree
Hide file tree
Showing 2 changed files with 234 additions and 242 deletions.
117 changes: 58 additions & 59 deletions lib/Api/V1Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,69 +10,68 @@
use OCP\AppFramework\Db\DoesNotExistException;
use OCP\AppFramework\Db\MultipleObjectsReturnedException;

class V1Api
{
private RowService $rowService;
private ColumnService $columnService;
private ?string $userId;
class V1Api {
private RowService $rowService;
private ColumnService $columnService;
private ?string $userId;

public function __construct(ColumnService $columnService, RowService $rowService, ?string $userId)
{
$this->columnService = $columnService;
$this->rowService = $rowService;
$this->userId = $userId;
}
public function __construct(ColumnService $columnService, RowService $rowService, ?string $userId) {
$this->columnService = $columnService;
$this->rowService = $rowService;
$this->userId = $userId;
}

/**
* @param int $tableId
* @param int|null $limit
* @param int|null $offset
* @param string|null $userId
* @param string|null $nodeType
* @return array
* @throws DoesNotExistException
* @throws InternalError
* @throws MultipleObjectsReturnedException
* @throws NotFoundError
* @throws PermissionError
*/
public function getData(int $tableId, ?int $limit, ?int $offset, ?string $userId, ?string $nodeType = null): array
{
if ($userId) $this->userId = $userId;
if ($nodeType === 'view') {
$columns = $this->columnService->findAllByView($tableId, $this->userId);
$rows = $this->rowService->findAllByView($tableId, $this->userId, $limit, $offset);
} else {
// if no nodeType is provided, the old table selection is used to not break anything
$columns = $this->columnService->findAllByTable($tableId, null, $this->userId);
$rows = $this->rowService->findAllByTable($tableId, $this->userId, $limit, $offset);
}
/**
* @param int $tableId
* @param int|null $limit
* @param int|null $offset
* @param string|null $userId
* @param string|null $nodeType
* @return array
* @throws DoesNotExistException
* @throws InternalError
* @throws MultipleObjectsReturnedException
* @throws NotFoundError
* @throws PermissionError
*/
public function getData(int $tableId, ?int $limit, ?int $offset, ?string $userId, ?string $nodeType = null): array {
if ($userId) {
$this->userId = $userId;
}
if ($nodeType === 'view') {
$columns = $this->columnService->findAllByView($tableId, $this->userId);
$rows = $this->rowService->findAllByView($tableId, $this->userId, $limit, $offset);
} else {
// if no nodeType is provided, the old table selection is used to not break anything
$columns = $this->columnService->findAllByTable($tableId, null, $this->userId);
$rows = $this->rowService->findAllByTable($tableId, $this->userId, $limit, $offset);
}

$data = [];
$data = [];

// first line contains the titles
$header = [];
foreach ($columns as $column) {
$header[] = $column->getTitle();
}
$data[] = $header;
// first line contains the titles
$header = [];
foreach ($columns as $column) {
$header[] = $column->getTitle();
}
$data[] = $header;

// now add the rows
foreach ($rows as $row) {
$rowData = $row->getDataArray();
$line = [];
foreach ($columns as $column) {
$value = '';
foreach ($rowData as $datum) {
if ($datum['columnId'] === $column->getId()) {
$value = $datum['value'];
}
}
$line[] = $value;
}
$data[] = $line;
}
// now add the rows
foreach ($rows as $row) {
$rowData = $row->getDataArray();
$line = [];
foreach ($columns as $column) {
$value = '';
foreach ($rowData as $datum) {
if ($datum['columnId'] === $column->getId()) {
$value = $datum['value'];
}
}
$line[] = $value;
}
$data[] = $line;
}

return $data;
}
return $data;
}
}
Loading

0 comments on commit dcf7f0d

Please sign in to comment.