-
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.
Merge pull request #50 from collector-bank/feature/oath
Feature/oath
- Loading branch information
Showing
41 changed files
with
1,822 additions
and
113 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Webbhuset\CollectorCheckout\Block\Admin\Form\Field; | ||
|
||
use Magento\Config\Block\System\Config\Form\Field\FieldArray\AbstractFieldArray; | ||
use Magento\Framework\DataObject; | ||
use Magento\Framework\Exception\LocalizedException; | ||
use Webbhuset\CollectorCheckout\Block\Admin\Form\Field\Icons as IconFields; | ||
|
||
class IconMapper extends AbstractFieldArray | ||
{ | ||
/** | ||
* @var IconFields | ||
*/ | ||
private $iconRenderer; | ||
|
||
/** | ||
* Prepare rendering the new field by adding all the needed columns | ||
*/ | ||
protected function _prepareToRender() | ||
{ | ||
$this->addColumn('method', [ | ||
'label' => __('Shipping methods'), | ||
'renderer' => $this->getIconRenderer() | ||
]); | ||
$this->addColumn('icon', ['label' => __('Icon'), 'class' => 'required-entry']); | ||
|
||
$this->_addAfter = false; | ||
$this->_addButtonLabel = __('Add'); | ||
} | ||
|
||
/** | ||
* Prepare existing row data object | ||
* | ||
* @param DataObject $row | ||
* @throws LocalizedException | ||
*/ | ||
protected function _prepareArrayRow(DataObject $row): void | ||
{ | ||
$options = []; | ||
|
||
$row->setData('option_extra_attrs', $options); | ||
} | ||
|
||
/** | ||
* @return IconFields | ||
* @throws LocalizedException | ||
*/ | ||
private function getIconRenderer() | ||
{ | ||
if (!$this->iconRenderer) { | ||
$this->iconRenderer = $this->getLayout()->createBlock( | ||
IconFields::class, | ||
'', | ||
['data' => ['is_render_to_js_template' => true]] | ||
); | ||
} | ||
return $this->iconRenderer; | ||
} | ||
} |
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,47 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Webbhuset\CollectorCheckout\Block\Admin\Form\Field; | ||
|
||
use Magento\Framework\View\Element\Context; | ||
use Magento\Framework\View\Element\Html\Select; | ||
use Webbhuset\CollectorCheckout\Config\Source\IconsSource; | ||
|
||
class Icons extends Select | ||
{ | ||
/** @var IconsSource $iconsSource */ | ||
private $iconsSource; | ||
|
||
public function __construct( | ||
Context $context, | ||
IconsSource $iconsSource, | ||
array $data = [] | ||
) { | ||
parent::__construct($context, $data); | ||
|
||
$this->iconsSource = $iconsSource; | ||
} | ||
|
||
public function setInputName($value) | ||
{ | ||
return $this->setName($value); | ||
} | ||
|
||
public function setInputId($value) | ||
{ | ||
return $this->setId($value); | ||
} | ||
|
||
public function _toHtml(): string | ||
{ | ||
if (!$this->getOptions()) { | ||
$this->setOptions($this->getSourceOptions()); | ||
} | ||
return parent::_toHtml(); | ||
} | ||
|
||
private function getSourceOptions(): array | ||
{ | ||
return $this->iconsSource->toOptionArray(); | ||
} | ||
} |
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,29 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Webbhuset\CollectorCheckout\Checkout\Order; | ||
|
||
use Magento\Framework\App\ResourceConnection; | ||
|
||
class SetOrderStatus | ||
{ | ||
/** | ||
* @var ResourceConnection | ||
*/ | ||
private $resourceConnection; | ||
|
||
public function __construct( | ||
ResourceConnection $resourceConnection | ||
) { | ||
$this->resourceConnection = $resourceConnection; | ||
} | ||
|
||
public function execute($orderId, $status, $state) | ||
{ | ||
$connection = $this->resourceConnection->getConnection(); | ||
$tableName = $this->resourceConnection->getTableName('sales_order'); | ||
|
||
$data = ['state' => $state, 'status' => $status]; | ||
$connection->update($tableName, $data, 'entity_id = ' . (int)$orderId); | ||
} | ||
} |
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.