1

I want to implement plugin after, before and around concept in my Magento 2 website.

di.xml :

<type name="Magento\Webapi\Model\Soap\Server">
    <plugin name="soap_log" type="training\learning\Model\Webapi\Soap\Server" />
</type>

Magento\Webapi\Model\Soap\Server has a method _checkRequest and it has a string type parameter.

Now i want to get that string type parameter in my _aftercheckrRequest in training\learning\Model\Webapi\Soap\Server class. How can I achieve this ?

2 Answers 2

1

You can use plugin only for public methods. See docs

1

_aftercheckrRequest method is protected and we cannot use plugin. We can use Plugins only for public and non-static methods. For example we have one public function :public function test(); and plugin:

public function afterTest(\Magento\Webapi\Model\Soap\Server $subject, $result)
{
    // your code
    return $result;
}

Note: test() became afterTest() (capital "T")

1
  • That is OK, but if it is public method then how we can get that method parameters in afterTest() ? Commented Mar 11, 2016 at 14:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.