Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IBX-201: Refactored ExportParametersFactory #68

Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions src/bundle/Resources/config/services/factory.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,22 @@ services:
autoconfigure: true
public: false

EzSystems\EzRecommendationClient\Factory\:
resource: '../../../../src/lib/Factory/*'
EzSystems\EzRecommendationClient\Factory\EzRecommendationClientAPIFactory: ~

EzSystems\EzRecommendationClient\Factory\ExportParametersFactory: ~
EzSystems\EzRecommendationClient\Factory\FakeRequestFactory: ~
Steveb-p marked this conversation as resolved.
Show resolved Hide resolved

EzSystems\EzRecommendationClient\Factory\ConfigurableExportParametersFactory:
EzSystems\EzRecommendationClient\Factory\RequestFactoryInterface:
'@EzSystems\EzRecommendationClient\Factory\FakeRequestFactory'

EzSystems\EzRecommendationClient\Factory\TokenFactory: ~

EzSystems\EzRecommendationClient\Factory\TokenFactoryInterface:
'@EzSystems\EzRecommendationClient\Factory\TokenFactory'

Ibexa\Personalization\Factory\Export\ParametersFactory:
arguments:
$innerService: '@EzSystems\EzRecommendationClient\Factory\ExportParametersFactory'
$credentialsResolver: '@EzSystems\EzRecommendationClient\Config\ExportCredentialsResolver'
$siteAccessService: '@ezpublish.siteaccess_service'
$credentialsResolver: '@EzSystems\EzRecommendationClient\Config\EzRecommendationClientCredentialsResolver'

Ibexa\Personalization\Factory\Export\ParametersFactoryInterface:
'@Ibexa\Personalization\Factory\Export\ParametersFactory'
3 changes: 0 additions & 3 deletions src/bundle/Resources/config/services/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ services:
autoconfigure: true
public: false

EzSystems\EzRecommendationClient\Value\:
resource: '../../../../src/lib/Value/*'

EzSystems\EzRecommendationClient\Value\ContentDataVisitor:
tags:
- { name: ezpublish_rest.output.value_object_visitor, type: EzSystems\EzRecommendationClient\Value\ContentData }
18 changes: 15 additions & 3 deletions src/lib/Exception/CredentialsNotFoundException.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,22 @@

namespace EzSystems\EzRecommendationClient\Exception;

class CredentialsNotFoundException extends NotFoundException
use Throwable;

final class CredentialsNotFoundException extends NotFoundException
{
public function __construct(int $code = 0, ?Throwable $previous = null)
public function __construct(?string $siteAccess = null, int $code = 0, Throwable $previous = null)
{
parent::__construct('Credentials for recommendation client are not set', $code, $previous);
$message = 'Credentials for recommendation client are not set';

if (null !== $siteAccess) {
$message .= ' for siteAccess: ' . $siteAccess;
}

parent::__construct(
$message,
$code,
$previous
);
}
}
13 changes: 0 additions & 13 deletions src/lib/Exception/ExportCredentialsNotFoundException.php

This file was deleted.

29 changes: 28 additions & 1 deletion src/lib/Exception/MissingExportParameterException.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,33 @@

namespace EzSystems\EzRecommendationClient\Exception;

class MissingExportParameterException extends ExportException
use Ibexa\Personalization\Factory\Export\ParametersFactoryInterface;
use Throwable;

final class MissingExportParameterException extends ExportException
{
/**
* @param array<int, string> $missingParameters
*/
public function __construct(array $missingParameters, string $type, int $code = 0, Throwable $previous = null)
{
$parameters = [];

if ($type === ParametersFactoryInterface::COMMAND_TYPE) {
foreach ($missingParameters as $parameter) {
$parameters[] = str_replace('_', '-', $parameter);
}
} else {
$parameters = $missingParameters;
}

parent::__construct(
sprintf(
'Required parameters: %s are missing',
implode(', ', $parameters)
),
$code,
$previous
);
}
}
130 changes: 0 additions & 130 deletions src/lib/Factory/ConfigurableExportParametersFactory.php

This file was deleted.

Loading