Skip to content

Commit

Permalink
fix return
Browse files Browse the repository at this point in the history
  • Loading branch information
smisidjan committed Nov 14, 2023
1 parent 8cd937b commit 5dcc17f
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions src/Service/GithubApiService.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,14 +187,8 @@ public function getGithubRepository(string $repositoryUrl, ?array $repositoryArr
// Get the publiccode/opencatalogi files of the given repository.
$dataArray = $this->getFilesFromRepo($repositoryUrl, $source);

if ($dataArray !== null) {
// Import the publiccode/opencatalogi files and connect it to the repository.
$repository = $this->importRepoFiles($dataArray, $source, $repositorySync->getObject());
}

if (isset($repository) === false) {
$repository = $repositorySync->getObject();
}
// Import the publiccode/opencatalogi files and connect it to the repository.
$repository = $this->importRepoFiles($dataArray, $source, $repositorySync->getObject());

// Cleanup the repository.
$repository = $this->cleanupRepository($repository);
Expand All @@ -220,7 +214,7 @@ public function cleanupRepository(ObjectEntity $repository): ?ObjectEntity
{
// If the repository has one or less components return.
if ($repository->getValue('components')->count() <= 1) {
return null;
return $repository;
}

// Loop through the components and remove the component we created.
Expand All @@ -247,8 +241,10 @@ public function cleanupRepository(ObjectEntity $repository): ?ObjectEntity
* @param Source $source The github api source.
*
* @throws GuzzleException
*
* @return ObjectEntity
*/
public function enrichWithOrganization(ObjectEntity $repository, array $repositoryArray, Source $source): void
public function enrichWithOrganization(ObjectEntity $repository, array $repositoryArray, Source $source): ObjectEntity
{
$organizationSchema = $this->resourceService->getSchema('https://opencatalogi.nl/oc.organisation.schema.json', 'open-catalogi/open-catalogi-bundle');

Expand All @@ -266,6 +262,8 @@ public function enrichWithOrganization(ObjectEntity $repository, array $reposito
$this->entityManager->persist($repository);
$this->entityManager->flush();

return $repository;

}//end enrichWithOrganization()


Expand All @@ -277,8 +275,10 @@ public function enrichWithOrganization(ObjectEntity $repository, array $reposito
* @param Source $source The github api source.
*
* @throws GuzzleException
*
* @return ObjectEntity
*/
public function enrichWithComponent(ObjectEntity $repository, array $repositoryArray, Source $source): void
public function enrichWithComponent(ObjectEntity $repository, array $repositoryArray, Source $source): ObjectEntity
{
$componentSchema = $this->resourceService->getSchema('https://opencatalogi.nl/oc.component.schema.json', 'open-catalogi/open-catalogi-bundle');

Expand All @@ -287,6 +287,8 @@ public function enrichWithComponent(ObjectEntity $repository, array $repositoryA
$this->entityManager->persist($componentSync);
$this->entityManager->flush();

return $repository;

}//end enrichWithComponent()


Expand All @@ -303,12 +305,12 @@ public function enrichRepository(ObjectEntity $repository, array $repositoryArra
{
// If there is no organization create one.
if ($repository->getValue('organisation') === false) {
$this->enrichWithOrganization($repository, $repositoryArray, $source);
$repository = $this->enrichWithOrganization($repository, $repositoryArray, $source);
}

// If there is no component create one.
if ($repository->getValue('components')->count() === 0) {
$this->enrichWithComponent($repository, $repositoryArray, $source);
$repository = $this->enrichWithComponent($repository, $repositoryArray, $source);
}

// @TODO: enrich the null values with what we have.
Expand Down

0 comments on commit 5dcc17f

Please sign in to comment.