Download the PHP package perfect-code/module-verify-connection-button without Composer
On this page you can find all versions of the php package perfect-code/module-verify-connection-button. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download perfect-code/module-verify-connection-button
More information about perfect-code/module-verify-connection-button
Files in perfect-code/module-verify-connection-button
Package module-verify-connection-button
Short Description Magento 2 module which gives you everything you need to add verify connection button to your configuration.
License GPL-3.0
Informations about the package module-verify-connection-button
Overview
This module helps you to add to your stores/configuration section button to check some connection with some system.
Usage
There are two ways how to use this module. Here is comparison between two possible ways. It's up to you which to use.
Step | Easy and Quick | More Scalable Way | Description |
---|---|---|---|
Implement an AdapterInterface | + | + | All in all you need to create an Adapter to verify the connection. |
Create routes.xml | + | ||
Create controller | + | It will be an empty controller extended from original. Further injection will be inside di.xml | |
Inject Adapter implementation | + | + | In easy way we use Original block and controller. In second way we use new created controller and virtual block. |
Use block in config | + | + | In first way we use original block. In second - virtual. |
Easy and quick start.
Useful for cases when you simply need only one button in your store. And you do not worry about perfect code.
To add a validation button, you need:
1. Implement AdapterInterface.
Implement an interface where you make an attempt to establish a connection with the service you need. Examples of fields usage are described in comments to this file.
2. Inject implementation from the previous step.
Then add your Service Connector (Adapter) to etc/adminhtml/di.xml
3. Use the block from this module in your config.
Add the button to your etc/adminhtml/system.xml
Alternative (more dependency inversion principle way)
According to soli[D] - DIP we need to work with abstractions. That's why I would recommend creating your own controller and create your own block.
1. Implement AdapterInterface.
Implement an interface where you make an attempt to establish a connection with the service you need. Examples of fields usage are described in comments to this file.
2. Create routes configuration.
Create etc/adminhtml/routes.xml
3. Create your controller and extend from existing.
Your controller can be empty like this one below (we will inject our Adapter through di.xml)
4. Inject dependencies using di.xml
This will be almost the same as in 'Easy Way'. The only thing - we will use our own controller.
It's unable to be done via "virtual controller", because magento need its physical persistence.
More info can be found here: \Magento\Framework\App\Router\ActionList::validateActionClass
.
We still need to inject our Adapter. Of course this can be done in your PHP class (but in my vision this is more DIP way).
Do not forget to pass your new controller action to the block which is virtual now (module/controller/action).
5. Use our virtual block in configuration.
Add the button to your etc/adminhtml/system.xml
Pay attention. Not real but virtual block.
All versions of module-verify-connection-button with dependencies
magento/framework Version *
magento/module-backend Version *
magento/module-config Version *
magento/magento-composer-installer Version *