Skip to content

Commit

Permalink
Merge pull request #17 from mon-petit-placement/feat/change-xmlrpc-bu…
Browse files Browse the repository at this point in the history
…ndle

feat: change xmlrpc bundle
  • Loading branch information
Celine68 authored Oct 3, 2023
2 parents f4abb8f + 64dedc6 commit 58adf95
Show file tree
Hide file tree
Showing 37 changed files with 875 additions and 2,714 deletions.
12 changes: 3 additions & 9 deletions Controller/CallbackController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,9 @@

class CallbackController extends AbstractController
{
/**
* @var LoggerInterface
*/
private $logger;
private LoggerInterface $logger;

/**
* @var EventDispatcherInterface
*/
private $dispatcher;
private EventDispatcherInterface $dispatcher;

public function __construct(LoggerInterface $logger, EventDispatcherInterface $dispatcher)
{
Expand All @@ -31,7 +25,7 @@ public function __construct(LoggerInterface $logger, EventDispatcherInterface $d
/**
* @Route("/universign/callback", name="mpp_universign_callback", methods="GET")
*/
public function process(Request $request)
public function process(Request $request): Response
{
$status = $request->query->get('status');
$transactionId = $request->query->get('id');
Expand Down
4 changes: 2 additions & 2 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

class Configuration implements ConfigurationInterface
{
const CONFIGURATION_ROOT = 'mpp_universign';
public const CONFIGURATION_ROOT = 'mpp_universign';

public function getConfigTreeBuilder()
public function getConfigTreeBuilder(): TreeBuilder
{
$treeBuilder = new TreeBuilder(self::CONFIGURATION_ROOT);

Expand Down
8 changes: 2 additions & 6 deletions DependencyInjection/MppUniversignExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,11 @@

class MppUniversignExtension extends Extension
{
/**
* @param array $configs
* @param ContainerBuilder $container
*/
public function load(array $configs, ContainerBuilder $container)
public function load(array $configs, ContainerBuilder $container): void
{
$configuration = new Configuration($container->getParameter('kernel.debug'));
$config = $this->processConfiguration($configuration, $configs);
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader->load('services.yaml');

$container->setParameter(
Expand Down
43 changes: 10 additions & 33 deletions Event/UniversignCallbackEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,62 +4,39 @@

class UniversignCallbackEvent
{
const STATUS_READY = 0;
const STATUS_EXPIRED = 1;
const STATUS_COMPLETED = 2;
const STATUS_CANCELED = 3;
const STATUS_ERROR = 4;
public const STATUS_READY = 0;
public const STATUS_EXPIRED = 1;
public const STATUS_COMPLETED = 2;
public const STATUS_CANCELED = 3;
public const STATUS_ERROR = 4;
/**
* All signatories have signed BUT waiting for Universign registration authority validation.
*/
const STATUS_SIGNED = 5;
public const STATUS_SIGNED = 5;

/**
* @var string
*/
private $transactionId;
private string $transactionId;

/**
* @var int|null
*/
private $indexSigner;
private ?int $indexSigner;

/**
* @var int
*/
private $status;
private int $status;

/**
* @param string $transactionId
* @param int|null $indexSigner
* @param int $status
*/
public function __construct(string $transactionId, ?int $indexSigner, int $status)
{
$this->transactionId = $transactionId;
$this->indexSigner = $indexSigner;
$this->status = $status;
}

/**
* @retrun string
*/
public function getTransactionId()
public function getTransactionId(): string
{
return $this->transactionId;
}

/**
* @return int
*/
public function getIndexSigner(): ?int
{
return $this->indexSigner;
}

/**
* @return int
*/
public function getStatus(): int
{
return $this->status;
Expand Down
56 changes: 11 additions & 45 deletions Model/CertificateInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,24 @@
use Symfony\Component\OptionsResolver\Exception\NoSuchOptionException;
use Symfony\Component\OptionsResolver\Exception\OptionDefinitionException;
use Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException;
use Symfony\Component\OptionsResolver\Options;
use Symfony\Component\OptionsResolver\OptionsResolver;

class CertificateInfo
{
/**
* @var string
*/
protected $subject;
protected ?string $subject;

/**
* @var string
*/
protected $issuer;
protected ?string $issuer;

/**
* @var string
*/
protected $serial;
protected ?string $serial;

/**
* @param OptionsResolver $resolver
*/
public static function configureData(OptionsResolver $resolver)
public function __construct()
{
$this->subject = null;
$this->issuer = null;
$this->serial = null;
}

public static function configureData(OptionsResolver $resolver): void
{
$resolver
->setDefault('subject', null)->setAllowedTypes('subject', ['null', 'string'])
Expand All @@ -41,10 +35,6 @@ public static function configureData(OptionsResolver $resolver)
}

/**
* @param array $options
*
* @return self
*
* @throws UndefinedOptionsException If an option name is undefined
* @throws InvalidOptionsException If an option doesn't fulfill the language specified validation rules
* @throws MissingOptionsException If a required option is missing
Expand All @@ -65,61 +55,37 @@ public static function createFromArray(array $options): self
;
}

/**
* @param string|null $subject
*
* @return self
*/
public function setSubject(?string $subject): self
{
$this->subject = $subject;

return $this;
}

/**
* @return string|null
*/
public function getSubject(): ?string
{
return $this->subject;
}

/**
* @param string|null $issuer
*
* @return self
*/
public function setIssuer(?string $issuer): self
{
$this->issuer = $issuer;

return $this;
}

/**
* @return string|null
*/
public function getIssuer(): ?string
{
return $this->issuer;
}

/**
* @param string|null $serial
*
* @return self
*/
public function setSerial(?string $serial): self
{
$this->serial = $serial;

return $this;
}

/**
* @return string|null
*/
public function getSerial(): ?string
{
return $this->serial;
Expand Down
6 changes: 3 additions & 3 deletions Model/CertificateType.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

class CertificateType
{
const SIMPLE = 'simple';
const CERTIFIED = 'certified';
const ADVANCED = 'advanced';
public const SIMPLE = 'simple';
public const CERTIFIED = 'certified';
public const ADVANCED = 'advanced';
}
69 changes: 18 additions & 51 deletions Model/DocSignatureField.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,51 +2,42 @@

namespace Mpp\UniversignBundle\Model;

use Mpp\UniversignBundle\Model\XmlRpc\Base64;
use Symfony\Component\OptionsResolver\Exception\AccessException;
use Symfony\Component\OptionsResolver\Exception\InvalidOptionsException;
use Symfony\Component\OptionsResolver\Exception\MissingOptionsException;
use Symfony\Component\OptionsResolver\Exception\NoSuchOptionException;
use Symfony\Component\OptionsResolver\Exception\OptionDefinitionException;
use Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException;
use Symfony\Component\OptionsResolver\Options;
use Symfony\Component\OptionsResolver\OptionsResolver;

class DocSignatureField extends SignatureField
{
/**
* @var string
*/
protected $patternName;
protected ?string $patternName;

/**
* @var string
*/
protected $label;
protected ?string $label;

/**
* @var \Laminas\XmlRpc\Value\Base64
*/
protected $image;
protected ?Base64 $image;

/**
* @param OptionsResolver $resolver
*/
public static function configureData(OptionsResolver $resolver)
public function __construct()
{
$this->patternName = null;
$this->label = null;
$this->image = null;
}

public static function configureData(OptionsResolver $resolver): void
{
parent::configureData($resolver);

$resolver
->setDefault('patternName', null)->setAllowedTypes('patternName', ['string', 'null'])
->setDefault('label', null)->setAllowedTypes('label', ['string', 'null'])
->setDefault('image', null)->setAllowedTypes('image', ['string', 'null'])
->setDefault('image', null)->setAllowedTypes('image', [Base64::class, 'null'])
;
}

/**
* @param array $options
*
* @return self
*
* @throws UndefinedOptionsException If an option name is undefined
* @throws InvalidOptionsException If an option doesn't fulfill the language specified validation rules
* @throws MissingOptionsException If a required option is missing
Expand All @@ -61,73 +52,49 @@ public static function createFromArray(array $options): self
$resolvedOptions = $resolver->resolve($options);

return (new self())
->setPatternName($resolvedOptions['patternName'])
->setLabel($resolvedOptions['label'])
->setImage($resolvedOptions['image'])
->setName($resolvedOptions['name'])
->setPage($resolvedOptions['page'])
->setX($resolvedOptions['x'])
->setY($resolvedOptions['y'])
->setSignerIndex($resolvedOptions['signerIndex'])
->setPatternName($resolvedOptions['patternName'])
->setLabel($resolvedOptions['label'])
->setImage($resolvedOptions['image'])
;
}

/**
* @param string $patternName
*
* @return self
*/
public function setPatternName(?string $patternName): self
{
$this->patternName = $patternName;

return $this;
}

/**
* @return string
*/
public function getPatternName(): string
{
return $this->patternName;
}

/**
* @param string $label
*
* @return self
*/
public function setLabel(?string $label): self
{
$this->label = $label;

return $this;
}

/**
* @return string
*/
public function getLabel(): string
{
return $this->label;
}

/**
* @param array $image
*
* @return self
*/
public function setImage(?array $image): self
public function setImage(?Base64 $image): self
{
$this->image = $image;

return $this;
}

/**
* @return \Laminas\XmlRpc\Value\Base64
*/
public function getImage(): \Laminas\XmlRpc\Value\Base64
public function getImage(): Base64
{
return $this->image;
}
Expand Down
Loading

0 comments on commit 58adf95

Please sign in to comment.