Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 19 additions & 8 deletions Block/Adminhtml/Form/Field/Code.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
<?php
/**
* Copyright © 2019 Rejoiner. All rights reserved.
/*
* Copyright © 2022 Rejoiner. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Rejoiner\Acr\Block\Adminhtml\Form\Field;

class Code extends \Magento\Config\Block\System\Config\Form\Field\FieldArray\AbstractFieldArray
{
/**
* @var \Magento\Framework\View\Element\BlockInterface|null
*/
protected $_salesruleRenderer;

/**
* @inheritDoc
*/
protected function _prepareToRender()
{
$this->addColumn(
Expand All @@ -28,20 +34,27 @@ protected function _prepareToRender()
$this->_addButtonLabel = __('Add Code');
}

/**
* Get Salesrule renderer
*
* @return \Magento\Framework\View\Element\BlockInterface
* @throws \Magento\Framework\Exception\LocalizedException
*/
protected function _getSalesruleRenderer()
{
if (!$this->_salesruleRenderer) {
$this->_salesruleRenderer = $this->getLayout()->createBlock(
'\Rejoiner\Acr\Block\Adminhtml\Form\Field\Salesrule',
\Rejoiner\Acr\Block\Adminhtml\Form\Field\Salesrule::class,
'promo_salesrule',
['data' => ['is_render_to_js_template' => true]]
);
}
}

return $this->_salesruleRenderer;
}

/**
* @param \Magento\Framework\DataObject $row
* @inheritDoc
*/
protected function _prepareArrayRow(\Magento\Framework\DataObject $row)
{
Expand All @@ -52,7 +65,5 @@ protected function _prepareArrayRow(\Magento\Framework\DataObject $row)
$options[$key] = 'selected="selected"';
}
$row->setData('option_extra_attrs', $options);

return;
}
}
}
7 changes: 4 additions & 3 deletions Block/Adminhtml/Form/Field/Custom.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright © 2017 Rejoiner. All rights reserved.
/*
* Copyright © 2022 Rejoiner. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Rejoiner\Acr\Block\Adminhtml\Form\Field;
Expand All @@ -9,6 +9,7 @@ class Custom extends \Magento\Config\Block\System\Config\Form\Field\FieldArray\A
{
/**
* Prepare to render
*
* @return void
*/
protected function _prepareToRender()
Expand All @@ -28,4 +29,4 @@ protected function _prepareToRender()
$this->_addAfter = false;
$this->_addButtonLabel = __('Add Rule');
}
}
}
19 changes: 12 additions & 7 deletions Block/Adminhtml/Form/Field/Google.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright © 2017 Rejoiner. All rights reserved.
/*
* Copyright © 2022 Rejoiner. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Rejoiner\Acr\Block\Adminhtml\Form\Field;
Expand All @@ -12,7 +12,9 @@ class Google extends \Magento\Config\Block\System\Config\Form\Field\FieldArray\A

/**
* Prepare to render
*
* @return void
* @throws \Magento\Framework\Exception\LocalizedException
*/
protected function _prepareToRender()
{
Expand All @@ -34,7 +36,9 @@ protected function _prepareToRender()
}

/**
* @param \Magento\Framework\DataObject $row
* @inheritDoc
*
* @throws \Magento\Framework\Exception\LocalizedException
*/
protected function _prepareArrayRow(\Magento\Framework\DataObject $row)
{
Expand All @@ -45,23 +49,24 @@ protected function _prepareArrayRow(\Magento\Framework\DataObject $row)
= 'selected="selected"';
}
$row->setData('option_extra_attrs', $options);

return;
}

/**
* Get Source Renderer
*
* @return \Rejoiner\Acr\Block\Adminhtml\Form\Field\Source
* @throws \Magento\Framework\Exception\LocalizedException
*/
protected function getSourceRenderer()
{
if (!$this->sourceRenderer) {
$this->sourceRenderer = $this->getLayout()->createBlock(
'\Rejoiner\Acr\Block\Adminhtml\Form\Field\Source',
\Rejoiner\Acr\Block\Adminhtml\Form\Field\Source::class,
'google_anal',
['data' => ['is_render_to_js_template' => true]]
);
}

return $this->sourceRenderer;
}
}
}
9 changes: 5 additions & 4 deletions Block/Adminhtml/Form/Field/Salesrule.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright © 2017 Rejoiner. All rights reserved.
/*
* Copyright © 2022 Rejoiner. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Rejoiner\Acr\Block\Adminhtml\Form\Field;
Expand All @@ -13,7 +13,7 @@ class Salesrule extends \Magento\Framework\View\Element\Html\Select
private $_salesruleFactory;

/**
* @param \Magento\SalesRule\Model\RuleFactory $ruleFactory
* @param \Rejoiner\Acr\Model\System\Config\Source\Salesrule $salesruleFactory
* @param \Magento\Framework\View\Element\Context $context
* @param array $data
*/
Expand All @@ -30,6 +30,7 @@ public function __construct(
* Render block HTML
*
* @return string
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function _toHtml()
{
Expand All @@ -53,4 +54,4 @@ public function setInputName($value)
{
return $this->setName($value);
}
}
}
6 changes: 3 additions & 3 deletions Block/Adminhtml/Form/Field/Source.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright © 2017 Rejoiner. All rights reserved.
/*
* Copyright © 2022 Rejoiner. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Rejoiner\Acr\Block\Adminhtml\Form\Field;
Expand Down Expand Up @@ -40,4 +40,4 @@ public function setInputName($value)
{
return $this->setName($value);
}
}
}
14 changes: 8 additions & 6 deletions Block/Base.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright © 2017 Rejoiner. All rights reserved.
/*
* Copyright © 2022 Rejoiner. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Rejoiner\Acr\Block;
Expand All @@ -10,13 +10,14 @@ class Base extends \Magento\Framework\View\Element\Template
/** @var \Rejoiner\Acr\Helper\Data $rejoinerHelper */
protected $rejoinerHelper;


