Skip to content

Commit

Permalink
3.5.0: MAG-503: Minor fixes from Magento Code Standard tool
Browse files Browse the repository at this point in the history
  • Loading branch information
ebanolopes committed Nov 13, 2019
1 parent 957044f commit e065dd3
Show file tree
Hide file tree
Showing 62 changed files with 227 additions and 150 deletions.
1 change: 0 additions & 1 deletion Api/Core/SignifydAPIFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
* After remove this class it is necessary to replace all its occurrences with \Signifyd\Core\SignifydAPIFactory
*
* Class SignifydAPIFactory
* @package Signifyd\Connect\Api\Core
*/
class SignifydAPIFactory extends \Signifyd\Core\SignifydAPIFactory
{
Expand Down
2 changes: 1 addition & 1 deletion Block/Adminhtml/Order/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function getCase(\Magento\Sales\Model\Order $order)
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();

/** @var $case \Signifyd\Connect\Model\Casedata */
$case = $objectManager->get('Signifyd\Connect\Model\Casedata');
$case = $objectManager->get(\Signifyd\Connect\Model\Casedata::class);
$case->load($order->getIncrementId());
return $case;
}
Expand Down
5 changes: 3 additions & 2 deletions Controller/Adminhtml/Order/Unhold.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function execute()
}

/** @var $case \Signifyd\Connect\Model\Casedata */
$case = $this->_objectManager->get('Signifyd\Connect\Model\Casedata');
$case = $this->_objectManager->get(\Signifyd\Connect\Model\Casedata::class);
$case->load($order->getIncrementId());

