mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-28 14:54:44 +02:00
Added basic possibilty to create parts based on infoProviders
This commit is contained in:
parent
538476be99
commit
716a56979d
12 changed files with 476 additions and 25 deletions
|
@ -23,12 +23,14 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Services\InfoProviderSystem;
|
||||
|
||||
use App\Entity\Parts\Part;
|
||||
use App\Services\InfoProviderSystem\DTOs\PartDetailDTO;
|
||||
use App\Services\InfoProviderSystem\DTOs\SearchResultDTO;
|
||||
use App\Services\InfoProviderSystem\Providers\InfoProviderInterface;
|
||||
|
||||
class PartInfoRetriever
|
||||
{
|
||||
public function __construct(private readonly ProviderRegistry $provider_registry)
|
||||
public function __construct(private readonly ProviderRegistry $provider_registry, private readonly DTOtoEntityConverter $dto_to_entity_converter)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -57,4 +59,27 @@ class PartInfoRetriever
|
|||
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the details for a part from the given provider with the given (provider) part id
|
||||
* @param string $provider_key
|
||||
* @param string $part_id
|
||||
* @return
|
||||
*/
|
||||
public function getDetails(string $provider_key, string $part_id): PartDetailDTO
|
||||
{
|
||||
return $this->provider_registry->getProviderByKey($provider_key)->getDetails($part_id);
|
||||
}
|
||||
|
||||
public function getDetailsForSearchResult(SearchResultDTO $search_result): PartDetailDTO
|
||||
{
|
||||
return $this->getDetails($search_result->provider_key, $search_result->provider_id);
|
||||
}
|
||||
|
||||
public function createPart(string $provider_key, string $part_id): Part
|
||||
{
|
||||
$details = $this->getDetails($provider_key, $part_id);
|
||||
|
||||
return $this->dto_to_entity_converter->convertPart($details);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue