diff --git a/app/Console/Commands/DumpFromGit.php b/app/Console/Commands/DumpFromGit.php index 28db647..4451533 100644 --- a/app/Console/Commands/DumpFromGit.php +++ b/app/Console/Commands/DumpFromGit.php @@ -6,13 +6,13 @@ use App\Models\Entity; use App\Models\Membership; use App\Models\User; +use App\Services\FederationService; use App\Traits\DumpFromGit\CreateCategoriesAndGroupsTrait; use App\Traits\DumpFromGit\CreateEntitiesTrait; use App\Traits\DumpFromGit\CreateFederationTrait; use App\Traits\DumpFromGit\EntitiesHelp\FixEntityTrait; use App\Traits\DumpFromGit\EntitiesHelp\UpdateEntity; use App\Traits\EdugainTrait; -use App\Traits\FederationTrait; use App\Traits\GitTrait; use App\Traits\ValidatorTrait; use Exception; @@ -22,7 +22,7 @@ class DumpFromGit extends Command { use CreateCategoriesAndGroupsTrait,CreateEntitiesTrait,CreateFederationTrait; use EdugainTrait; - use FederationTrait,FixEntityTrait,UpdateEntity; + use FixEntityTrait,UpdateEntity; use GitTrait, ValidatorTrait; /** @@ -41,7 +41,7 @@ class DumpFromGit extends Command private function createMetadataFiles(): void { - $this->updateFederationFolders(); + FederationService::createFoldersToAllFederation(); $membership = Membership::select('entity_id', 'federation_id')->whereApproved(1)->get(); foreach ($membership as $member) { EntityFacade::saveMetadataToFederationFolder($member->entity_id, $member->federation_id); @@ -67,7 +67,7 @@ public function handle() $this->createCategoriesAndGroups(); $this->updateGroupsAndCategories(); $this->updateEntitiesXml(); - $this->updateFederationFolders(); + FederationService::createFoldersToAllFederation(); $this->fixEntities(); $this->createMetadataFiles(); $this->makeEdu2Edugain(); diff --git a/app/Http/Controllers/EntityController.php b/app/Http/Controllers/EntityController.php index 7a6f860..002500a 100644 --- a/app/Http/Controllers/EntityController.php +++ b/app/Http/Controllers/EntityController.php @@ -391,8 +391,8 @@ function () use ($entity) { Notification::sendNow($new_operators, new YourEntityRightsChanged($entity, 'added')); NotificationService::sendOperatorNotification($old_operators, new EntityOperatorsChanged($entity, $new_operators, 'added')); -/* Notification::send($old_operators, new EntityOperatorsChanged($entity, $new_operators, 'added')); - Notification::send($admins, new EntityOperatorsChanged($entity, $new_operators, 'added'));*/ + /* Notification::send($old_operators, new EntityOperatorsChanged($entity, $new_operators, 'added')); + Notification::send($admins, new EntityOperatorsChanged($entity, $new_operators, 'added'));*/ return redirect() ->route('entities.show', $entity) @@ -416,8 +416,8 @@ function () use ($entity) { $admins = User::activeAdmins()->select('id', 'email')->get(); Notification::sendNow($old_operators, new YourEntityRightsChanged($entity, 'deleted')); NotificationService::sendOperatorNotification($old_operators, new EntityOperatorsChanged($entity, $old_operators, 'deleted')); -/* Notification::send($new_operators, new EntityOperatorsChanged($entity, $old_operators, 'deleted')); - Notification::send($admins, new EntityOperatorsChanged($entity, $old_operators, 'deleted'));*/ + /* Notification::send($new_operators, new EntityOperatorsChanged($entity, $old_operators, 'deleted')); + Notification::send($admins, new EntityOperatorsChanged($entity, $old_operators, 'deleted'));*/ return redirect() ->route('entities.show', $entity) diff --git a/app/Listeners/CreateFederationFolder.php b/app/Listeners/CreateFederationFolder.php index dd69582..cde2ea6 100644 --- a/app/Listeners/CreateFederationFolder.php +++ b/app/Listeners/CreateFederationFolder.php @@ -3,13 +3,11 @@ namespace App\Listeners; use App\Events\FederationApprove; -use App\Traits\FederationTrait; +use App\Services\FederationService; use Illuminate\Support\Facades\Storage; class CreateFederationFolder { - use FederationTrait; - /** * Create the event listener. */ @@ -28,7 +26,7 @@ public function handle(FederationApprove $event): void $federation = $event->federation; if ($federation->approved) { if (! Storage::disk($diskName)->exists($federation->name)) { - $this->createFederationFolder($federation->name); + FederationService::createFederationFolder($federation->name); } } diff --git a/app/Traits/FederationTrait.php b/app/Services/FederationService.php similarity index 60% rename from app/Traits/FederationTrait.php rename to app/Services/FederationService.php index 6aaf753..060c534 100644 --- a/app/Traits/FederationTrait.php +++ b/app/Services/FederationService.php @@ -1,25 +1,25 @@ makeDirectory($name); } - public function updateFederationFolders(): void + public static function createFoldersToAllFederation(): void { $federations = Federation::all(); foreach ($federations as $fed) { if (! Storage::disk(config('storageCfg.name'))->exists($fed['xml_id'])) { - $this->createFederationFolder($fed['xml_id']); + self::createFederationFolder($fed['xml_id']); } } } diff --git a/app/Traits/EdugainTrait.php b/app/Traits/EdugainTrait.php index 0970a31..275c2a8 100644 --- a/app/Traits/EdugainTrait.php +++ b/app/Traits/EdugainTrait.php @@ -7,8 +7,6 @@ trait EdugainTrait { - use FederationTrait; - public function makeEdu2Edugain() { $folderName = config('storageCfg.edu2edugain'); diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index 0ee88e5..6ebc835 100644 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -7,14 +7,12 @@ use App\Models\Federation; use App\Models\Group; use App\Models\User; -use App\Traits\FederationTrait; +use App\Services\FederationService; use Illuminate\Database\Seeder; use Illuminate\Support\Facades\Storage; class DatabaseSeeder extends Seeder { - use FederationTrait; - /** * Seed the application's database. * @@ -34,8 +32,7 @@ public function run() User::factory()->create(['active' => true]); User::factory(96)->create(); - $edu2edugain = config('storageCfg.edu2edugain'); - $this->createFederationFolder($edu2edugain); + FederationService::createFederationFolder(config('storageCfg.edu2edugain')); /* Federation::factory(20)->create(); Entity::factory(100)->create();*/