if (!$case->isHoldReleased()) {
Expand All @@ -72,7 +72,8 @@ public function execute()

$resultRedirect = parent::execute();

$order->addStatusHistoryComment("Signifyd: order status updated by {$this->authSession->getUser()->getUserName()}");
$message = "Signifyd: order status updated by {$this->authSession->getUser()->getUserName()}";
$order->addStatusHistoryComment($message);
$order->save();

return $resultRedirect;
Expand Down
19 changes: 5 additions & 14 deletions Controller/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,28 +39,19 @@ public function match(\Magento\Framework\App\RequestInterface $request)
if ($request->getModuleName() === 'signifyd_connect') {
return;
}
/*
* We will search “examplerouter” and “exampletocms” words and make forward depend on word
* -examplerouter will forward to base router to match Signifydtest front name, test controller path and test controller class
* -exampletocms will set front name to cms, controller path to page and action to view
*/

$identifier = trim($request->getPathInfo(), '/');

if (strpos($identifier, 'signifyd/webhooks') !== false && strpos($identifier, 'signifyd/webhooks/handler') === false) {
/*
* We must set module, controller path and action name for our controller class(Controller/Test/Test.php)
*/
if (strpos($identifier, 'signifyd/webhooks') !== false &&
strpos($identifier, 'signifyd/webhooks/handler') === false
) {
$request->setModuleName('signifyd_connect')->setControllerName('webhooks')->setActionName('index');
} else {
//There is no match
return;
}

/*
* We have match and now we will forward action
*/
return $this->actionFactory->create(
'Magento\Framework\App\Action\Forward',
\Magento\Framework\App\Action\Forward::class,
['request' => $request]
);
}
Expand Down
6 changes: 3 additions & 3 deletions Controller/Webhooks/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function __construct(
// Compatibility with Magento 2.3+ which required form_key on every request
// Magento expects class to implement \Magento\Framework\App\CsrfAwareActionInterface but this causes
// a backward incompatibility to Magento versions below 2.3
if (interface_exists("\Magento\Framework\App\CsrfAwareActionInterface")) {
if (interface_exists(\Magento\Framework\App\CsrfAwareActionInterface::class)) {
$request = $this->getRequest();
if ($request instanceof RequestInterface && $request->isPost() && empty($request->getParam('form_key'))) {
$request->setParam('form_key', $formKey->getFormKey());
Expand Down Expand Up @@ -121,7 +121,7 @@ public function processRequest($request, $hash, $topic)
/** @var $order \Magento\Sales\Model\Order */
$order = $this->orderFactory->create()->loadByIncrementId($requestJson->orderId);
/** @var $case \Signifyd\Connect\Model\Casedata */
$case = $this->objectManager->create('Signifyd\Connect\Model\Casedata')->load($requestJson->orderId);
$case = $this->objectManager->create(\Signifyd\Connect\Model\Casedata::class)->load($requestJson->orderId);

$caseData = [
"case" => $case,
Expand Down Expand Up @@ -156,7 +156,7 @@ public function processRequest($request, $hash, $topic)

if ($signifydApi->validWebhookRequest($request, $hash, $topic)) {
/** @var \Signifyd\Connect\Model\Casedata $caseObj */
$caseObj = $this->objectManager->create('Signifyd\Connect\Model\Casedata');
$caseObj = $this->objectManager->create(\Signifyd\Connect\Model\Casedata::class);
$caseObj->updateCase($caseData);
$this->getResponse()->setStatusCode(Http::STATUS_CODE_200);
return;
Expand Down
13 changes: 8 additions & 5 deletions Cron/RetryCaseJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ public function execute()
$waitingCases = $this->caseRetryObj->getRetryCasesByStatus(Casedata::WAITING_SUBMISSION_STATUS);

foreach ($waitingCases as $case) {
$this->logger->debug("Signifyd: preparing for send case no: {$case['order_increment']}", ['entity' => $case]);
$message = "Signifyd: preparing for send case no: {$case['order_increment']}";
$this->logger->debug($message, ['entity' => $case]);

$order = $this->getOrder($case['order_increment']);

Expand All @@ -70,7 +71,7 @@ public function execute()

if ($result) {
/** @var \Signifyd\Connect\Model\Casedata $caseObj */
$caseObj = $this->_objectManager->create('Signifyd\Connect\Model\Casedata')
$caseObj = $this->_objectManager->create(\Signifyd\Connect\Model\Casedata::class)
->load($case->getOrderIncrement())
->setCode($result)
->setMagentoStatus(Casedata::IN_REVIEW_STATUS)
Expand All @@ -85,7 +86,8 @@ public function execute()
$inReviewCases = $this->caseRetryObj->getRetryCasesByStatus(Casedata::IN_REVIEW_STATUS);

foreach ($inReviewCases as $case) {
$this->logger->debug("Signifyd: preparing for review case no: {$case['order_increment']}", ['entity' => $case]);
$message = "Signifyd: preparing for review case no: {$case['order_increment']}";
$this->logger->debug($message, ['entity' => $case]);

$this->caseRetryObj->processInReviewCase($case, $this->getOrder($case['order_increment']));
}
Expand All @@ -96,7 +98,8 @@ public function execute()
$inProcessingCases = $this->caseRetryObj->getRetryCasesByStatus(Casedata::PROCESSING_RESPONSE_STATUS);

foreach ($inProcessingCases as $case) {
$this->logger->debug("Signifyd: preparing for process case no: {$case['order_increment']}", ['entity' => $case]);
$message = "Signifyd: preparing for process case no: {$case['order_increment']}";
$this->logger->debug($message, ['entity' => $case]);

$this->caseRetryObj->processResponseStatus($case, $this->getOrder($case['order_increment']));
}
Expand All @@ -108,6 +111,6 @@ public function execute()

public function getOrder($incrementId)
{
return $this->_objectManager->get('Magento\Sales\Model\Order')->loadByIncrementId($incrementId);
return $this->_objectManager->get(\Magento\Sales\Model\Order::class)->loadByIncrementId($incrementId);
}
}
4 changes: 0 additions & 4 deletions CustomerData/Fingerprint.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
use Magento\Checkout\Model\Session;
use Signifyd\Connect\Helper\DeviceHelper;

/**
* Class FingerprintSection
* @package Signifyd\Connect\CustomerData
*/
class Fingerprint extends DataObject implements SectionSourceInterface
{
/**
Expand Down
3 changes: 2 additions & 1 deletion Helper/ConfigHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ public function getSignifydApi(\Magento\Framework\Model\AbstractModel $entity =
if (isset($this->signifydAPI[$storeCode]) === false ||
$this->signifydAPI[$storeCode] instanceof \Signifyd\Core\SignifydAPI == false) {
$signifydSettingsMagento = $this->getSignifydSettingsMagento($entity);
$this->signifydAPI[$storeCode] = $this->signifydAPIFactory->create(['settings' => $signifydSettingsMagento]);
$data = ['settings' => $signifydSettingsMagento];
$this->signifydAPI[$storeCode] = $this->signifydAPIFactory->create($data);
}

return $this->signifydAPI[$storeCode];
Expand Down
6 changes: 3 additions & 3 deletions Helper/FulfillmentHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ public function generateFulfillmentData(\Magento\Sales\Model\Order\Shipment $shi
}

/** @var \Signifyd\Models\Fulfillment $fulfillment */
$fulfillment = SignifydModel::Make("\\Signifyd\\Models\\Fulfillment");
$fulfillment = SignifydModel::Make(\Signifyd\Models\Fulfillment::class);
$fulfillment->id = $shipment->getIncrementId();
$fulfillment->orderId = $shipment->getOrder()->getIncrementId();
$fulfillment->createdAt = $this->getCreatedAt($shipment);
Expand Down Expand Up @@ -338,7 +338,7 @@ public function getProducts(\Magento\Sales\Model\Order\Shipment $shipment)
*/

/** @var \Signifyd\Models\Product $product */
$product = SignifydModel::Make("\\Signifyd\\Models\\Product");
$product = SignifydModel::Make(\Signifyd\Models\Product::class);
$product->itemId = $item->getSku();
$product->itemName = $item->getName();
$product->itemIsDigital = (bool) $item->getOrderItem()->getIsVirtual();
Expand Down Expand Up @@ -413,7 +413,7 @@ public function getShipmentStatus(\Magento\Sales\Model\Order\Shipment $shipment)
public function getDeliveryAddress(\Magento\Sales\Model\Order\Shipment $shipment)
{
/** @var \Signifyd\Models\Address $deliveryAddress */
$deliveryAddress = SignifydModel::Make("\\Signifyd\\Models\\Address");
$deliveryAddress = SignifydModel::Make(\Signifyd\Models\Address::class);
$deliveryAddress->streetAddress = $this->getStreetAddress($shipment);
$deliveryAddress->unit = null;
$deliveryAddress->city = $shipment->getShippingAddress()->getCity();
Expand Down
Loading

0 comments on commit e065dd3

Please sign in to comment.