introduce cloneCard backendFunctionality

Signed-off-by: grnd-alt <salimbelakkaf@outlook.de>
This commit is contained in:
grnd-alt
2024-11-04 12:45:33 +01:00
committed by Julius Knorr
parent 55c44ef6d4
commit 838b648ef6
8 changed files with 76 additions and 4 deletions

View File

@@ -93,6 +93,18 @@ class LabelService {
return $this->labelMapper->insert($label);
}
public function cloneLabelIfNotExists(int $labelId, int $targetBoardId): Label {
$this->permissionService->checkPermission(null, $targetBoardId, Acl::PERMISSION_MANAGE);
$boardLabels = $this->boardService->find($targetBoardId)->getLabels();
$originLabel = $this->find($labelId);
$filteredValues = array_values(array_filter($boardLabels, fn ($item) => $item->getTitle() === $originLabel->getTitle()));
if (empty($filteredValues)) {
$label = $this->create($originLabel->getTitle(), $originLabel->getColor(), $targetBoardId);
return $label;
}
return $originLabel;
}
/**
* @param $id
* @return \OCP\AppFramework\Db\Entity