-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sysvmsg extension is no longer required + modernized module
- Loading branch information
Franck Allimant
committed
Aug 6, 2024
1 parent
713369b
commit 9f56542
Showing
10 changed files
with
106 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
name: "Auto Release" | ||
on: | ||
push: | ||
branches: [ master, main ] | ||
jobs: | ||
release: | ||
uses: thelia-modules/ReusableWorkflow/.github/workflows/auto_release.yml@main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
xsi:schemaLocation="http://thelia.net/schema/dic/module http://thelia.net/schema/dic/module/module-2_1.xsd"> | ||
<fullnamespace>InvoiceRef\InvoiceRef</fullnamespace> | ||
<descriptive locale="en_US"> | ||
<title>Manage invoive ref</title> | ||
<title>Invoice references management</title> | ||
</descriptive> | ||
<descriptive locale="fr_FR"> | ||
<title>Gestion des numéros de facture</title> | ||
|
@@ -13,7 +13,7 @@ | |
<language>en_US</language> | ||
<language>fr_FR</language> | ||
</languages> | ||
<version>2.0.0</version> | ||
<version>2.0.1</version> | ||
<author> | ||
<name>Manuel Raynaud</name> | ||
<email>[email protected]</email> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,68 @@ | ||
<?php | ||
/*************************************************************************************/ | ||
/* This file is part of the Thelia package. */ | ||
/* */ | ||
/* Copyright (c) OpenStudio */ | ||
/* email : [email protected] */ | ||
/* web : http://www.thelia.net */ | ||
/* */ | ||
/* For the full copyright and license information, please view the LICENSE.txt */ | ||
/* file that was distributed with this source code. */ | ||
/*************************************************************************************/ | ||
|
||
/* | ||
* This file is part of the Thelia package. | ||
* http://www.thelia.net | ||
* | ||
* (c) OpenStudio <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
/* Copyright (c) OpenStudio */ | ||
/* email : [email protected] */ | ||
/* web : http://www.thelia.net */ | ||
|
||
/* For the full copyright and license information, please view the LICENSE.txt */ | ||
/* file that was distributed with this source code. */ | ||
|
||
namespace InvoiceRef\EventListeners; | ||
|
||
use Symfony\Component\EventDispatcher\EventSubscriberInterface; | ||
use Symfony\Component\Lock\Factory; | ||
use Symfony\Component\Lock\LockFactory; | ||
use Symfony\Component\Lock\Store\FlockStore; | ||
use Symfony\Component\Lock\Store\SemaphoreStore; | ||
use Thelia\Core\Event\Order\OrderEvent; | ||
use Thelia\Core\Event\TheliaEvents; | ||
use Thelia\Log\Tlog; | ||
use Thelia\Model\ConfigQuery; | ||
|
||
/** | ||
* Class OrderListener | ||
* @package InvoiceRef\EventListeners | ||
* Class OrderListener. | ||
* | ||
* @author manuel raynaud <[email protected]> | ||
*/ | ||
class OrderListener implements EventSubscriberInterface | ||
{ | ||
/** | ||
* @param OrderEvent $event | ||
* @throws \Propel\Runtime\Exception\PropelException | ||
*/ | ||
public function implementInvoice(OrderEvent $event) | ||
public function implementInvoice(OrderEvent $event): void | ||
{ | ||
$order = $event->getOrder(); | ||
|
||
if ($order->isPaid() && null === $order->getInvoiceRef()) { | ||
$store = new SemaphoreStore(); | ||
$flockFactory = new LockFactory($store); | ||
$lock = null; | ||
|
||
$lock = $flockFactory->createLock('invoice-ref-generation'); | ||
// Try to acquire lock, being fault-tolerant if it can't be acquired | ||
// for whatever reason. | ||
try { | ||
$flockFactory = new LockFactory(new FlockStore()); | ||
|
||
$lock = $flockFactory->createLock('invoice-ref-generation'); | ||
|
||
// Acquire a blocking lock | ||
$lock->acquire(true); | ||
// Acquire a blocking lock | ||
$lock->acquire(true); | ||
} catch (\Exception $ex) { | ||
Tlog::getInstance()->error('Failed to acquire lock : '.$ex->getMessage()); | ||
} | ||
|
||
try { | ||
$invoiceRef = ConfigQuery::create() | ||
->findOneByName('invoiceRef'); | ||
|
||
if (null === $invoiceRef) { | ||
throw new \RuntimeException("you must set an invoice ref in your admin panel"); | ||
throw new \RuntimeException('you must set an invoice ref in your admin panel'); | ||
} | ||
|
||
$value = $invoiceRef->getValue(); | ||
|
@@ -62,7 +74,7 @@ public function implementInvoice(OrderEvent $event) | |
->save(); | ||
} finally { | ||
// Always release lock ! | ||
$lock->release(); | ||
$lock?->release(); | ||
} | ||
} | ||
} | ||
|
@@ -90,7 +102,7 @@ public function implementInvoice(OrderEvent $event) | |
public static function getSubscribedEvents() | ||
{ | ||
return [ | ||
TheliaEvents::ORDER_UPDATE_STATUS => ['implementInvoice', 100] | ||
TheliaEvents::ORDER_UPDATE_STATUS => ['implementInvoice', 100], | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
<?php | ||
/*************************************************************************************/ | ||
/* This file is part of the Thelia package. */ | ||
/* */ | ||
/* Copyright (c) OpenStudio */ | ||
/* email : [email protected] */ | ||
/* web : http://www.thelia.net */ | ||
/* */ | ||
/* For the full copyright and license information, please view the LICENSE.txt */ | ||
/* file that was distributed with this source code. */ | ||
/*************************************************************************************/ | ||
|
||
/* | ||
* This file is part of the Thelia package. | ||
* http://www.thelia.net | ||
* | ||
* (c) OpenStudio <info@thelia.net> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace InvoiceRef\Form; | ||
|
||
|
@@ -20,17 +20,15 @@ | |
use Thelia\Model\ConfigQuery; | ||
|
||
/** | ||
* Class ConfigurationForm | ||
* @package InvoiceRef\Form | ||
* Class ConfigurationForm. | ||
* | ||
* @author manuel raynaud <[email protected]> | ||
*/ | ||
class ConfigurationForm extends BaseForm | ||
{ | ||
|
||
/** | ||
* | ||
* in this function you add all the fields you need for your Form. | ||
* Form this you have to call add method on $this->formBuilder attribute : | ||
* Form this you have to call add method on $this->formBuilder attribute :. | ||
* | ||
* $this->formBuilder->add("name", "text") | ||
* ->add("email", "email", array( | ||
|
@@ -52,13 +50,13 @@ protected function buildForm() | |
$this->formBuilder | ||
->add('invoice', TextType::class, [ | ||
'constraints' => [ | ||
new NotBlank() | ||
new NotBlank(), | ||
], | ||
'label' => Translator::getInstance()->trans('invoice ref', [], InvoiceRef::DOMAIN_NAME), | ||
'label_attr' => [ | ||
'for' => 'invoice-ref' | ||
'for' => 'invoice-ref', | ||
], | ||
'data' => ConfigQuery::read('invoiceRef', 0) | ||
'data' => ConfigQuery::read('invoiceRef', 0), | ||
]); | ||
} | ||
|
||
|
@@ -67,6 +65,6 @@ protected function buildForm() | |
*/ | ||
public static function getName() | ||
{ | ||
return 'invoiceref_config'; | ||
return 'invoiceref_configuration'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Thelia package. | ||
* http://www.thelia.net | ||
* | ||
* (c) OpenStudio <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace InvoiceRef\Hook; | ||
|
||
use Thelia\Core\Event\Hook\HookRenderEvent; | ||
use Thelia\Core\Hook\BaseHook; | ||
|
||
class BackHook extends BaseHook | ||
{ | ||
public function onModuleConfiguration(HookRenderEvent $event): void | ||
{ | ||
$event->add($this->render('module_configuration.html')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<?php | ||
|
||
return array( | ||
'invoice ref' => 'invoice ref', | ||
'invoice ref' => 'Nex invoice reference number', | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<?php | ||
|
||
return array( | ||
'invoice ref' => 'Numéro de facture', | ||
'invoice ref' => 'Prochain numéro de facture', | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,13 @@ | ||
<?php | ||
/*************************************************************************************/ | ||
/* This file is part of the Thelia package. */ | ||
/* */ | ||
/* Copyright (c) OpenStudio */ | ||
/* email : [email protected] */ | ||
/* web : http://www.thelia.net */ | ||
/* */ | ||
/* For the full copyright and license information, please view the LICENSE.txt */ | ||
/* file that was distributed with this source code. */ | ||
/*************************************************************************************/ | ||
/* | ||
* This file is part of the Thelia package. | ||
* http://www.thelia.net | ||
* | ||
* (c) OpenStudio <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace InvoiceRef; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters