Skip to content

Commit

Permalink
Merge pull request #13 from stevro/migrate_sf7
Browse files Browse the repository at this point in the history
Migrate sf7
  • Loading branch information
stevro authored Sep 16, 2024
2 parents b03f64a + b066f30 commit 813c9ea
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 224 deletions.
8 changes: 4 additions & 4 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ class Configuration implements ConfigurationInterface
/**
* {@inheritdoc}
*/
public function getConfigTreeBuilder()
public function getConfigTreeBuilder(): TreeBuilder
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('stev_lista_firme');
$treeBuilder = new TreeBuilder('stev_lista_firme');
$rootNode = $treeBuilder->getRootNode();

$supportedCheckers = array(CIFChecker::CHECKER_LISTA_FIRME, CIFChecker::CHECKER_MFIN, CIFChecker::CHECKER_OPEN_API, CIFChecker::CHECKER_ANAF, CIFChecker::CHECKER_VIES);
$supportedCheckers = array(CIFChecker::CHECKER_LISTA_FIRME, CIFChecker::CHECKER_OPEN_API, CIFChecker::CHECKER_ANAF, CIFChecker::CHECKER_VIES);

$rootNode
->children()
Expand Down
5 changes: 0 additions & 5 deletions DependencyInjection/StevListaFirmeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@ public function load(array $configs, ContainerBuilder $container)
throw new \RuntimeException('Username and password are mandatory for listaFirme checker');
}
break;
case \Stev\ListaFirmeBundle\Lib\CIFChecker::CHECKER_MFIN:
if (!isset($config['pathToPhantom'])) {
$config['pathToPhantom'] = $container->getParameter('kernel.root_dir') . '/../bin/phantomjs';
}
break;
case \Stev\ListaFirmeBundle\Lib\CIFChecker::CHECKER_OPEN_API:
if (!isset($config['apiKey'])) {
throw new \RuntimeException('ApiKey is mandatory for OpenAPI checker since 15.09.2016');
Expand Down
17 changes: 4 additions & 13 deletions Lib/CIFChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ class CIFChecker
{

const CHECKER_LISTA_FIRME = 'listaFirme';
const CHECKER_MFIN = 'mFin';
const CHECKER_OPEN_API = 'openApi';
const CHECKER_ANAF = 'anaf';
const CHECKER_VIES = 'vies';
Expand All @@ -42,7 +41,7 @@ class CIFChecker
* @param bool $enabled If you set it to false it will completly disable the checker.
* @param LoggerInterface
*/
public function __construct($cifChecker, $username, $password, $offline = false, $enabled = true, $pathToPhantom = null, \Psr\Log\LoggerInterface $logger, $apiKey = null)
public function __construct($cifChecker, $username, $password, \Psr\Log\LoggerInterface $logger, $offline = false, $enabled = true, $apiKey = null)
{
$this->logger = $logger;

Expand All @@ -51,7 +50,6 @@ public function __construct($cifChecker, $username, $password, $offline = false,
'password' => $password,
'offline' => $offline,
'enabled' => $enabled,
'pathToPhantom' => $pathToPhantom,
'logger' => $logger,
'apiKey' => $apiKey,
];
Expand All @@ -60,9 +58,6 @@ public function __construct($cifChecker, $username, $password, $offline = false,
case self::CHECKER_LISTA_FIRME:
$this->setupCheckers(array(self::CHECKER_LISTA_FIRME, self::CHECKER_VIES));
break;
case self::CHECKER_MFIN:
$this->setupCheckers(array(self::CHECKER_MFIN));
break;
case self::CHECKER_OPEN_API:
$this->setupCheckers(array(self::CHECKER_OPEN_API, self::CHECKER_VIES, self::CHECKER_ANAF));
break;
Expand All @@ -87,9 +82,8 @@ public function __construct($cifChecker, $username, $password, $offline = false,
* [
'username' => string,
'password' => string,
'offlien' => bool,
'offline' => bool,
'enabled' => bool,
'pathToPhantom' => string,
'logger' => \Psr\Log\LoggerInterface,
'apiKey' => string,
]
Expand Down Expand Up @@ -123,17 +117,14 @@ private static function createCheckerInstance($checker, array $options)
case self::CHECKER_LISTA_FIRME:
return new ListaFirme($options['username'], $options['password'], $options['offline'], $options['enabled']);
break;
case self::CHECKER_MFIN:
return new MFin($options['offline'], $options['enabled'], $options['pathToPhantom']);
break;
case self::CHECKER_OPEN_API:
return new OpenAPI($options['offline'], $options['enabled'], $options['apiKey']);
return new OpenAPI($options['apiKey'], $options['offline'], $options['enabled']);
break;
case self::CHECKER_ANAF:
return new Anaf($options['offline'], $options['enabled']);
break;
case self::CHECKER_VIES:
return new Vies($options['offline'], $options['enabled'], $options['logger']);
return new Vies($options['logger'], $options['offline'], $options['enabled']);
break;
default:
throw new \InvalidArgumentException('You provided an invalid cifChecker ' . $checker);
Expand Down
148 changes: 0 additions & 148 deletions Lib/MFin.php

This file was deleted.

2 changes: 1 addition & 1 deletion Lib/OpenAPI.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class OpenAPI extends AbstractCIFChecker implements CIFCheckerInterface
*
* @param bool $offline Set it to true if list firme is down or if you want to disable the check. It will make the check to return a mocked(dummy) response.
*/
public function __construct($offline = false, $enabled = true, $apiKey)
public function __construct($apiKey, $offline = false, $enabled = true)
{
parent::__construct($offline, $enabled);

Expand Down
2 changes: 1 addition & 1 deletion Lib/Vies.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Vies extends AbstractCIFChecker implements CIFCheckerInterface
* WSDL Doc http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl
* To unblock your IP send an email to TAXUD-VIESWEB@ec.europa.eu
*/
public function __construct($offline = false, $enabled = true, \Psr\Log\LoggerInterface $logger)
public function __construct( \Psr\Log\LoggerInterface $logger, $offline = false, $enabled = true)
{
parent::__construct($offline, $enabled);

Expand Down
14 changes: 8 additions & 6 deletions Model/CompanyInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,27 @@ interface CompanyInterface

public function getLongName();

public function setLongName($longName);
public function setLongName(string $longName);

public function getCif();

public function setCif($cif);
public function setCif(string $cif);

public function getAddress();

public function setAddress($address);
public function setAddress(?string $address);

public function getCity();

public function setCity($city);
public function setCity(?string $city);

public function getCountry();

public function setCountry($country);
public function setCountry(string $country);

public function setRegistrationNumber($registrationNumber);
public function setRegistrationNumber(?string $registrationNumber);

public function getRegistrationNumber();

public function setIsVatPayer(bool $isVatPayer);
}
19 changes: 9 additions & 10 deletions Resources/config/services.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
services:
stev.lista_firme:
Stev\ListaFirmeBundle\Lib\CIFChecker:
class: Stev\ListaFirmeBundle\Lib\CIFChecker
arguments:
- %stev_lista_firme.cifChecker%
- %stev_lista_firme.username%
- %stev_lista_firme.password%
- %stev_lista_firme.offline%
- %stev_lista_firme.enabled%
- %stev_lista_firme.pathToPhantom%
- '%stev_lista_firme.cifChecker%'
- '%stev_lista_firme.username%'
- '%stev_lista_firme.password%'
- '@logger'
- %stev_lista_firme.apiKey%
- '%stev_lista_firme.offline%'
- '%stev_lista_firme.enabled%'
- '%stev_lista_firme.apiKey%'

stev.lista_firme.validator.is_valid_company:
Stev\ListaFirmeBundle\Validator\Constraints\IsValidCompanyValidator:
class: Stev\ListaFirmeBundle\Validator\Constraints\IsValidCompanyValidator
arguments: ['@stev.lista_firme','@logger']
arguments: ['@Stev\ListaFirmeBundle\Lib\CIFChecker','@logger']
tags:
- { name: validator.constraint_validator, alias: is_valid_company }
21 changes: 0 additions & 21 deletions Resources/public/browser.js

This file was deleted.

5 changes: 3 additions & 2 deletions Validator/Constraints/IsValidCompany.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,19 @@
/**
* @Annotation
*/
#[\Attribute]
class IsValidCompany extends Constraint
{

public $message = 'CIF-ul %string% nu este valid.';
public $details = '%string%';

public function getTargets()
public function getTargets(): array|string
{
return self::CLASS_CONSTRAINT;
}

public function validatedBy()
public function validatedBy(): string
{
return 'is_valid_company';
}
Expand Down
Loading

0 comments on commit 813c9ea

Please sign in to comment.