| @@ 358-369 (lines=12) @@ | ||
| 355 | * |
|
| 356 | * @throws \Exception |
|
| 357 | */ |
|
| 358 | public function deleteDocumentTypeBySlug($slug) |
|
| 359 | { |
|
| 360 | $documentTypes = $this->repository->documentTypes; |
|
| 361 | foreach ($documentTypes as $key => $documentTypeObject) { |
|
| 362 | if ($documentTypeObject->slug == $slug) { |
|
| 363 | unset($documentTypes[$key]); |
|
| 364 | } |
|
| 365 | } |
|
| 366 | $documentTypes = array_values($documentTypes); |
|
| 367 | $this->repository->documentTypes = $documentTypes; |
|
| 368 | $this->save(); |
|
| 369 | } |
|
| 370 | ||
| 371 | /** |
|
| 372 | * Get document type by its slug |
|
| @@ 410-422 (lines=13) @@ | ||
| 407 | * |
|
| 408 | * @throws \Exception |
|
| 409 | */ |
|
| 410 | public function saveDocumentType($slug, $postValues) |
|
| 411 | { |
|
| 412 | $documentTypeObject = DocumentTypeFactory::createDocumentTypeFromPostValues($postValues); |
|
| 413 | ||
| 414 | $documentTypes = $this->repository->documentTypes; |
|
| 415 | foreach ($documentTypes as $key => $documentType) { |
|
| 416 | if ($documentType->slug == $slug) { |
|
| 417 | $documentTypes[$key] = $documentTypeObject; |
|
| 418 | } |
|
| 419 | } |
|
| 420 | $this->repository->documentTypes = $documentTypes; |
|
| 421 | $this->save(); |
|
| 422 | } |
|
| 423 | ||
| 424 | /* |
|
| 425 | * |
|