Browse Source

[Technique] Remplacer la notion de "Utils" par "Manager" #1341

feature/souke
Guillaume Bourgeois 1 year ago
parent
commit
72b3ec20cc
23 changed files with 67 additions and 89 deletions
  1. +1
    -1
      backend/controllers/UserController.php
  2. +8
    -0
      common/logic/AbstractManager.php
  3. +1
    -21
      common/logic/AbstractService.php
  4. +0
    -8
      common/logic/AbstractUtils.php
  5. +5
    -6
      common/logic/Document/Document/Module/DocumentModule.php
  6. +2
    -4
      common/logic/Document/Document/Service/DocumentManager.php
  7. +1
    -1
      common/logic/ManagerInterface.php
  8. +5
    -5
      common/logic/Opinion/Module/OpinionModule.php
  9. +2
    -2
      common/logic/Opinion/Service/OpinionManager.php
  10. +4
    -4
      common/logic/Order/Order/Module/OrderModule.php
  11. +11
    -0
      common/logic/Order/Order/Service/OrderManager.php
  12. +0
    -11
      common/logic/Order/Order/Service/OrderUtils.php
  13. +5
    -5
      common/logic/Payment/Module/PaymentModule.php
  14. +2
    -2
      common/logic/Payment/Service/PaymentManager.php
  15. +5
    -5
      common/logic/Producer/Producer/Module/ProducerModule.php
  16. +2
    -2
      common/logic/Producer/Producer/Service/DolibarrProducerUtils.php
  17. +2
    -2
      common/logic/Producer/Producer/Service/ProducerManager.php
  18. +2
    -2
      common/logic/Producer/Producer/Service/ProducerPageSizer.php
  19. +2
    -2
      common/logic/User/User/Service/AuthorizationChecker.php
  20. +2
    -2
      common/logic/User/User/Service/NewsletterManager.php
  21. +2
    -2
      common/logic/User/User/Service/UserNotifier.php
  22. +2
    -1
      frontend/controllers/SiteController.php
  23. +1
    -1
      frontend/views/site/service.php

+ 1
- 1
backend/controllers/UserController.php View File

$creditForm = new CreditForm(); $creditForm = new CreditForm();
if ($creditForm->load(\Yii::$app->request->post()) && $creditForm->validate()) { if ($creditForm->load(\Yii::$app->request->post()) && $creditForm->validate()) {


$paymentModule->getUtils()
$paymentModule->getManager()
->creditOrDebitUser( ->creditOrDebitUser(
$creditForm->type, $creditForm->type,
$user, $user,

+ 8
- 0
common/logic/AbstractManager.php View File

<?php

namespace common\logic;

abstract class AbstractManager extends AbstractService implements ManagerInterface
{

}

+ 1
- 21
common/logic/AbstractService.php View File

NotifierInterface::class, NotifierInterface::class,
ResolverInterface::class, ResolverInterface::class,
GeneratorInterface::class, GeneratorInterface::class,
UtilsInterface::class,
ManagerInterface::class,
]; ];
} }


FactoryInterface, SolverInterface ou BuilderInterface au service.'); FactoryInterface, SolverInterface ou BuilderInterface au service.');
} }


protected function isSolver(): bool
{
return $this->classImplementsInterface(SolverInterface::class);
}

protected function isBuilder(): bool
{
return $this->classImplementsInterface(BuilderInterface::class);
}

protected function isResolver(): bool
{
return $this->classImplementsInterface(ResolverInterface::class);
}

protected function isUtils(): bool
{
return $this->classImplementsInterface(UtilsInterface::class);
}

