Skip to content

Commit

Permalink
add xml_file field to update case in store
Browse files Browse the repository at this point in the history
  • Loading branch information
temaotl committed Jul 2, 2024
1 parent 6473425 commit 95c9ca6
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions app/Http/Controllers/EntityController.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ public function store(StoreEntity $request)
->back()
->with('status', "{$result['error']} {$result['message']}")
->with('color', 'red');

break;

default:
Expand Down Expand Up @@ -256,6 +255,7 @@ public function update(Request $request, Entity $entity)
switch ($result['code']) {
case '0':

$xml_file = $this->deleteTags($updated_entity['metadata']);
$entity->update([
'name_en' => $updated_entity['name_en'],
'name_cs' => $updated_entity['name_cs'],
Expand All @@ -264,6 +264,7 @@ public function update(Request $request, Entity $entity)
'cocov1' => $updated_entity['cocov1'],
'sirtfi' => $updated_entity['sirtfi'],
'metadata' => $updated_entity['metadata'],
'xml_file' => $xml_file,
]);

if ($entity->type->value === 'idp') {
Expand All @@ -276,14 +277,14 @@ public function update(Request $request, Entity $entity)
->with('status', __('entities.not_changed'));
}

Bus::chain([
/* Bus::chain([
new GitUpdateEntity($entity, Auth::user()),
function () use ($entity) {
$admins = User::activeAdmins()->select('id', 'email')->get();
Notification::send($entity->operators, new EntityUpdated($entity));
Notification::send($admins, new EntityUpdated($entity));
},
])->dispatch();
])->dispatch();*/

return redirect()
->route('entities.show', $entity)
Expand Down Expand Up @@ -313,10 +314,11 @@ function () use ($entity) {
case 'state':
$this->authorize('delete', $entity);

// TODO restore
if ($entity->trashed()) {
$entity->restore();

Bus::chain([
/* Bus::chain([
new GitAddEntity($entity, Auth::user()),
new GitAddToHfd($entity, Auth::user()),
new GitRestoreToEdugain($entity, Auth::user()),
Expand All @@ -330,22 +332,24 @@ function () use ($entity) {
Notification::send(User::activeAdmins()->select('id', 'email')->get(), new EntityAddedToHfd($entity));
}
},
])->dispatch();
])->dispatch();*/

// TODO here M:N connection wit federation
foreach ($entity->federations as $federation) {
Bus::chain([
/* Bus::chain([
new GitAddMember($federation, $entity, Auth::user()),
function () use ($federation, $entity) {
$admins = User::activeAdmins()->select('id', 'email')->get();
Notification::send($federation->operators, new FederationMemberChanged($federation, $entity, 'added'));
Notification::send($admins, new FederationMemberChanged($federation, $entity, 'added'));
},
])->dispatch();
])->dispatch();*/
}
} else {
$entity->delete();

Bus::chain([
//TODO delete chain
/* Bus::chain([
new GitDeleteEntity($entity, Auth::user()),
new GitDeleteFromHfd($entity, Auth::user()),
new GitDeleteFromEdugain($entity, Auth::user()),
Expand All @@ -359,7 +363,7 @@ function () use ($entity) {
Notification::send(User::activeAdmins()->select('id', 'email')->get(), new EntityDeletedFromHfd($entity));
}
},
])->dispatch();
])->dispatch();*/
}

$state = $entity->trashed() ? 'deleted' : 'restored';
Expand Down

0 comments on commit 95c9ca6

Please sign in to comment.