MAJ en Thelia 2.3.4
This commit is contained in:
@@ -55,6 +55,12 @@ class BaseModule implements BaseModuleInterface
|
||||
const IS_ACTIVATED = 1;
|
||||
const IS_NOT_ACTIVATED = 0;
|
||||
|
||||
const IS_MANDATORY = 1;
|
||||
const IS_NOT_MANDATORY = 0;
|
||||
|
||||
const IS_HIDDEN = 1;
|
||||
const IS_NOT_HIDDEN = 0;
|
||||
|
||||
protected $reflected;
|
||||
|
||||
protected $dispatcher = null;
|
||||
@@ -429,7 +435,9 @@ class BaseModule implements BaseModuleInterface
|
||||
/** @var Country $country */
|
||||
$country = $taxEngine->getDeliveryCountry();
|
||||
|
||||
$amount = $with_tax ? $cart->getTaxedAmount($country, $with_discount) : $cart->getTotalAmount($with_discount);
|
||||
$state = $taxEngine->getDeliveryState();
|
||||
|
||||
$amount = $with_tax ? $cart->getTaxedAmount($country, $with_discount, $state) : $cart->getTotalAmount($with_discount);
|
||||
|
||||
if ($with_postage) {
|
||||
if ($with_tax) {
|
||||
|
||||
@@ -247,5 +247,4 @@ interface BaseModuleInterface
|
||||
* Create or update module hooks returned by the `getHooks` function
|
||||
*/
|
||||
public function registerHooks();
|
||||
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Core\HttpKernel\Exception\RedirectException;
|
||||
use Thelia\Log\Tlog;
|
||||
use Thelia\Model\OrderQuery;
|
||||
use Thelia\Model\OrderStatus;
|
||||
use Thelia\Model\OrderStatusQuery;
|
||||
|
||||
/**
|
||||
@@ -120,6 +119,53 @@ abstract class BasePaymentModuleController extends BaseFrontController
|
||||
|
||||
/**
|
||||
* Process the cancelation of a payment on the payment gateway. The order will go back to the
|
||||
* Save the transaction/payment ref in the order
|
||||
*
|
||||
* @param int $orderId the order ID
|
||||
* @param int $transactionRef the transaction reference
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function saveTransactionRef($orderId, $transactionRef)
|
||||
{
|
||||
try {
|
||||
$orderId = intval($orderId);
|
||||
|
||||
if (null !== $order = $this->getOrder($orderId)) {
|
||||
$event = new OrderEvent($order);
|
||||
|
||||
$event->setTransactionRef($transactionRef);
|
||||
|
||||
$this->dispatch(TheliaEvents::ORDER_UPDATE_TRANSACTION_REF, $event);
|
||||
|
||||
$this->getLog()->addInfo(
|
||||
$this->getTranslator()->trans(
|
||||
"Payment transaction %transaction_ref for order ref. %ref, ID %id has been successfully saved.",
|
||||
[
|
||||
'%transaction_ref' => $transactionRef,
|
||||
'%ref' => $order->getRef(),
|
||||
'%id' => $order->getId()
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
} catch (\Exception $ex) {
|
||||
$this->getLog()->addError(
|
||||
$this->getTranslator()->trans(
|
||||
"Error occurred while saving payment transaction %transaction_ref for order ID %id.",
|
||||
[
|
||||
'%transaction_ref' => $transactionRef,
|
||||
'%id' => $orderId
|
||||
]
|
||||
)
|
||||
);
|
||||
|
||||
throw $ex;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the cancellation of a payment on the payment gateway. The order will go back to the
|
||||
* "not paid" status.
|
||||
*
|
||||
* @param int $order_id the order ID
|
||||
@@ -138,7 +184,7 @@ abstract class BasePaymentModuleController extends BaseFrontController
|
||||
|
||||
$event = new OrderEvent($order);
|
||||
|
||||
$event->setStatus(OrderStatus::CODE_NOT_PAID);
|
||||
$event->setStatus(OrderStatusQuery::getNotPaidStatus()->getId());
|
||||
|
||||
$this->getLog()->addInfo(
|
||||
$this->getTranslator()->trans(
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
namespace Thelia\Module;
|
||||
|
||||
use Propel\Runtime\Connection\ConnectionInterface;
|
||||
use Propel\Runtime\Exception\PropelException;
|
||||
use Propel\Runtime\Propel;
|
||||
use SplFileInfo;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
@@ -48,7 +47,8 @@ class ModuleManagement
|
||||
|
||||
$finder
|
||||
->name('module.xml')
|
||||
->in($this->baseModuleDir . '*'.DS.'Config');
|
||||
->in($this->baseModuleDir . '*' . DS . 'Config')
|
||||
;
|
||||
|
||||
$errors = [];
|
||||
|
||||
@@ -84,10 +84,12 @@ class ModuleManagement
|
||||
{
|
||||
$descriptorValidator = $this->getDescriptorValidator();
|
||||
|
||||
$content = $descriptorValidator->getDescriptor($file->getRealPath());
|
||||
$content = $descriptorValidator->getDescriptor($file->getRealPath());
|
||||
$reflected = new \ReflectionClass((string)$content->fullnamespace);
|
||||
$code = basename(dirname($reflected->getFileName()));
|
||||
$version = (string)$content->version;
|
||||
$mandatory = intval($content->mandatory);
|
||||
$hidden = intval($content->hidden);
|
||||
|
||||
$module = ModuleQuery::create()->filterByCode($code)->findOne();
|
||||
|
||||
@@ -113,6 +115,8 @@ class ModuleManagement
|
||||
->setFullNamespace((string)$content->fullnamespace)
|
||||
->setType($this->getModuleType($reflected))
|
||||
->setCategory((string)$content->type)
|
||||
->setMandatory($mandatory)
|
||||
->setHidden($hidden)
|
||||
->save($con);
|
||||
|
||||
// Update the module images, title and description when the module is installed, but not after
|
||||
@@ -123,7 +127,7 @@ class ModuleManagement
|
||||
if (isset($content->{"images-folder"}) && !$module->isModuleImageDeployed($con)) {
|
||||
/** @var \Thelia\Module\BaseModule $moduleInstance */
|
||||
$moduleInstance = $reflected->newInstance();
|
||||
$imagesFolder = THELIA_MODULE_DIR . $code . DS . (string) $content->{"images-folder"};
|
||||
$imagesFolder = THELIA_MODULE_DIR . $code . DS . (string)$content->{"images-folder"};
|
||||
$moduleInstance->deployImageFolder($module, $imagesFolder, $con);
|
||||
}
|
||||
}
|
||||
@@ -139,9 +143,13 @@ class ModuleManagement
|
||||
$instance->update($currentVersion, $version, $con);
|
||||
}
|
||||
|
||||
if ($action !== 'none') {
|
||||
$instance->registerHooks();
|
||||
}
|
||||
|
||||
$con->commit();
|
||||
} catch (\Exception $ex) {
|
||||
Tlog::getInstance()->addError("Failed to update module ".$module->getCode(), $ex);
|
||||
Tlog::getInstance()->addError("Failed to update module " . $module->getCode(), $ex);
|
||||
|
||||
$con->rollBack();
|
||||
throw $ex;
|
||||
@@ -184,7 +192,8 @@ class ModuleManagement
|
||||
->setDescription(isset($description->description) ? $description->description : null)
|
||||
->setPostscriptum(isset($description->postscriptum) ? $description->postscriptum : null)
|
||||
->setChapo(isset($description->subtitle) ? $description->subtitle : null)
|
||||
->save($con);
|
||||
->save($con)
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,6 +159,28 @@
|
||||
<xs:documentation>URL to test if a new version of the module exists. Will be called with two get parameters : module name, current version</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:element>
|
||||
<xs:element name="mandatory" minOccurs="0" maxOccurs="1">
|
||||
<xs:annotation>
|
||||
<xs:documentation>Flag for protected module</xs:documentation>
|
||||
</xs:annotation>
|
||||
<xs:simpleType>
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:enumeration value="0"/>
|
||||
<xs:enumeration value="1"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
</xs:element>
|
||||
<xs:element name="hidden" minOccurs="0" maxOccurs="1">
|
||||
<xs:annotation>
|
||||
<xs:documentation>Flag for visible module</xs:documentation>
|
||||
</xs:annotation>
|
||||
<xs:simpleType>
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:enumeration value="0"/>
|
||||
<xs:enumeration value="1"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
|
||||
Reference in New Issue
Block a user