protected function classImplementsInterface(string $interface, $object = null) protected function classImplementsInterface(string $interface, $object = null)
{ {
if(is_null($object)) { if(is_null($object)) {

+ 0
- 8
common/logic/AbstractUtils.php View File

<?php

namespace common\logic;

abstract class AbstractUtils extends AbstractService implements UtilsInterface
{

}

+ 5
- 6
common/logic/Document/Document/Module/DocumentModule.php View File

namespace common\logic\Document\Document\Module; namespace common\logic\Document\Document\Module;


use common\logic\AbstractModule; use common\logic\AbstractModule;
use common\logic\DefinitionInterface;
use common\logic\Document\Document\Repository\DocumentRepository; use common\logic\Document\Document\Repository\DocumentRepository;
use common\logic\Document\Document\Service\DocumentBuilder; use common\logic\Document\Document\Service\DocumentBuilder;
use common\logic\Document\Document\Service\DocumentDefinition; use common\logic\Document\Document\Service\DocumentDefinition;
use common\logic\Document\Document\Service\DocumentSolver; use common\logic\Document\Document\Service\DocumentSolver;
use common\logic\Document\Document\Service\DocumentUtils;
use common\logic\Document\Document\Service\DocumentManager;


/** /**
* @mixin DocumentDefinition * @mixin DocumentDefinition
* @mixin DocumentSolver * @mixin DocumentSolver
* @mixin DocumentBuilder * @mixin DocumentBuilder
* @mixin DocumentUtils
* @mixin DocumentManager
*/ */
class DocumentModule extends AbstractModule class DocumentModule extends AbstractModule
{ {
DocumentSolver::class, DocumentSolver::class,
DocumentRepository::class, DocumentRepository::class,
DocumentBuilder::class, DocumentBuilder::class,
DocumentUtils::class,
DocumentManager::class,
]; ];
} }


return DocumentBuilder::getInstance(); return DocumentBuilder::getInstance();
} }


public function getUtils()
public function getManager()
{ {
return DocumentUtils::getInstance();
return DocumentManager::getInstance();
} }
} }

common/logic/Document/Document/Service/DocumentUtils.php → common/logic/Document/Document/Service/DocumentManager.php View File



namespace common\logic\Document\Document\Service; namespace common\logic\Document\Document\Service;


use common\helpers\GlobalParam;
use common\logic\AbstractService;
use common\logic\AbstractManager;
use common\logic\Document\Document\Model\DocumentInterface; use common\logic\Document\Document\Model\DocumentInterface;
use common\logic\Producer\Producer\Service\ProducerSolver; use common\logic\Producer\Producer\Service\ProducerSolver;
use common\logic\UtilsInterface;
use kartik\mpdf\Pdf; use kartik\mpdf\Pdf;
use yii\base\ErrorException; use yii\base\ErrorException;
use yii\helpers\Html; use yii\helpers\Html;


