EchoStrHandler.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. /*
  3. * This file is part of the overtrue/wechat.
  4. *
  5. * (c) overtrue <i@overtrue.me>
  6. *
  7. * This source file is subject to the MIT license that is bundled
  8. * with this source code in the file LICENSE.
  9. */
  10. namespace EasyWeChat\OfficialAccount\Server\Handlers;
  11. use EasyWeChat\Kernel\Contracts\EventHandlerInterface;
  12. use EasyWeChat\Kernel\Decorators\FinallyResult;
  13. use EasyWeChat\Kernel\ServiceContainer;
  14. /**
  15. * Class EchoStrHandler.
  16. *
  17. * @author overtrue <i@overtrue.me>
  18. */
  19. class EchoStrHandler implements EventHandlerInterface
  20. {
  21. /**
  22. * @var ServiceContainer
  23. */
  24. protected $app;
  25. /**
  26. * EchoStrHandler constructor.
  27. *
  28. * @param ServiceContainer $app
  29. */
  30. public function __construct(ServiceContainer $app)
  31. {
  32. $this->app = $app;
  33. }
  34. /**
  35. * @param mixed $payload
  36. *
  37. * @return FinallyResult|null
  38. */
  39. public function handle($payload = null)
  40. {
  41. if ($str = $this->app['request']->get('echostr')) {
  42. return new FinallyResult($str);
  43. }
  44. }
  45. }