Skip to content

Commit

Permalink
OXDEV-8215: Merge Theme and Module functionality (Services, DT and Fi…
Browse files Browse the repository at this point in the history
…lters)
  • Loading branch information
MarcelOxid committed Aug 7, 2024
1 parent f200685 commit 3fb5eb4
Show file tree
Hide file tree
Showing 49 changed files with 530 additions and 832 deletions.
7 changes: 4 additions & 3 deletions src/Module/Controller/ModuleListController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
namespace OxidEsales\GraphQL\ConfigurationAccess\Module\Controller;

use OxidEsales\GraphQL\ConfigurationAccess\Module\DataType\ModuleDataTypeInterface;
use OxidEsales\GraphQL\ConfigurationAccess\Module\DataType\ModuleFilters;
use OxidEsales\GraphQL\ConfigurationAccess\Module\Service\ModuleListServiceInterface;
use OxidEsales\GraphQL\ConfigurationAccess\Shared\DataType\ComponentFilters;
use OxidEsales\GraphQL\ConfigurationAccess\Shared\DataType\ComponentFiltersInterface;
use TheCodingMachine\GraphQLite\Annotations\Logged;
use TheCodingMachine\GraphQLite\Annotations\Query;
use TheCodingMachine\GraphQLite\Annotations\Right;
Expand All @@ -30,8 +31,8 @@ public function __construct(
#[Query]
#[Logged]
#[Right('LIST_MODULES')]
public function modulesList(?ModuleFilters $filters = null): array
public function modulesList(?ComponentFiltersInterface $filters): array
{
return $this->moduleListService->getModuleList($filters ?? new ModuleFilters());
return $this->moduleListService->getModuleList($filters ?? new ComponentFilters());
}
}
40 changes: 9 additions & 31 deletions src/Module/DataType/ModuleDataType.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,47 +9,25 @@

namespace OxidEsales\GraphQL\ConfigurationAccess\Module\DataType;

use OxidEsales\GraphQL\ConfigurationAccess\Shared\DataType\AbstractComponentDataType;
use TheCodingMachine\GraphQLite\Annotations\Field;
use TheCodingMachine\GraphQLite\Annotations\Type;