class DocumentUtils extends AbstractService implements UtilsInterface
class DocumentManager extends AbstractManager
{ {
protected DocumentSolver $documentSolver; protected DocumentSolver $documentSolver;
protected DocumentBuilder $documentBuilder; protected DocumentBuilder $documentBuilder;

common/logic/UtilsInterface.php → common/logic/ManagerInterface.php View File



namespace common\logic; namespace common\logic;


interface UtilsInterface
interface ManagerInterface
{ {


} }

+ 5
- 5
common/logic/Opinion/Module/OpinionModule.php View File

namespace common\logic\Opinion\Module; namespace common\logic\Opinion\Module;


use common\logic\AbstractModule; use common\logic\AbstractModule;
use common\logic\Opinion\Service\OpinionUtils;
use common\logic\Opinion\Service\OpinionManager;


/** /**
* @mixin OpinionUtils
* @mixin OpinionManager
*/ */
class OpinionModule extends AbstractModule class OpinionModule extends AbstractModule
{ {
public function getServices(): array public function getServices(): array
{ {
return [ return [
OpinionUtils::class
OpinionManager::class
]; ];
} }


public function getUtils(): OpinionUtils
public function getManager(): OpinionManager
{ {
return OpinionUtils::getInstance();
return OpinionManager::getInstance();
} }
} }

common/logic/Opinion/Service/OpinionUtils.php → common/logic/Opinion/Service/OpinionManager.php View File



namespace common\logic\Opinion\Service; namespace common\logic\Opinion\Service;


use common\logic\AbstractUtils;
use common\logic\AbstractManager;
use common\logic\User\User\Model\User; use common\logic\User\User\Model\User;
use common\logic\User\User\Service\UserSolver; use common\logic\User\User\Service\UserSolver;


class OpinionUtils extends AbstractUtils
class OpinionManager extends AbstractManager
{ {
protected UserSolver $userSolver; protected UserSolver $userSolver;



+ 4
- 4
common/logic/Order/Order/Module/OrderModule.php View File

use common\logic\Order\Order\Service\OrderBuilder; use common\logic\Order\Order\Service\OrderBuilder;
use common\logic\Order\Order\Service\OrderDefinition; use common\logic\Order\Order\Service\OrderDefinition;
use common\logic\Order\Order\Service\OrderSolver; use common\logic\Order\Order\Service\OrderSolver;
use common\logic\Order\Order\Service\OrderUtils;
use common\logic\Order\Order\Service\OrderManager;


/** /**
* @mixin OrderDefinition * @mixin OrderDefinition
OrderSolver::class, OrderSolver::class,
OrderRepository::class, OrderRepository::class,
OrderBuilder::class, OrderBuilder::class,
OrderUtils::class
OrderManager::class
]; ];
} }


return OrderBuilder::getInstance(); return OrderBuilder::getInstance();
} }


public function getUtils(): OrderUtils
public function getUtils(): OrderManager
{ {
return OrderUtils::getInstance();
return OrderManager::getInstance();
} }
} }

+ 11
- 0
common/logic/Order/Order/Service/OrderManager.php View File

<?php

namespace common\logic\Order\Order\Service;

use common\logic\AbstractService;
use common\logic\ManagerInterface;

class OrderManager extends AbstractService implements ManagerInterface
{
}

+ 0
- 11
common/logic/Order/Order/Service/OrderUtils.php View File

<?php

namespace common\logic\Order\Order\Service;

use common\logic\AbstractService;
use common\logic\UtilsInterface;

class OrderUtils extends AbstractService implements UtilsInterface
{
}

+ 5
- 5
common/logic/Payment/Module/PaymentModule.php View File

use common\logic\AbstractModule; use common\logic\AbstractModule;
use common\logic\Payment\Repository\PaymentRepository; use common\logic\Payment\Repository\PaymentRepository;
use common\logic\Payment\Service\PaymentNotifier; use common\logic\Payment\Service\PaymentNotifier;
use common\logic\Payment\Service\PaymentUtils;
use common\logic\Payment\Service\PaymentManager;
use common\logic\Payment\Service\PaymentBuilder; use common\logic\Payment\Service\PaymentBuilder;
use common\logic\Payment\Service\PaymentDefinition; use common\logic\Payment\Service\PaymentDefinition;
use common\logic\Payment\Service\PaymentSolver; use common\logic\Payment\Service\PaymentSolver;
* @mixin PaymentSolver * @mixin PaymentSolver
* @mixin PaymentRepository * @mixin PaymentRepository
* @mixin PaymentBuilder * @mixin PaymentBuilder
* @mixin PaymentUtils
* @mixin PaymentManager
*/ */
class PaymentModule extends AbstractModule class PaymentModule extends AbstractModule
{ {
PaymentBuilder::class, PaymentBuilder::class,
PaymentRepository::class, PaymentRepository::class,
PaymentNotifier::class, PaymentNotifier::class,
PaymentUtils::class,
PaymentManager::class,
]; ];
} }


return PaymentNotifier::getInstance(); return PaymentNotifier::getInstance();
} }


public function getUtils(): PaymentUtils
public function getManager(): PaymentManager
{ {
return PaymentUtils::getInstance();
return PaymentManager::getInstance();
} }
} }

common/logic/Payment/Service/PaymentUtils.php → common/logic/Payment/Service/PaymentManager.php View File

use common\logic\Producer\Producer\Service\ProducerSolver; use common\logic\Producer\Producer\Service\ProducerSolver;
use common\logic\User\User\Model\User; use common\logic\User\User\Model\User;
use common\logic\User\User\Repository\UserRepository; use common\logic\User\User\Repository\UserRepository;
use common\logic\UtilsInterface;
use common\logic\ManagerInterface;
use yii\base\ErrorException; use yii\base\ErrorException;


