Skip to content

Commit

Permalink
Entities code cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
JanOppolzer committed Nov 26, 2024
1 parent 6922218 commit bdda973
Show file tree
Hide file tree
Showing 36 changed files with 68 additions and 1,401 deletions.
3 changes: 2 additions & 1 deletion app/Http/Controllers/EntityCategoryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@ public function update(Entity $entity)
if ($xml_file) {
$entity->xml_file = $xml_file;
}

$entity->category()->associate($category);
$entity->xml_file = CategoryTag::create($entity);
$entity->save();

$admins = User::activeAdmins()->select('id', 'email')->get();
Notification::send($admins, new IdpCategoryChanged($entity, $category));

Expand All @@ -42,6 +44,5 @@ public function update(Entity $entity)
return redirect()
->route('entities.show', $entity)
->with('status', __('entities.category_updated'));

}
}
12 changes: 3 additions & 9 deletions app/Http/Controllers/EntityController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,15 @@
use App\Notifications\EntityRequested;
use App\Traits\DumpFromGit\EntitiesHelp\DeleteFromEntity;
use App\Traits\DumpFromGit\EntitiesHelp\UpdateEntity;
use App\Traits\GitTrait;
use App\Traits\ValidatorTrait;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Notification;
use Illuminate\Support\Facades\Storage;

class EntityController extends Controller
{
use DeleteFromEntity,UpdateEntity;
use GitTrait, ValidatorTrait;
use DeleteFromEntity, UpdateEntity, ValidatorTrait;

/**
* Display a listing of the resource.
Expand Down Expand Up @@ -171,9 +168,7 @@ public function edit(Entity $entity)
{
$this->authorize('update', $entity);

return view('entities.edit', [
'entity' => $entity,
]);
return view('entities.edit', compact('entity'));
}

/**
Expand Down Expand Up @@ -260,7 +255,6 @@ public function update(Request $request, Entity $entity)
->back()
->with('status', __('entities.unknown_error_while_registration'))
->with('color', 'red');

}
}

Expand Down Expand Up @@ -288,7 +282,7 @@ public function destroy(Entity $entity)
$entity->forceDelete();

$admins = User::activeAdmins()->select('id', 'email')->get();
Notification::sendNow($admins, new EntityDestroyed($name));
Notification::send($admins, new EntityDestroyed($name));

return redirect('entities')
->with('status', __('entities.destroyed', ['name' => $name]));
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/EntityEduGainController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class EntityEduGainController extends Controller
{
public function edugain(Entity $entity)
public function update(Entity $entity)
{
$this->authorize('update', $entity);

Expand Down
5 changes: 1 addition & 4 deletions app/Http/Controllers/EntityFederationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,12 @@
use App\Models\Federation;
use App\Models\User;
use App\Notifications\EntityDeletedFromFederation;
use App\Traits\GitTrait;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Notification;

class EntityFederationController extends Controller
{
use GitTrait;

public function index(Entity $entity)
{
$this->authorize('view', $entity);
Expand Down Expand Up @@ -77,7 +74,7 @@ public function destroy(Request $request, Entity $entity)
$federation = Federation::find($f);

FolderDeleteMembership::dispatch($entity, $federation);
//GitDeleteFromFederation::dispatch($entity, $federation, Auth::user());

Notification::send($entity->operators, new EntityDeletedFromFederation($entity, $federation));
Notification::send(User::activeAdmins()->select('id', 'email')->get(), new EntityDeletedFromFederation($entity, $federation));
}
Expand Down
242 changes: 0 additions & 242 deletions app/Http/Controllers/EntityManagementController.php

This file was deleted.

2 changes: 2 additions & 0 deletions app/Http/Controllers/EntityMetadataController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public function store(Entity $entity)
->with('status', __('entities.not_yet_approved'))
->with('color', 'red');
}

$folderName = optional($entity->federations->first())->name;
if (is_null($folderName)) {
return to_route('entities.show', $entity)
Expand All @@ -36,6 +37,7 @@ public function show(Entity $entity)
->with('status', __('entities.not_yet_approved'))
->with('color', 'red');
}

$folderName = optional($entity->federations->first())->name;
if (is_null($folderName)) {
return to_route('entities.show', $entity)
Expand Down
5 changes: 2 additions & 3 deletions app/Http/Controllers/EntityOperatorController.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function store(Entity $entity)
$new_operators = User::whereIn('id', request('operators'))->get();
$entity->operators()->attach(request('operators'));

Notification::sendNow($new_operators, new YourEntityRightsChanged($entity, 'added'));
Notification::send($new_operators, new YourEntityRightsChanged($entity, 'added'));
NotificationService::sendOperatorNotification($old_operators, new EntityOperatorsChanged($entity, $new_operators, 'added'));

return redirect()
Expand All @@ -70,12 +70,11 @@ public function destroy(Entity $entity)
$old_operators = User::whereIn('id', request('operators'))->get();
$entity->operators()->detach(request('operators'));

Notification::sendNow($old_operators, new YourEntityRightsChanged($entity, 'deleted'));
Notification::send($old_operators, new YourEntityRightsChanged($entity, 'deleted'));
NotificationService::sendOperatorNotification($old_operators, new EntityOperatorsChanged($entity, $old_operators, 'deleted'));

return redirect()
->route('entities.operators.index', $entity)
->with('status', __('entities.operators_deleted'));

}
}
Loading

0 comments on commit bdda973

Please sign in to comment.