Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
bigboss86 committed Mar 19, 2024
1 parent 1c9a038 commit 69870ec
Show file tree
Hide file tree
Showing 27 changed files with 114 additions and 205 deletions.
15 changes: 3 additions & 12 deletions src/Controller/Action/CitySearchAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,11 @@

final class CitySearchAction
{
private AddressRepositoryInterface $addressRepository;

private RepositoryInterface $countryRepository;

private ConfigurableViewHandlerInterface $viewHandler;

public function __construct(
AddressRepositoryInterface $addressRepository,
RepositoryInterface $countryRepository,
ConfigurableViewHandlerInterface $viewHandler,
private AddressRepositoryInterface $addressRepository,
private RepositoryInterface $countryRepository,
private ConfigurableViewHandlerInterface $viewHandler,
) {
$this->addressRepository = $addressRepository;
$this->countryRepository = $countryRepository;
$this->viewHandler = $viewHandler;
}

public function __invoke(Request $request): Response
Expand Down
15 changes: 3 additions & 12 deletions src/Controller/Action/PostcodeSearchAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,11 @@

final class PostcodeSearchAction
{
private AddressRepositoryInterface $addressRepository;

private RepositoryInterface $countryRepository;

private ConfigurableViewHandlerInterface $viewHandler;

public function __construct(
AddressRepositoryInterface $addressRepository,
RepositoryInterface $countryRepository,
ConfigurableViewHandlerInterface $viewHandler,
private AddressRepositoryInterface $addressRepository,
private RepositoryInterface $countryRepository,
private ConfigurableViewHandlerInterface $viewHandler,
) {
$this->addressRepository = $addressRepository;
$this->countryRepository = $countryRepository;
$this->viewHandler = $viewHandler;
}

public function __invoke(Request $request): Response
Expand Down
15 changes: 3 additions & 12 deletions src/Controller/Action/ProductSearchAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,11 @@

final class ProductSearchAction
{
private ProductRepositoryInterface $productRepository;

private LocaleContextInterface $localeContext;

private ConfigurableViewHandlerInterface $viewHandler;

public function __construct(
ProductRepositoryInterface $productRepository,
LocaleContextInterface $localeContext,
ConfigurableViewHandlerInterface $viewHandler,
private ProductRepositoryInterface $productRepository,
private LocaleContextInterface $localeContext,
private ConfigurableViewHandlerInterface $viewHandler,
) {
$this->productRepository = $productRepository;
$this->localeContext = $localeContext;
$this->viewHandler = $viewHandler;
}

public function __invoke(Request $request): Response
Expand Down
20 changes: 4 additions & 16 deletions src/Controller/Action/ProvinceSearchAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,12 @@

final class ProvinceSearchAction
{
private AddressRepositoryInterface $addressRepository;

private RepositoryInterface $provinceRepository;

private RepositoryInterface $countryRepository;

private ConfigurableViewHandlerInterface $viewHandler;

public function __construct(
AddressRepositoryInterface $addressRepository,
RepositoryInterface $provinceRepository,
RepositoryInterface $countryRepository,
ConfigurableViewHandlerInterface $viewHandler,
private AddressRepositoryInterface $addressRepository,
private RepositoryInterface $provinceRepository,
private RepositoryInterface $countryRepository,
private ConfigurableViewHandlerInterface $viewHandler,
) {
$this->addressRepository = $addressRepository;
$this->provinceRepository = $provinceRepository;
$this->countryRepository = $countryRepository;
$this->viewHandler = $viewHandler;
}

public function __invoke(Request $request): Response
Expand Down
8 changes: 3 additions & 5 deletions src/DataFetcher/BaseDataFetcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@

abstract class BaseDataFetcher implements DataFetcherInterface
{
protected QueryFilterInterface $queryFilter;

public function __construct(QueryFilterInterface $queryFilter)
{
$this->queryFilter = $queryFilter;
public function __construct(
protected QueryFilterInterface $queryFilter,
) {
}

/**
Expand Down
11 changes: 3 additions & 8 deletions src/DataFetcher/DelegatingDataFetcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,9 @@

class DelegatingDataFetcher implements DelegatingDataFetcherInterface
{
/**
* DataFetcher registry.
*/
protected ServiceRegistryInterface $registry;

public function __construct(ServiceRegistryInterface $registry)
{
$this->registry = $registry;
public function __construct(
protected ServiceRegistryInterface $registry,
) {
}

public function fetch(ReportInterface $report, array $configuration = []): Data
Expand Down
6 changes: 1 addition & 5 deletions src/DataFetcher/NumberOfOrdersDataFetcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,11 @@

class NumberOfOrdersDataFetcher extends TimePeriodDataFetcher
{
private string $orderClass;

public function __construct(
private string $orderClass,
QueryFilterInterface $queryFilter,
string $orderClass,
) {
parent::__construct($queryFilter);

$this->orderClass = $orderClass;
}

protected function setupQueryFilter(array $configuration = []): void
Expand Down
6 changes: 1 addition & 5 deletions src/DataFetcher/SalesTotalDataFetcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,11 @@

class SalesTotalDataFetcher extends TimePeriodDataFetcher
{
private string $orderClass;

public function __construct(
private string $orderClass,
QueryFilterInterface $queryFilter,
string $orderClass,
) {
parent::__construct($queryFilter);

$this->orderClass = $orderClass;
}

protected function setupQueryFilter(array $configuration = []): void
Expand Down
6 changes: 1 addition & 5 deletions src/DataFetcher/UserRegistrationDataFetcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,11 @@

class UserRegistrationDataFetcher extends TimePeriodDataFetcher
{
private string $userClass;

public function __construct(
private string $userClass,
QueryFilterInterface $queryFilter,
string $userClass,
) {
parent::__construct($queryFilter);

$this->userClass = $userClass;
}

protected function setupQueryFilter(array $configuration = []): void
Expand Down
21 changes: 9 additions & 12 deletions src/Filter/QueryFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,14 @@

class QueryFilter implements QueryFilterInterface
{
protected EntityManager $em;

protected QueryBuilder $qb;

protected array $joins = [];

public function __construct(EntityManager $entityManager)
{
$this->em = $entityManager;

$this->qb = $this->em->createQueryBuilder();
public function __construct(
protected EntityManager $em,
) {
$this->qb = $em->createQueryBuilder();
}

public function getQueryBuilder(): QueryBuilder
Expand All @@ -48,7 +45,7 @@ protected function getGroupByParts(
array $configuration = [],
string $dateField = 'checkoutCompletedAt',
): array {
if (false === strpos($dateField, '.')) {
if (!str_contains($dateField, '.')) {
$rootAlias = $qb->getRootAliases()[0];
$dateF = $rootAlias . '.' . $dateField;
} else {
Expand All @@ -62,10 +59,10 @@ protected function getGroupByParts(
$selectPeriod .= ', ';
$selectGroupBy .= ',';
}
$salias = ucfirst(strtolower($groupByElement)) . 'Date';
$selectPeriod .= $groupByElement . '(' . $dateF . ') as ' . $salias;
$alias = ucfirst(strtolower($groupByElement)) . 'Date';
$selectPeriod .= $groupByElement . '(' . $dateF . ') as ' . $alias;

$selectGroupBy .= $salias;
$selectGroupBy .= $alias;
}

return [$selectPeriod, $selectGroupBy];
Expand All @@ -87,7 +84,7 @@ public function addTimePeriod(
string $dateField = 'checkoutCompletedAt',
?string $rootAlias = null,
): void {
if (false === strpos($dateField, '.')) {
if (!str_contains($dateField, '.')) {
if (null === $rootAlias) {
$rootAlias = $this->qb->getRootAliases()[0];
}
Expand Down
25 changes: 5 additions & 20 deletions src/Form/Builder/QueryFilterFormBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,13 @@

class QueryFilterFormBuilder implements QueryFilterFormBuilderInterface
{
protected RepositoryInterface $addressRepository;

protected TaxonRepositoryInterface $taxonRepository;

protected ProductRepositoryInterface $productRepository;

protected ChannelRepositoryInterface $channelRepository;

protected UrlGeneratorInterface $generator;

public function __construct(
RepositoryInterface $addressRepository,
TaxonRepositoryInterface $taxonRepository,
ProductRepositoryInterface $productRepository,
ChannelRepositoryInterface $channelRepository,
UrlGeneratorInterface $generator,
protected RepositoryInterface $addressRepository,
protected TaxonRepositoryInterface $taxonRepository,
protected ProductRepositoryInterface $productRepository,
protected ChannelRepositoryInterface $channelRepository,
protected UrlGeneratorInterface $generator,
) {
$this->addressRepository = $addressRepository;
$this->taxonRepository = $taxonRepository;
$this->productRepository = $productRepository;
$this->channelRepository = $channelRepository;
$this->generator = $generator;
}

public function addUserGender(FormBuilderInterface &$builder): void
Expand Down
12 changes: 4 additions & 8 deletions src/Form/EventListener/BuildReportDataFetcherFormSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,10 @@

class BuildReportDataFetcherFormSubscriber implements EventSubscriberInterface
{
private ServiceRegistryInterface $dataFetcherRegistry;

private FormFactoryInterface $factory;

public function __construct(ServiceRegistryInterface $dataFetcherRegistry, FormFactoryInterface $factory)
{
$this->dataFetcherRegistry = $dataFetcherRegistry;
$this->factory = $factory;
public function __construct(
private ServiceRegistryInterface $dataFetcherRegistry,
private FormFactoryInterface $factory,
) {
}

public static function getSubscribedEvents(): array
Expand Down
12 changes: 4 additions & 8 deletions src/Form/EventListener/BuildReportRendererFormSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,10 @@

class BuildReportRendererFormSubscriber implements EventSubscriberInterface
{
private ServiceRegistryInterface $rendererRegistry;

private FormFactoryInterface $factory;

public function __construct(ServiceRegistryInterface $rendererRegistry, FormFactoryInterface $factory)
{
$this->rendererRegistry = $rendererRegistry;
$this->factory = $factory;
public function __construct(
private ServiceRegistryInterface $rendererRegistry,
private FormFactoryInterface $factory,
) {
}

public static function getSubscribedEvents(): array
Expand Down
8 changes: 3 additions & 5 deletions src/Form/Type/DataFetcher/BaseDataFetcherType.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@

abstract class BaseDataFetcherType extends AbstractType
{
protected QueryFilterFormBuilderInterface $queryFilterFormBuilder;

public function __construct(QueryFilterFormBuilderInterface $queryFilterFormBuilder)
{
$this->queryFilterFormBuilder = $queryFilterFormBuilder;
public function __construct(
protected QueryFilterFormBuilderInterface $queryFilterFormBuilder,
) {
}
}
10 changes: 3 additions & 7 deletions src/Form/Type/DataFetcher/DataFetcherChoiceType.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,9 @@

class DataFetcherChoiceType extends AbstractType
{
protected array $dataFetchers;

public function __construct(array $dataFetchers)
{
/**
* @phpstan-ignore-next-line
*/
public function __construct(
protected array $dataFetchers,
) {
$this->dataFetchers = array_combine(array_values($dataFetchers), array_keys($dataFetchers));
}

Expand Down
10 changes: 3 additions & 7 deletions src/Form/Type/Renderer/RendererChoiceType.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,9 @@

class RendererChoiceType extends AbstractType
{
protected array $renderers;

public function __construct(array $renderers)
{
/**
* @phpstan-ignore-next-line
*/
public function __construct(
protected array $renderers,
) {
$this->renderers = array_combine(array_values($renderers), array_keys($renderers));
}

Expand Down
8 changes: 1 addition & 7 deletions src/Form/Type/ReportDataFetcherConfigurationType.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,12 @@

class ReportDataFetcherConfigurationType extends AbstractResourceType
{
protected DelegatingDataFetcherInterface $delegatingDataFetcher;

protected string $dataFetcherConfigurationTemplate;

public function __construct(
protected DelegatingDataFetcherInterface $delegatingDataFetcher,
string $dataClass,
array $validationGroups,
DelegatingDataFetcherInterface $delegatingDataFetcher,
) {
parent::__construct($dataClass, $validationGroups);

$this->delegatingDataFetcher = $delegatingDataFetcher;
}

public function buildForm(FormBuilderInterface $builder, array $options): void
Expand Down
Loading

0 comments on commit 69870ec

Please sign in to comment.