/** @var \Magento\Framework\App\Request\Http $request */
protected $request;

/**
* Base constructor.
*
* @param \Rejoiner\Acr\Helper\Data $rejoinerHelper
* @param \Magento\Framework\App\Request\Http $request
* @param \Magento\Framework\View\Element\Template\Context $context
* @param array $data
*/
Expand All @@ -32,18 +33,20 @@ public function __construct(
}

/**
* Get Rejoiner helper
*
* @return \Rejoiner\Acr\Helper\Data
*/
public function getRejoinerHelper()
{
return $this->rejoinerHelper;
}


/**
* Get cache key informative items
*
* @return array
* @throws \Magento\Framework\Exception\NoSuchEntityException
*/
public function getCacheKeyInfo()
{
Expand All @@ -56,5 +59,4 @@ public function getCacheKeyInfo()
'page_type' => $this->rejoinerHelper->getCurrentPageName()
];
}

}
}
32 changes: 27 additions & 5 deletions Block/Newsletter.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright © 2017 Rejoiner. All rights reserved.
/*
* Copyright © 2022 Rejoiner. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Rejoiner\Acr\Block;
Expand Down Expand Up @@ -53,6 +53,8 @@ public function __construct(
}

/**
* IsEnabled flag
*
* @return bool
*/
public function isEnabled()
Expand All @@ -61,19 +63,23 @@ public function isEnabled()
}

/**
* GetLabel
*
* @return string
*/
public function getLabel()
{
if (!$this->label) {
$label = $this->rejoinerHelper->getRejoinerSubscribeCheckboxLabel();
$this->label = $label ? $label : __(self::DEFAULT_LABEL);
$this->label = $label ?: __(self::DEFAULT_LABEL);
}

return $this->label;
}

/**
* IsLabelChanged flag
*
* @return bool
*/
public function isLabelChanged()
Expand All @@ -82,6 +88,8 @@ public function isLabelChanged()
}

/**
* GetCssClass
*
* @return string
*/
public function getCssClass()
Expand All @@ -94,6 +102,8 @@ public function getCssClass()
}

/**
* GetStyles
*
* @return string
*/
public function getStyles()
Expand All @@ -106,6 +116,8 @@ public function getStyles()
}

/**
* GetCheckboxSelectors
*
* @return string
*/
public function getCheckboxSelectors()
Expand All @@ -114,6 +126,8 @@ public function getCheckboxSelectors()
}

/**
* HideInCustomerAccount flag
*
* @return bool
*/
public function hideInCustomerAccount()
Expand All @@ -122,6 +136,8 @@ public function hideInCustomerAccount()
}

/**
* ShowOnLoginCheckout flag
*
* @return bool
*/
public function showOnLoginCheckout()
Expand All @@ -130,6 +146,8 @@ public function showOnLoginCheckout()
}

/**
* ShowOnGuestCheckout flag
*
* @return bool
*/
public function showOnGuestCheckout()
Expand All @@ -138,6 +156,8 @@ public function showOnGuestCheckout()
}

/**
* ShouldBeCheckedByDefault flag
*
* @return bool
*/
public function shouldBeCheckedByDefault()
Expand All @@ -146,16 +166,18 @@ public function shouldBeCheckedByDefault()
}

/**
* Get config array
*
* @return array
*/
public function getConfig()
{
return [
'label' => $this->getLabel() ? $this->getLabel() : self::DEFAULT_LABEL,
'label' => $this->getLabel() ?: self::DEFAULT_LABEL,
'show_on_guest_checkout' => (int) $this->showOnGuestCheckout(),
'show_on_login_checkout' => (int) $this->showOnLoginCheckout(),
'checked_by_default' => (int) $this->shouldBeCheckedByDefault(),
'subscribe_guest_checkout' => (int) ($this->showOnGuestCheckout() && $this->shouldBeCheckedByDefault())
];
}
}
}
Loading