Skip to content

Commit

Permalink
CSV Importer fix and makefile improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelfolaron committed Feb 6, 2025
1 parent 10e01f2 commit 6ec2f0b
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 8 deletions.
2 changes: 1 addition & 1 deletion app/Core/Events/EventDispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ public static function add_event_listener(

public static function addEventListener($event, $listener, $priority = 10, $source = 'leantime')
{
return self::add_event_listener($event, $listener, $priority, $source);
self::add_event_listener($event, $listener, $priority, $source);
}

public static function add_filter_listener(
Expand Down
31 changes: 26 additions & 5 deletions app/Domain/Api/Services/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,36 @@
use Leantime\Domain\Users\Repositories\Users as UserRepository;
use RangeException;

/**
*
*/
class Api
{
use DispatchesEvents;

/**
* @var ApiRepository
*/
private ApiRepository $apiRepository;

/**
* @var UserRepository
*/
private UserRepository $userRepo;

private Auth $authService;

/**
* @var array|null
*/
private ?array $error = null;

/**
* @api
*/
public function __construct(ApiRepository $apiRepository, UserRepository $userRepo, Auth $authService)
public function __construct(ApiRepository $apiRepository, UserRepository $userRepo)
{
$this->apiRepository = $apiRepository;
$this->userRepo = $userRepo;
$this->authService = $authService;
}

/**
Expand Down Expand Up @@ -71,6 +81,16 @@ public function getAPIKeyUser(string $apiKey): bool|array
return false;
}

/**
* @param array $user
* @param bool $isExternalAuth
* @return void
* @throws BindingResolutionException
*
* Note: This is deliberately a duplicate of the authService setSession method to not have to load the authService
* which will run db connections when we are not ready yet.
* TODO: Move session management into a dedicated service
*/
public function setApiUserSession(array $user, bool $isExternalAuth = false)
{

Expand Down Expand Up @@ -207,8 +227,6 @@ public function jsonResponse(int $id, ?array $result): void
/**
* Check the manifest for the asset and serve if found.
*
*
*
* @api
*/
public function getCaseCorrectPathFromManifest(string $filepath): string|false
Expand All @@ -229,6 +247,9 @@ public function getCaseCorrectPathFromManifest(string $filepath): string|false
return $basePath.array_search($referenceValue, $correctManifest);
}

/**
* @return true
*/
public function healthCheck()
{
return true;
Expand Down
8 changes: 7 additions & 1 deletion app/Domain/CsvImport/register.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,11 @@
// Register event listener
EventDispatcher::add_filter_listener(
'leantime.domain.connector.services.providers.loadProviders.providerList',
new AddCSVImportProvider
function(mixed $payload) {

$provider = app()->make(\Leantime\Domain\CsvImport\Services\CsvImport::class);
$payload[$provider->id] = $provider;

return $payload;
}
);
3 changes: 2 additions & 1 deletion makefile
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ clear-cache:
rm -rf ./bootstrap/cache/*.php
rm -rf ./storage/framework/composerPaths.php
rm -rf ./storage/framework/viewPaths.php
rm -rf ./storage/framework/cache/*.php
rm -rf ./storage/framework/cache/**/*
rm -rf ./storage/framework/sessions/**/*
rm -rf ./storage/framework/views/*.php

.PHONY: install-deps build-js build package clean run-dev

0 comments on commit 6ec2f0b

Please sign in to comment.