Skip to content

Commit 6f87694

Browse files
authored
Merge pull request #5 from igrybkov/rename-plugin
Rename plugin to follow best practices
2 parents 3336784 + 6a41a7a commit 6f87694

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

Diff for: Plugin/Model/Config/ConfigPlugin.php renamed to Plugin/Config/ValidateConfiguration.php

+8-10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Enqueue\Magento2\Plugin\Model\Config;
3+
namespace Enqueue\Magento2\Plugin\Config;
44

55
use \Enqueue\AmqpExt\AmqpContext;
66
use Enqueue\Null\NullContext;
@@ -11,7 +11,7 @@
1111
use \Enqueue\Dbal\DbalContext;
1212
use \Magento\Framework\Exception\TemporaryState\CouldNotSaveException;
1313

14-
class ConfigPlugin
14+
class ValidateConfiguration
1515
{
1616
/**
1717
* @var array
@@ -75,22 +75,20 @@ public function beforeSave(\Magento\Config\Model\Config $subject)
7575
if (isset($beforeSaveData['transport']['fields']['default']['value'])) {
7676
$configValue = $beforeSaveData['transport']['fields']['default']['value'];
7777

78-
if (false == isset($this->_preDefinedServices[$configValue])) {
78+
if (false === isset($this->_preDefinedServices[$configValue])) {
7979
throw new \LogicException(sprintf('Unknown transport: "%s"', $configValue));
8080
}
8181

82-
if (false == $this->isClassExists($this->_preDefinedServices[$configValue]['class'])) {
82+
if (false === $this->isClassExists($this->_preDefinedServices[$configValue]['class'])) {
8383
throw new CouldNotSaveException(
8484
__(
85-
vsprintf(
86-
'%s transport requires package "%s". Please install it via composer. #> php composer.php require %s',
85+
'%name transport requires package "%package".'
86+
. ' Please install it via composer. #> php composer.php require %package',
8787
[
88-
$this->_preDefinedServices[$configValue]['name'],
89-
$this->_preDefinedServices[$configValue]['package'],
90-
$this->_preDefinedServices[$configValue]['package']
88+
'name' => $this->_preDefinedServices[$configValue]['name'],
89+
'package' => $this->_preDefinedServices[$configValue]['package'],
9190
]
9291
)
93-
)
9492
);
9593
}
9694
}

Diff for: etc/di.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
-->
77
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
88
<type name="\Magento\Config\Model\Config">
9-
<plugin name="config_data_plugin" type="Enqueue\Magento2\Plugin\Model\Config\ConfigPlugin"/>
9+
<plugin name="enqueue_config_validation" type="Enqueue\Magento2\Plugin\Config\ValidateConfiguration"/>
1010
</type>
1111
</config>

0 commit comments

Comments
 (0)