-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from exponea/feature/sync-14
v0.9.4 Release
- Loading branch information
Showing
44 changed files
with
1,411 additions
and
309 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,55 @@ | ||
<?php | ||
/** | ||
* @author Bloomreach | ||
* @copyright Copyright (c) Bloomreach (https://www.bloomreach.com/) | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Bloomreach\EngagementConnector\Block\Adminhtml\System\Config; | ||
|
||
use Bloomreach\EngagementConnector\Service\InitialImport\ProcessStatus; | ||
use Magento\Backend\Block\Template\Context; | ||
use Magento\Framework\Data\Form\Element\AbstractElement; | ||
use Magento\Framework\Phrase; | ||
|
||
/** | ||
* Button for running Initial Import in admin panel | ||
*/ | ||
class RunInitialImportButton extends Button | ||
{ | ||
/** | ||
* @var ProcessStatus | ||
*/ | ||
private $processStatus; | ||
|
||
/** | ||
* @param Context $context | ||
* @param ProcessStatus $processStatus | ||
* @param array $data | ||
*/ | ||
public function __construct( | ||
Context $context, | ||
ProcessStatus $processStatus, | ||
array $data = [] | ||
) { | ||
parent::__construct($context, $data); | ||
$this->processStatus = $processStatus; | ||
} | ||
|
||
/** | ||
* Get the button and scripts contents | ||
* | ||
* @param AbstractElement $element | ||
* | ||
* @return string | ||
*/ | ||
protected function _getElementHtml(AbstractElement $element) | ||
{ | ||
parent::_getElementHtml($element); | ||
$this->addData([ | ||
'is_import_in_progress' => $this->processStatus->execute() | ||
]); | ||
|
||
return $this->_toHtml(); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
/** | ||
* @author Bloomreach | ||
* @copyright Copyright (c) Bloomreach (https://www.bloomreach.com/) | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Bloomreach\EngagementConnector\Exception; | ||
|
||
use Exception; | ||
use Magento\Framework\Exception\LocalizedException; | ||
use Magento\Framework\Phrase; | ||
|
||
/** | ||
* An exception that is thrown when the request to the Bloomreach API is unsuccessful | ||
*/ | ||
class ExportRequestException extends LocalizedException | ||
{ | ||
/** | ||
* @var bool | ||
*/ | ||
private $isNeedUpdateRetryCounter; | ||
|
||
/** | ||
* @param Phrase $phrase | ||
* @param bool $isNeedUpdateRetryCounter | ||
* @param Exception|null $cause | ||
* @param int $code | ||
*/ | ||
public function __construct( | ||
Phrase $phrase, | ||
bool $isNeedUpdateRetryCounter = true, | ||
Exception $cause = null, | ||
$code = 0 | ||
) { | ||
$this->isNeedUpdateRetryCounter = $isNeedUpdateRetryCounter; | ||
parent::__construct($phrase, $cause, $code); | ||
} | ||
|
||
/** | ||
* Is need to update retry counter after failed attempt | ||
* | ||
* @return bool | ||
*/ | ||
public function isNeedUpdateRetryCounter(): bool | ||
{ | ||
return $this->isNeedUpdateRetryCounter; | ||
} | ||
} |
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,97 @@ | ||
<?php | ||
/** | ||
* @author Bloomreach | ||
* @copyright Copyright (c) Bloomreach (https://www.bloomreach.com/) | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Bloomreach\EngagementConnector\Logger; | ||
|
||
use Bloomreach\EngagementConnector\Model\DataMapping\Config\ConfigProvider; | ||
use Magento\Framework\Phrase; | ||
use Magento\Framework\Serialize\SerializerInterface; | ||
use Psr\Log\LoggerInterface; | ||
|
||
/** | ||
* The class is responsible for saving the debug information to the log file | ||
*/ | ||
class Debugger | ||
{ | ||
/** | ||
* @var ConfigProvider | ||
*/ | ||
private $configProvider; | ||
|
||
/** | ||
* @var SerializerInterface | ||
*/ | ||
private $jsonSerializer; | ||
|
||
/** | ||
* @var LoggerInterface | ||
*/ | ||
private $logger; | ||
|
||
/** | ||
* @var bool | ||
*/ | ||
private $isDebugModeEnabled; | ||
|
||
/** | ||
* @param ConfigProvider $configProvider | ||
* @param SerializerInterface $jsonSerializer | ||
* @param LoggerInterface $logger | ||
*/ | ||
public function __construct( | ||
ConfigProvider $configProvider, | ||
SerializerInterface $jsonSerializer, | ||
LoggerInterface $logger | ||
) { | ||
$this->configProvider = $configProvider; | ||
$this->jsonSerializer = $jsonSerializer; | ||
$this->logger = $logger; | ||
} | ||
|
||
/** | ||
* Log debugging information | ||
* | ||
* @param Phrase|string $message | ||
* | ||
* @return void | ||
*/ | ||
public function log($message): void | ||
{ | ||
if ($this->isDebugModeEnabled()) { | ||
$this->logger->debug($message); | ||
} | ||
} | ||
|
||
/** | ||
* Log debugging information | ||
* | ||
* @param string $placeholder | ||
* @param array $data | ||
* | ||
* @return void | ||
*/ | ||
public function logArray(string $placeholder, array $data): void | ||
{ | ||
if ($this->isDebugModeEnabled()) { | ||
$this->logger->debug(__($placeholder, $this->jsonSerializer->serialize($data))); | ||
} | ||
} | ||
|
||
/** | ||
* Checks whether is debug mode enabled | ||
* | ||
* @return bool | ||
*/ | ||
private function isDebugModeEnabled(): bool | ||
{ | ||
if ($this->isDebugModeEnabled === null) { | ||
$this->isDebugModeEnabled = $this->configProvider->isDebugModeEnabled(); | ||
} | ||
|
||
return $this->isDebugModeEnabled; | ||
} | ||
} |
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
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
Oops, something went wrong.