class PaymentUtils extends AbstractService implements UtilsInterface
class PaymentManager extends AbstractService implements ManagerInterface
{ {
protected PaymentBuilder $paymentBuilder; protected PaymentBuilder $paymentBuilder;
protected OrderSolver $orderSolver; protected OrderSolver $orderSolver;

+ 5
- 5
common/logic/Producer/Producer/Module/ProducerModule.php View File

use common\logic\Producer\Producer\Service\ProducerDefinition; use common\logic\Producer\Producer\Service\ProducerDefinition;
use common\logic\Producer\Producer\Service\ProducerPageSizer; use common\logic\Producer\Producer\Service\ProducerPageSizer;
use common\logic\Producer\Producer\Service\ProducerSolver; use common\logic\Producer\Producer\Service\ProducerSolver;
use common\logic\Producer\Producer\Service\ProducerUtils;
use common\logic\Producer\Producer\Service\ProducerManager;


/** /**
* @mixin ProducerDefinition * @mixin ProducerDefinition
* @mixin ProducerSolver * @mixin ProducerSolver
* @mixin ProducerRepository * @mixin ProducerRepository
* @mixin ProducerBuilder * @mixin ProducerBuilder
* @mixin ProducerUtils
* @mixin ProducerManager
* @mixin ProducerPageSizer * @mixin ProducerPageSizer
* @mixin DolibarrProducerUtils * @mixin DolibarrProducerUtils
*/ */
ProducerSolver::class, ProducerSolver::class,
ProducerRepository::class, ProducerRepository::class,
ProducerBuilder::class, ProducerBuilder::class,
ProducerUtils::class,
ProducerManager::class,
ProducerPageSizer::class, ProducerPageSizer::class,
DolibarrProducerUtils::class, DolibarrProducerUtils::class,
]; ];
return ProducerBuilder::getInstance(); return ProducerBuilder::getInstance();
} }


public function getUtils(): ProducerUtils
public function getUtils(): ProducerManager
{ {
return ProducerUtils::getInstance();
return ProducerManager::getInstance();
} }


public function getProducerPageSizer(): ProducerPageSizer public function getProducerPageSizer(): ProducerPageSizer

+ 2
- 2
common/logic/Producer/Producer/Service/DolibarrProducerUtils.php View File

namespace common\logic\Producer\Producer\Service; namespace common\logic\Producer\Producer\Service;


use common\components\DolibarrApi; use common\components\DolibarrApi;
use common\logic\AbstractUtils;
use common\logic\AbstractManager;
use common\logic\Producer\Producer\Model\Producer; use common\logic\Producer\Producer\Model\Producer;
use common\logic\Producer\Producer\Repository\ProducerRepository; use common\logic\Producer\Producer\Repository\ProducerRepository;
use common\logic\Producer\ProducerPriceRange\Repository\ProducerPriceRangeRepository; use common\logic\Producer\ProducerPriceRange\Repository\ProducerPriceRangeRepository;
use yii\base\ErrorException; use yii\base\ErrorException;


