AbstractGearmanClientTaskEvent.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. /**
  3. * Gearman Bundle for Symfony2
  4. *
  5. * For the full copyright and license information, please view the LICENSE
  6. * file that was distributed with this source code.
  7. *
  8. * Feel free to edit as you please, and have fun.
  9. *
  10. * @author Marc Morera <yuhu@mmoreram.com>
  11. */
  12. namespace Mmoreram\GearmanBundle\Event\Abstracts;
  13. use GearmanTask;
  14. use Symfony\Component\EventDispatcher\Event;
  15. /**
  16. * AbstractGearmanClientTaskEvent
  17. */
  18. abstract class AbstractGearmanClientTaskEvent extends Event
  19. {
  20. /**
  21. * @var GearmanTask
  22. *
  23. * Gearman task object
  24. */
  25. protected $gearmanTask;
  26. /**
  27. * @var mixed
  28. *
  29. * Context that can be set in the addTask method
  30. */
  31. protected $context;
  32. /**
  33. * Construct method
  34. *
  35. * @param GearmanTask $gearmanTask Gearman Task
  36. */
  37. public function __construct(GearmanTask $gearmanTask)
  38. {
  39. $this->gearmanTask = $gearmanTask;
  40. }
  41. /**
  42. * Get Gearman Task
  43. *
  44. * @return GearmanTask Gearman Task
  45. */
  46. public function getGearmanTask()
  47. {
  48. return $this->gearmanTask;
  49. }
  50. /**
  51. * @param mixed $context Context that can be set in the addTask method
  52. */
  53. public function setContext($context)
  54. {
  55. $this->context = &$context['context'];
  56. }
  57. /**
  58. * @return mixed Context that can be set in the addTask method
  59. */
  60. public function &getContext()
  61. {
  62. return $this->context;
  63. }
  64. }