#[Type]
final class ModuleDataType implements ModuleDataTypeInterface
final class ModuleDataType extends AbstractComponentDataType implements ModuleDataTypeInterface
{
public function __construct(
private readonly string $id,
private readonly string $version,
private readonly string $title,
private readonly string $description,
string $id,
string $title,
string $version,
string $description,
bool $active,
private readonly ?string $thumbnail,
private readonly ?string $author,
private readonly ?string $url,
private readonly ?string $email,
private readonly bool $active
private readonly ?string $email
) {
}

#[Field]
public function getId(): string
{
return $this->id;
}

#[Field]
public function getTitle(): string
{
return $this->title;
}

#[Field]
public function getVersion(): string
{
return $this->version;
}

#[Field]
public function getDescription(): string
{
return $this->description;
parent::__construct($id, $title, $version, $description, $active);
}

#[Field]
Expand Down
8 changes: 4 additions & 4 deletions src/Module/DataType/ModuleDataTypeFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function __construct(
) {
}

public function createFromCoreModule(
public function createFromModuleConfiguration(
ModuleConfiguration $moduleConfig
): ModuleDataTypeInterface {
$titlesData = $moduleConfig->getTitle();
Expand All @@ -36,14 +36,14 @@ public function createFromCoreModule(

return new ModuleDataType(
id: $moduleConfig->getId(),
version: $moduleConfig->getVersion(),
title: $translatedTitle,
version: $moduleConfig->getVersion(),
description: $translatedDescription,
active: $moduleConfig->isActivated(),
thumbnail: $moduleConfig->getThumbnail(),
author: $moduleConfig->getAuthor(),
url: $moduleConfig->getUrl(),
email: $moduleConfig->getEmail(),
active: $moduleConfig->isActivated(),
email: $moduleConfig->getEmail()
);
}
}
2 changes: 1 addition & 1 deletion src/Module/DataType/ModuleDataTypeFactoryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@

interface ModuleDataTypeFactoryInterface
{
public function createFromCoreModule(ModuleConfiguration $moduleConfig): ModuleDataTypeInterface;
public function createFromModuleConfiguration(ModuleConfiguration $moduleConfig): ModuleDataTypeInterface;
}
12 changes: 3 additions & 9 deletions src/Module/DataType/ModuleDataTypeInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,10 @@

namespace OxidEsales\GraphQL\ConfigurationAccess\Module\DataType;

interface ModuleDataTypeInterface
{
public function getId(): string;

public function getTitle(): string;

public function getVersion(): string;

public function getDescription(): string;
use OxidEsales\GraphQL\ConfigurationAccess\Shared\DataType\ComponentDataTypeInterface;

interface ModuleDataTypeInterface extends ComponentDataTypeInterface
{
public function getThumbnail(): ?string;

public function getAuthor(): ?string;
Expand Down
21 changes: 0 additions & 21 deletions src/Module/DataType/ModuleFiltersInterface.php

This file was deleted.

2 changes: 1 addition & 1 deletion src/Module/Infrastructure/ModuleListInfrastructure.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function __construct(
) {
}

public function getModuleList(): array
public function getModuleConfigurations(): array
{
$shopConfiguration = $this->shopConfigurationDaoBridge->get();
$moduleConfigurations = $shopConfiguration->getModuleConfigurations();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ interface ModuleListInfrastructureInterface
* @return array<ModuleConfiguration>
* @throws ModulesNotFoundException
*/
public function getModuleList(): array;
public function getModuleConfigurations(): array;
}
24 changes: 0 additions & 24 deletions src/Module/Service/ModuleFilterService.php

This file was deleted.

21 changes: 0 additions & 21 deletions src/Module/Service/ModuleFilterServiceInterface.php

This file was deleted.

14 changes: 8 additions & 6 deletions src/Module/Service/ModuleListService.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,27 @@
namespace OxidEsales\GraphQL\ConfigurationAccess\Module\Service;

use OxidEsales\GraphQL\ConfigurationAccess\Module\DataType\ModuleDataTypeFactoryInterface;
use OxidEsales\GraphQL\ConfigurationAccess\Module\DataType\ModuleFiltersInterface;
use OxidEsales\GraphQL\ConfigurationAccess\Module\Infrastructure\ModuleListInfrastructureInterface;
use OxidEsales\GraphQL\ConfigurationAccess\Shared\DataType\ComponentFiltersInterface;
use OxidEsales\GraphQL\ConfigurationAccess\Shared\Service\ComponentFilterServiceInterface;

final class ModuleListService implements ModuleListServiceInterface
{
public function __construct(
private readonly ModuleListInfrastructureInterface $moduleListInfrastructure,
private readonly ModuleFilterServiceInterface $moduleFilterService,
private readonly ComponentFilterServiceInterface $componentFilterService,
private readonly ModuleDataTypeFactoryInterface $moduleDataTypeFactory
) {
}

public function getModuleList(ModuleFiltersInterface $filters): array
public function getModuleList(ComponentFiltersInterface $filters): array
{
$modulesArray = [];
$moduleConfigurations = $this->moduleListInfrastructure->getModuleList();
$moduleConfigurations = $this->moduleListInfrastructure->getModuleConfigurations();
foreach ($moduleConfigurations as $moduleConfig) {
$modulesArray[] = $this->moduleDataTypeFactory->createFromCoreModule($moduleConfig);
$modulesArray[] = $this->moduleDataTypeFactory->createFromModuleConfiguration($moduleConfig);
}
return $this->moduleFilterService->filterModules($modulesArray, $filters);

return $this->componentFilterService->filterComponents($modulesArray, $filters);
}
}
4 changes: 2 additions & 2 deletions src/Module/Service/ModuleListServiceInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@

namespace OxidEsales\GraphQL\ConfigurationAccess\Module\Service;

use OxidEsales\GraphQL\ConfigurationAccess\Shared\DataType\ComponentFiltersInterface;
use OxidEsales\GraphQL\ConfigurationAccess\Module\DataType\ModuleDataTypeInterface;
use OxidEsales\GraphQL\ConfigurationAccess\Module\DataType\ModuleFiltersInterface;

interface ModuleListServiceInterface
{
/**
* @return array<ModuleDataTypeInterface>
*/
public function getModuleList(ModuleFiltersInterface $filters): array;
public function getModuleList(ComponentFiltersInterface $filters): array;
}
56 changes: 56 additions & 0 deletions src/Shared/DataType/AbstractComponentDataType.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php

/**
* Copyright © OXID eSales AG. All rights reserved.
* See LICENSE file for license details.
*/

declare(strict_types=1);

namespace OxidEsales\GraphQL\ConfigurationAccess\Shared\DataType;

use TheCodingMachine\GraphQLite\Annotations\Field;
use TheCodingMachine\GraphQLite\Annotations\Type;

#[Type]
abstract class AbstractComponentDataType implements ComponentDataTypeInterface
{
public function __construct(
private readonly string $id,
private readonly string $title,
private readonly string $version,
private readonly string $description,
private readonly bool $active
) {
}

#[Field]
public function getId(): string
{
return $this->id;
}

#[Field]
public function getTitle(): string
{
return $this->title;
}

#[Field]
public function getVersion(): string
{
return $this->version;
}

#[Field]
public function getDescription(): string
{
return $this->description;
}

#[Field]
public function isActive(): bool
{
return $this->active;
}
}
16 changes: 16 additions & 0 deletions src/Shared/DataType/ComponentDataTypeInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace OxidEsales\GraphQL\ConfigurationAccess\Shared\DataType;

interface ComponentDataTypeInterface
{
public function getId(): string;

public function getTitle(): string;

public function getVersion(): string;

public function getDescription(): string;

public function isActive(): bool;
}
Loading

0 comments on commit 3fb5eb4

Please sign in to comment.