Skip to content

Commit

Permalink
plugin position
Browse files Browse the repository at this point in the history
  • Loading branch information
karliuka committed Oct 3, 2017
1 parent c91cfeb commit 754ab70
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 29 deletions.
12 changes: 6 additions & 6 deletions Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,27 @@
use Magento\Framework\App\Helper\AbstractHelper;

/**
* Faonni ShippingTweaks Data helper
* Shipping Tweaks Helper
*/
class Data extends AbstractHelper
{
/**
* Enabled config path
* Enabled Config Path
*/
const XML_TWEAKS_ENABLED = 'shipping/behavior/tweaks';
const XML_CONFIG_ENABLED = 'shipping/behavior/tweaks';

/**
* Check Tweaks mode functionality should be enabled
* Check Tweaks mode Functionality Should be Enabled
*
* @return bool
*/
public function isEnabled()
{
return $this->_getConfig(self::XML_TWEAKS_ENABLED);
return $this->_getConfig(self::XML_CONFIG_ENABLED);
}

/**
* Retrieve store configuration data
* Retrieve Store Configuration Data
*
* @param string $path
* @return string|null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,26 @@
*
* See COPYING.txt for license details.
*/
namespace Faonni\ShippingTweaks\Model\Plugin\Rate;
namespace Faonni\ShippingTweaks\Plugin\Shipping\Model\Rate;

use Faonni\ShippingTweaks\Helper\Data as ShippingTweaksHelper;

/**
* Plugin for \Magento\Shipping\Model\Rate\Result
* Shipping Result Plugin
*/
class Result
{
/**
* Helper instance
* Helper
*
* @var \Faonni\ShippingTweaks\Helper\Data
*/
protected $_helper;

/**
* Factory constructor
*
* @param \Faonni\ShippingTweaks\Helper\Data $helper
* Initialize Plugin
*
* @param ShippingTweaksHelper $helper
*/
public function __construct(
ShippingTweaksHelper $helper
Expand All @@ -32,11 +32,11 @@ public function __construct(
}

/**
* Return all rates in the result
* Return all Rates in the Result
*
* @param $subject Magento\Shipping\Model\Rate\Result
* @param $result \Magento\Quote\Model\Quote\Address\RateResult\Method[]
* @return \Magento\Quote\Model\Quote\Address\RateResult\Method[]
* @param Result $subject
* @param Method[] $result
* @return Method[]
*/
public function afterGetAllRates($subject, $result)
{
Expand All @@ -48,10 +48,10 @@ public function afterGetAllRates($subject, $result)
}

/**
* Return all free rates in the result
* Return all free Rates in the Result
*
* @param $result \Magento\Quote\Model\Quote\Address\RateResult\Method[]
* @return \Magento\Quote\Model\Quote\Address\RateResult\Method[]
* @param Method[] $result
* @return Method[]
*/
public function getAllFreeRates($result)
{
Expand Down
21 changes: 14 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,24 @@
"name": "faonni/module-shipping-tweaks",
"description": "Extension hides any other shipping methods if free shipping is available.",
"type": "magento2-module",
"version": "2.0.5",
"version": "2.0.6",
"authors": [{
"name" : "Karliuka Vitalii",
"email": "[email protected]"
}],
"license": [
"OSL-3.0"
],
],
"require": {
"php": "~5.5.0|~5.6.0|~7.0.0"
},
"php": "~5.5.0|~5.6.0|~7.0.0",
"magento/module-shipping": "100.0.*|100.1.*|100.2.*"
},
"autoload": {
"files": [ "registration.php" ],
"psr-4": {
"Faonni\\ShippingTweaks\\": ""
"files": [
"registration.php"
],
"psr-4": {
"Faonni\\ShippingTweaks\\": ""
}
}
}
3 changes: 3 additions & 0 deletions etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
<system>
<section id="shipping">
<!--
shipping behavior section
-->
<group id="behavior" translate="label" showInDefault="1" showInWebsite="1" showInStore="1" sortOrder="310">
<label>Behavior of Methods</label>
<field id="tweaks" translate="label comment" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
Expand Down
4 changes: 2 additions & 2 deletions etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd">
<!--
plugin for a class Magento\Shipping\Model\Rate\Result
plugin
-->
<type name="\Magento\Shipping\Model\Rate\Result">
<plugin name="Faonni_ShippingTweaks" type="Faonni\ShippingTweaks\Model\Plugin\Rate\Result" />
<plugin name="Faonni_ShippingTweaks" type="Faonni\ShippingTweaks\Plugin\Shipping\Model\Rate\Result" />
</type>
</config>
6 changes: 5 additions & 1 deletion etc/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,9 @@
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd">
<module name="Faonni_ShippingTweaks" setup_version="2.0.5"/>
<module name="Faonni_ShippingTweaks" setup_version="2.0.6">
<sequence>
<module name="Magento_Shipping"/>
</sequence>
</module>
</config>

0 comments on commit 754ab70

Please sign in to comment.