-
Notifications
You must be signed in to change notification settings - Fork 1
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 #31 from magmodules/release/1.11.0
Release/1.11.0
- Loading branch information
Showing
15 changed files
with
524 additions
and
54 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 |
---|---|---|
|
@@ -2,44 +2,22 @@ name: Lint PHP files | |
on: [push, pull_request] | ||
|
||
jobs: | ||
php-71: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: StephaneBour/[email protected] | ||
with: | ||
dir: './' | ||
|
||
php-72: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: StephaneBour/[email protected] | ||
with: | ||
dir: './' | ||
|
||
php-73: | ||
php-74: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: StephaneBour/[email protected] | ||
with: | ||
dir: './' | ||
- uses: prestashop/github-action-php-lint/[email protected] | ||
|
||
php-74: | ||
php-81: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: StephaneBour/[email protected] | ||
with: | ||
dir: './' | ||
- uses: prestashop/github-action-php-lint/[email protected] | ||
|
||
php-80: | ||
php-82: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: StephaneBour/[email protected] | ||
with: | ||
dir: './' | ||
- uses: prestashop/github-action-php-lint/[email protected] | ||
|
||
php-81: | ||
php-83: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: StephaneBour/[email protected] | ||
with: | ||
dir: './' | ||
- uses: prestashop/github-action-php-lint/[email protected] |
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,87 @@ | ||
<?php | ||
/** | ||
* Copyright © Magmodules.eu. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magmodules\Reloadify\Block\Adminhtml\System\Config\Form\Field; | ||
|
||
use Magento\Config\Block\System\Config\Form\Field\FieldArray\AbstractFieldArray; | ||
use Magento\Framework\DataObject; | ||
use Magento\Framework\Exception\LocalizedException; | ||
|
||
/** | ||
* Class ExtraFields | ||
* System config field renderer for Extra Fields (feed) | ||
*/ | ||
class ExtraFields extends AbstractFieldArray | ||
{ | ||
|
||
/** | ||
* @var Renderer\Attributes | ||
*/ | ||
private $attributeRenderer; | ||
|
||
/** | ||
* Prepare to render method | ||
* | ||
* @throws LocalizedException | ||
*/ | ||
public function _prepareToRender() | ||
{ | ||
$this->addColumn( | ||
'name', | ||
[ | ||
'label' => __('Field name'), | ||
] | ||
); | ||
$this->addColumn( | ||
'attribute', | ||
[ | ||
'label' => __('Attribute'), | ||
'renderer' => $this->getAttributeRenderer() | ||
] | ||
); | ||
$this->_addAfter = false; | ||
$this->_addButtonLabel = __('Add'); | ||
} | ||
|
||
/** | ||
* Retrieve attribute column renderer | ||
* | ||
* @return Renderer\Attributes | ||
* @throws LocalizedException | ||
*/ | ||
public function getAttributeRenderer(): Renderer\Attributes | ||
{ | ||
if (!$this->attributeRenderer) { | ||
$this->attributeRenderer = $this->getLayout()->createBlock( | ||
Renderer\Attributes::class, | ||
'', | ||
['data' => ['is_render_to_js_template' => true]] | ||
); | ||
} | ||
|
||
return $this->attributeRenderer; | ||
} | ||
|
||
/** | ||
* Prepare existing row data object | ||
* | ||
* @param DataObject $row | ||
* @throws LocalizedException | ||
*/ | ||
public function _prepareArrayRow(DataObject $row) | ||
{ | ||
$options = []; | ||
if ($attribute = $row->getData('attribute')) { | ||
$options['option_' . $this->getAttributeRenderer()->calcOptionHash($attribute)] = 'selected="selected"'; | ||
} | ||
|
||
$row->setData( | ||
'option_extra_attrs', | ||
$options | ||
); | ||
} | ||
} |
110 changes: 110 additions & 0 deletions
110
Block/Adminhtml/System/Config/Form/Field/Renderer/Attributes.php
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,110 @@ | ||
<?php | ||
/** | ||
* Copyright © Magmodules.eu. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magmodules\Reloadify\Block\Adminhtml\System\Config\Form\Field\Renderer; | ||
|
||
use Magento\Framework\View\Element\Context; | ||
use Magento\Framework\View\Element\Html\Select; | ||
use Magmodules\Reloadify\Model\System\Config\Source\Attributes as AttributesSource; | ||
|
||
class Attributes extends Select | ||
{ | ||
|
||
/** | ||
* @var array | ||
*/ | ||
private $attribute = []; | ||
/** | ||
* @var AttributesSource | ||
*/ | ||
private $attributes; | ||
|
||
/** | ||
* Attributes constructor. | ||
* | ||
* @param Context $context | ||
* @param AttributesSource $attributes | ||
* @param array $data | ||
*/ | ||
public function __construct( | ||
Context $context, | ||
AttributesSource $attributes, | ||
array $data = [] | ||
) { | ||
parent::__construct($context, $data); | ||
$this->attributes = $attributes; | ||
} | ||
|
||
/** | ||
* Render block HTML | ||
* | ||
* @return string | ||
*/ | ||
public function _toHtml() | ||
{ | ||
if (!$this->getOptions()) { | ||
foreach ($this->getAttributeSource() as $attribute) { | ||
$this->addOption($attribute['value'], $attribute['label']); | ||
} | ||
} | ||
|
||
return parent::_toHtml(); | ||
} | ||
|
||
/** | ||
* Get all attributes | ||
* | ||
* @return array | ||
*/ | ||
public function getAttributeSource(): array | ||
{ | ||
if (!$this->attribute) { | ||
$this->attribute = $this->attributes->toOptionArray(); | ||
$this->attribute[] = $this->getPriceAttributeSource(); | ||
} | ||
|
||
return $this->attribute; | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
private function getPriceAttributeSource(): array | ||
{ | ||
$optionArray = []; | ||
$optionArray[] = [ | ||
'label' => __('Price with base currency'), | ||
'value' => 'rendered_price__price' | ||
]; | ||
$optionArray[] = [ | ||
'label' => __('Min. price with base currency'), | ||
'value' => 'rendered_price__min_price' | ||
]; | ||
$optionArray[] = [ | ||
'label' => __('Max. price with base currency'), | ||
'value' => 'rendered_price__max_price' | ||
]; | ||
|
||
return [ | ||
'label' => __('Price Attributes'), | ||
'value' => $optionArray, | ||
'optgroup-name' => __('Price Attributes') | ||
]; | ||
} | ||
|
||
/** | ||
* Sets name for input element | ||
* | ||
* @param $value | ||
* | ||
* @return Attributes | ||
*/ | ||
public function setInputName($value) | ||
{ | ||
return $this->setData('name', $value); | ||
} | ||
} |
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,35 @@ | ||
<?php | ||
/** | ||
* Copyright © Magmodules.eu. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magmodules\Reloadify\Model\Config\Backend\Serialized; | ||
|
||
use Magento\Config\Model\Config\Backend\Serialized\ArraySerialized; | ||
|
||
/** | ||
* Class ExtraFields | ||
*/ | ||
class ExtraFields extends ArraySerialized | ||
{ | ||
|
||
/** | ||
* @return \Magento\Config\Model\Config\Backend\Serialized\ArraySerialized | ||
*/ | ||
public function beforeSave() | ||
{ | ||
$data = $this->getValue(); | ||
if (is_array($data)) { | ||
foreach ($data as $key => $row) { | ||
if (empty($row['name']) || empty($row['attribute'])) { | ||
unset($data[$key]); | ||
continue; | ||
} | ||
} | ||
} | ||
$this->setValue($data); | ||
return parent::beforeSave(); | ||
} | ||
} |
Oops, something went wrong.