Skip to content

Rename plugin to follow best practices #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 27, 2018
Merged
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
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Enqueue\Magento2\Plugin\Model\Config;
namespace Enqueue\Magento2\Plugin\Config;

use \Enqueue\AmqpExt\AmqpContext;
use Enqueue\Null\NullContext;
Expand All @@ -11,7 +11,7 @@
use \Enqueue\Dbal\DbalContext;
use \Magento\Framework\Exception\TemporaryState\CouldNotSaveException;

class ConfigPlugin
class ValidateConfiguration
{
/**
* @var array
Expand Down Expand Up @@ -75,22 +75,20 @@ public function beforeSave(\Magento\Config\Model\Config $subject)
if (isset($beforeSaveData['transport']['fields']['default']['value'])) {
$configValue = $beforeSaveData['transport']['fields']['default']['value'];

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

if (false == $this->isClassExists($this->_preDefinedServices[$configValue]['class'])) {
if (false === $this->isClassExists($this->_preDefinedServices[$configValue]['class'])) {
throw new CouldNotSaveException(
__(
vsprintf(
'%s transport requires package "%s". Please install it via composer. #> php composer.php require %s',
'%name transport requires package "%package".'
. ' Please install it via composer. #> php composer.php require %package',
[
$this->_preDefinedServices[$configValue]['name'],
$this->_preDefinedServices[$configValue]['package'],
$this->_preDefinedServices[$configValue]['package']
'name' => $this->_preDefinedServices[$configValue]['name'],
'package' => $this->_preDefinedServices[$configValue]['package'],
]
)
)
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="\Magento\Config\Model\Config">
<plugin name="config_data_plugin" type="Enqueue\Magento2\Plugin\Model\Config\ConfigPlugin"/>
<plugin name="enqueue_config_validation" type="Enqueue\Magento2\Plugin\Config\ValidateConfiguration"/>
</type>
</config>