Plugin1.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Framework\Test\Unit\Interception\Sample;
  7. /**
  8. * Sample plugin
  9. */
  10. class Plugin1
  11. {
  12. /**
  13. * Sample before-plugin method
  14. *
  15. * @return void
  16. */
  17. public function beforeDoSomething(Entity $subject)
  18. {
  19. $subject->addPluginCall(static::class . '::' . __FUNCTION__);
  20. //Not changing arguments
  21. }
  22. /**
  23. * Sample around-plugin method
  24. *
  25. * @param Entity $subject
  26. * @param \Closure $proceed
  27. * @return mixed
  28. */
  29. public function aroundDoSomething(Entity $subject, \Closure $proceed)
  30. {
  31. $subject->addPluginCall(static::class . '::' . __FUNCTION__);
  32. //Not breaking the chain
  33. return $proceed();
  34. }
  35. /**
  36. * Sample after-plugin method
  37. *
  38. * @param Entity $subject
  39. * @param mixed $result
  40. * @return mixed
  41. */
  42. public function afterDoSomething(Entity $subject, $result)
  43. {
  44. $subject->addPluginCall(static::class . '::' . __FUNCTION__);
  45. //Not changing result
  46. return $result;
  47. }
  48. }