class DolibarrProducerUtils extends AbstractUtils
class DolibarrProducerUtils extends AbstractManager
{ {
protected DolibarrApi $dolibarrApi; protected DolibarrApi $dolibarrApi;
protected ProducerPriceRangeRepository $producerPriceRangeRepository; protected ProducerPriceRangeRepository $producerPriceRangeRepository;

common/logic/Producer/Producer/Service/ProducerUtils.php → common/logic/Producer/Producer/Service/ProducerManager.php View File



use common\logic\AbstractService; use common\logic\AbstractService;
use common\logic\Producer\Producer\Model\Producer; use common\logic\Producer\Producer\Model\Producer;
use common\logic\UtilsInterface;
use common\logic\ManagerInterface;


class ProducerUtils extends AbstractService implements UtilsInterface
class ProducerManager extends AbstractService implements ManagerInterface
{ {
public function sendEmailNewProducer(Producer $producer): void public function sendEmailNewProducer(Producer $producer): void
{ {

+ 2
- 2
common/logic/Producer/Producer/Service/ProducerPageSizer.php View File

namespace common\logic\Producer\Producer\Service; namespace common\logic\Producer\Producer\Service;


use common\components\PageSizer; use common\components\PageSizer;
use common\logic\AbstractUtils;
use common\logic\AbstractManager;
use common\logic\Producer\Producer\Model\Producer; use common\logic\Producer\Producer\Model\Producer;


class ProducerPageSizer extends AbstractUtils
class ProducerPageSizer extends AbstractManager
{ {
protected ProducerSolver $producerSolver; protected ProducerSolver $producerSolver;
protected ProducerBuilder $producerBuilder; protected ProducerBuilder $producerBuilder;

+ 2
- 2
common/logic/User/User/Service/AuthorizationChecker.php View File



namespace common\logic\User\User\Service; namespace common\logic\User\User\Service;


use common\logic\AbstractUtils;
use common\logic\AbstractManager;
use common\logic\User\User\Model\User; use common\logic\User\User\Model\User;


class AuthorizationChecker extends AbstractUtils
class AuthorizationChecker extends AbstractManager
{ {
protected UserSolver $userSolver; protected UserSolver $userSolver;



+ 2
- 2
common/logic/User/User/Service/NewsletterManager.php View File

use common\logic\User\User\Model\User; use common\logic\User\User\Model\User;
use common\logic\User\UserProducer\Repository\UserProducerRepository; use common\logic\User\UserProducer\Repository\UserProducerRepository;
use common\logic\User\UserProducer\Service\UserProducerBuilder; use common\logic\User\UserProducer\Service\UserProducerBuilder;
use common\logic\UtilsInterface;
use common\logic\ManagerInterface;


class NewsletterManager extends AbstractService implements UtilsInterface
class NewsletterManager extends AbstractService implements ManagerInterface
{ {
protected UserProducerRepository $userProducerRepository; protected UserProducerRepository $userProducerRepository;
protected UserProducerBuilder $userProducerBuilder; protected UserProducerBuilder $userProducerBuilder;

+ 2
- 2
common/logic/User/User/Service/UserNotifier.php View File

use common\logic\Producer\Producer\Model\Producer; use common\logic\Producer\Producer\Model\Producer;
use common\logic\Ticket\Ticket\Model\Ticket; use common\logic\Ticket\Ticket\Model\Ticket;
use common\logic\User\User\Model\User; use common\logic\User\User\Model\User;
use common\logic\UtilsInterface;
use common\logic\ManagerInterface;


class UserNotifier extends AbstractNotifier implements UtilsInterface
class UserNotifier extends AbstractNotifier implements ManagerInterface
{ {
protected UserSolver $userSolver; protected UserSolver $userSolver;



+ 2
- 1
frontend/controllers/SiteController.php View File

$opinionFormModel = new OpinionForm(); $opinionFormModel = new OpinionForm();
$opinionSent = false; $opinionSent = false;
if ($opinionFormModel->load(Yii::$app->request->post()) && $opinionFormModel->validate()) { if ($opinionFormModel->load(Yii::$app->request->post()) && $opinionFormModel->validate()) {
$this->getOpinionModule()->sendOpinionEmailAdmin($opinionFormModel, $this->getUserCurrent());
$this->getOpinionModule()->getManager()
->sendOpinionEmailAdmin($opinionFormModel, $this->getUserCurrent());
$opinionSent = true; $opinionSent = true;
} }



+ 1
- 1
frontend/views/site/service.php View File

<?= block_feature("cog", "Une administration complète et intuitive pour gérer votre activité de producteur."); ?> <?= block_feature("cog", "Une administration complète et intuitive pour gérer votre activité de producteur."); ?>
<div class="clr"></div> <div class="clr"></div>
<?= block_feature("calendar", "Planification des jours de distributions."); ?> <?= block_feature("calendar", "Planification des jours de distributions."); ?>
<?= block_feature("download-alt", "Accès à un récapitulatif des commandes par jour de distribution."); ?>
<?= block_feature("download-alt", "Récapitulatif des commandes par jour de distribution (PDF et CSV).<br />Génération d'étiquettes (PDF)."); ?>
<?= block_feature("cutlery", "Gestion des produits, catégories et prix spécifiques."); ?> <?= block_feature("cutlery", "Gestion des produits, catégories et prix spécifiques."); ?>
<?= block_feature("map-marker", "Gestion des points de vente."); ?> <?= block_feature("map-marker", "Gestion des points de vente."); ?>
<?= block_feature("repeat", "Gestion des abonnements pour les commandes récurrentes."); ?> <?= block_feature("repeat", "Gestion des abonnements pour les commandes récurrentes."); ?>

Loading…
Cancel
Save